lib/pagarme/resources/postback.rb in pagarme-2.1.3 vs lib/pagarme/resources/postback.rb in pagarme-2.1.4
- old
+ new
@@ -2,9 +2,14 @@
class Postback < PagarMeObject
def valid?
self.class.valid_request_signature? payload, signature
end
+ def redirect(url = 'http://localhost:3000/pagarme/postback')
+ uri = URI(url)
+ Net::HTTP.new(uri.host, uri.port).post uri.path, payload, JSON.parse(headers)
+ end
+
class << self
def valid_request_signature?(payload, signature)
kind, raw_signature = signature.split '=', 2
return false if kind.blank? || raw_signature.blank?
signature(payload, kind) == raw_signature