Sha256: 10425a4aeb20014b112f2db3b60b0d17b558d0a254cfc51e74b9d874b2736b81
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'base64' require 'stringio' require 'zlib' require 'openssl' module ActiveMerchant #:nodoc: module Billing #:nodoc: module Integrations #:nodoc: module Adyen class Return < ActiveMerchant::Billing::Integrations::Return attr_accessor :shared_secret # for verifying the signature of the URL parameters returned by Adyen after the payment process PAYMENT_RESULT_SIGNATURE_FIELDS = [ :authResult, :pspReference, :merchantReference, :skinCode ] def generate_signature_string ::ActiveMerchant::Billing::Integrations::Adyen::Return::PAYMENT_RESULT_SIGNATURE_FIELDS.map {|key| @params[key.to_s]} * "" end def generate_signature digest = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, @shared_secret, generate_signature_string) return Base64.encode64(digest).strip end def signature_is_valid? generate_signature.to_s == params['merchantSig'].to_s end def payment_authorized? params['authResult'] == 'AUTHORISED' end def success? signature_is_valid? and payment_authorized? end def message params['authResult'] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activemerchant-est-1.4.2.6 | lib/active_merchant/billing/integrations/adyen/return.rb |
activemerchant-est-1.4.2.5 | lib/active_merchant/billing/integrations/adyen/return.rb |