Class: ActiveMerchant::Billing::Integrations::Adyen::Return

Inherits:
Return
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/adyen/return.rb

Constant Summary collapse

PAYMENT_RESULT_SIGNATURE_FIELDS =

for verifying the signature of the URL parameters returned by Adyen after the payment process

[
  :authResult,
  :pspReference,
  :merchantReference,
  :skinCode
]

Instance Attribute Summary collapse

Attributes inherited from Return

#params

Instance Method Summary collapse

Methods inherited from Return

#initialize, #parse

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Return

Instance Attribute Details

#shared_secretObject

Returns the value of attribute shared_secret.



12
13
14
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 12

def shared_secret
  @shared_secret
end

Instance Method Details

#generate_signatureObject



26
27
28
29
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 26

def generate_signature
  digest = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, @shared_secret, generate_signature_string)
  return Base64.encode64(digest).strip
end

#generate_signature_stringObject



22
23
24
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 22

def generate_signature_string
  ::ActiveMerchant::Billing::Integrations::Adyen::Return::PAYMENT_RESULT_SIGNATURE_FIELDS.map {|key| @params[key.to_s]} * ""
end

#messageObject



43
44
45
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 43

def message
  params['authResult']
end

#payment_authorized?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 35

def payment_authorized?
  params['authResult'] == 'AUTHORISED'
end

#signature_is_valid?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 31

def signature_is_valid?
  generate_signature.to_s == params['merchantSig'].to_s
end

#success?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/active_merchant/billing/integrations/adyen/return.rb', line 39

def success?
  signature_is_valid? and payment_authorized?
end