module Adyen::REST::Signature

The Signature module can sign and verify HMAC SHA-256 signatures for API

Public Instance Methods

sign(params) click to toggle source

Sign the parameters with the given shared secret @param [Hash] params The set of parameters to sign. Should sent `sharedSecret` to sign. @return [String] signature from parameters

   # File lib/adyen/rest/signature.rb
12 def sign(params)
13   Adyen::Signature.sign(params, :rest)
14 end
verify(params) click to toggle source

Verify the parameters with the given shared secret @param [Hash] params The set of parameters to verify. Should include `sharedSecret` param to sign and the `hmacSignature` param to compare with the signature calculated @return [Boolean] true if the `hmacSignature` in the params matches our calculated signature

   # File lib/adyen/rest/signature.rb
20 def verify(params)
21   their_sig = params.delete('hmacSignature')
22   raise ArgumentError, "params must include 'hmacSignature' for verification" if their_sig.empty?
23   Adyen::Signature.verify(params, their_sig, :rest)
24 end