Class: Adyen::HPP::Response
- Inherits:
-
Object
- Object
- Adyen::HPP::Response
- Defined in:
- lib/adyen/hpp/response.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#shared_secret ⇒ Object
readonly
Returns the value of attribute shared_secret.
Instance Method Summary collapse
-
#has_valid_signature? ⇒ true, false
Checks the redirect signature for this request by calculating the signature from the provided parameters, and comparing it to the signature provided in the
merchantSig
parameter. -
#initialize(params, shared_secret: nil) ⇒ Response
constructor
Initialize the HPP response.
Constructor Details
#initialize(params, shared_secret: nil) ⇒ Response
Initialize the HPP response
13 14 15 16 17 18 19 20 |
# File 'lib/adyen/hpp/response.rb', line 13 def initialize(params, shared_secret: nil) raise ArgumentError, "params should be a Hash" unless params.is_a?(Hash) raise ArgumentError, "params should contain :merchantSig" unless params.key?('merchantSig') @params = params skin = Adyen.configuration.form_skin_by_code(params['skinCode']) || {} @shared_secret = shared_secret || skin[:shared_secret] end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/adyen/hpp/response.rb', line 5 def params @params end |
#shared_secret ⇒ Object (readonly)
Returns the value of attribute shared_secret.
5 6 7 |
# File 'lib/adyen/hpp/response.rb', line 5 def shared_secret @shared_secret end |
Instance Method Details
#has_valid_signature? ⇒ true, false
Checks the redirect signature for this request by calculating the signature from the provided parameters, and comparing it to the signature provided in the merchantSig
parameter.
If this method returns false, the request could be a forgery and should not be handled. Therefore, you should include this check in a before_filter
, and raise an error of the signature check fails.
47 48 49 |
# File 'lib/adyen/hpp/response.rb', line 47 def has_valid_signature? Adyen::HPP::Signature.verify(params, shared_secret) end |