class PayplugRails::Payplug
Public Class Methods
create_payment(amount, ipn_url, customer_hash={})
click to toggle source
# File lib/payplug_rails.rb, line 17 def self.create_payment(amount, ipn_url, customer_hash={}) data = { currency: 'EUR', amount: amount, ipn_url: ipn_url, origin: "PayplugRails-"+PayplugRails::VERSION, }.merge(customer_hash).to_query key = OpenSSL::PKey::RSA.new PayplugRails.private_key raw_sign = key.sign(OpenSSL::Digest::SHA1.new, data) http_sign = CGI.escape(Base64.strict_encode64(raw_sign)) http_data = CGI.escape(Base64.strict_encode64(data)) return PayplugRails.url+"?data="+http_data+"&sign="+http_sign end
verify(request)
click to toggle source
# File lib/payplug_rails.rb, line 33 def self.verify(request) # Verify the IPN contained in the http request if request.raw_post.blank? return false end signature = Base64.decode64(request.headers['HTTP_PAYPLUG_SIGNATURE']) body = request.raw_post key = OpenSSL::PKey::RSA.new PayplugRails.payplug_public_key status = key.verify(OpenSSL::Digest::SHA1.new, signature, body) return status end