Class: Buckaroo::Ideal::ResponseSignature
- Inherits:
-
Object
- Object
- Buckaroo::Ideal::ResponseSignature
- Includes:
- Util
- Defined in:
- lib/buckaroo-ideal/response_signature.rb
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#response ⇒ Buckaroo::Ideal::Response
readonly
The response that was signed.
-
#secret ⇒ String
readonly
The secret key that is used to sign the order.
-
#signature ⇒ String
readonly
The signature that was given in the response.
Instance Method Summary collapse
- #generate_signature ⇒ Object
-
#initialize(response, signature = '') ⇒ ResponseSignature
constructor
A new instance of ResponseSignature.
-
#merchant_key ⇒ String
The configured merchant_key in
Buckaroo::Ideal::Config
. -
#secret_key ⇒ String
The configured secret_key in
Buckaroo::Ideal::Config
. - #valid? ⇒ Boolean
Methods included from Util
#compact, #from_cents, #from_numeric_boolean, #to_cents, #to_normalized_string, #to_numeric_boolean
Constructor Details
#initialize(response, signature = '') ⇒ ResponseSignature
Returns a new instance of ResponseSignature.
23 24 25 26 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 23 def initialize(response, signature = '') @response = response @signature = signature end |
Instance Attribute Details
#response ⇒ Buckaroo::Ideal::Response (readonly)
Returns The response that was signed.
18 19 20 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 18 def response @response end |
#secret ⇒ String (readonly)
Returns The secret key that is used to sign the order.
21 22 23 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 21 def secret @secret end |
#signature ⇒ String (readonly)
Returns The signature that was given in the response.
15 16 17 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 15 def signature @signature end |
Instance Method Details
#generate_signature ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 32 def generate_signature salt = [ response.transaction_id, response., merchant_key, response.invoice_number, response.reference, response.currency, to_cents(response.amount), response.status.code, to_numeric_boolean(response.test_mode), secret_key ].join Digest::MD5.hexdigest(salt) end |
#merchant_key ⇒ String
Returns The configured merchant_key in Buckaroo::Ideal::Config
.
9 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 9 delegate :merchant_key, :to => Config |
#secret_key ⇒ String
Returns The configured secret_key in Buckaroo::Ideal::Config
.
12 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 12 delegate :secret_key, :to => Config |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/buckaroo-ideal/response_signature.rb', line 28 def valid? signature == generate_signature end |