Fix ifthenpay callback

This commit is contained in:
Hugo Peixoto 2024-02-01 09:16:02 +00:00
parent 4eb6d2de05
commit c7a5f2a8e0

View File

@ -18,7 +18,8 @@ module IfThenPay
end end
def self.payments(date) def self.payments(date)
URI("https://ifthenpay.com/ifmbws/ifmbws.asmx/getPaymentsJson?chavebackoffice=#{ENV['IFTHENPAY_BO_KEY']}&entidade=&subentidade=&dtHrInicio=#{date}&dtHrFim=#{date}&referencia=&valor=&sandbox=0") end_date = (Time.parse(date) + 1).strftime("%Y-%m-%d %H:%M:%S")
URI("https://ifthenpay.com/ifmbws/ifmbws.asmx/getPaymentsJson?chavebackoffice=#{ENV['IFTHENPAY_BO_KEY']}&entidade=&subentidade=&dtHrInicio=#{date}&dtHrFim=#{end_date}&referencia=&valor=&sandbox=0")
.then{|u| Net::HTTP.get(u)} .then{|u| Net::HTTP.get(u)}
.then{|b| Nokogiri::XML(b).child.child.text} .then{|b| Nokogiri::XML(b).child.child.text}
.then{|x| JSON.parse(x)} .then{|x| JSON.parse(x)}