Method: Adyen::Form#calculate_billing_address_signature

Defined in:
lib/adyen/form.rb

#calculate_billing_address_signature(parameters, shared_secret = nil) ⇒ String

Calculates the billing address request signature for the given billing address parameters.

This signature is used by Adyen to check whether the request is genuinely originating from you. The resulting signature should be included in the billing address request parameters as the billingAddressSig parameter; the shared secret should of course not be included.

Parameters:

  • parameters (Hash)

    The billing address parameters for which to calculate the billing address request signature.

  • shared_secret (String) (defaults to: nil)

    The shared secret to use for this signature. It should correspond with the skin_code parameter. This parameter can be left out if the shared_secret is included as key in the parameters.

Returns:

  • (String)

    The signature of the billing address request

Raises:

  • (ArgumentError)

    Thrown if shared_secret is empty



303
304
305
306
307
# File 'lib/adyen/form.rb', line 303

def calculate_billing_address_signature(parameters, shared_secret = nil)
  shared_secret ||= parameters.delete(:shared_secret)
  raise ArgumentError, "Cannot calculate billing address request signature with empty shared_secret" if shared_secret.to_s.empty?
  Adyen::Util.hmac_base64(shared_secret, calculate_billing_address_signature_string(parameters[:billing_address]))
end