Class: Buckaroo::Ideal::RequestSignature
- Inherits:
-
Object
- Object
- Buckaroo::Ideal::RequestSignature
- Includes:
- Util
- Defined in:
- lib/buckaroo-ideal/request_signature.rb
Overview
Digital signature generator for Buckaroo::Ideal::Order
instances.
A digital signature is used to sign your request so the Buckaroo Payment Service can validate that the request was made by your application.
A digital signature is composed by generating a MD5 hash of the following values:
-
Merchant Key: The
merchant_key
that is provided by Buckaroo and set inBuckaroo::Ideal::Config
. -
Invoice Number: The
invoice_number
that is set in yourBuckaroo::Ideal::Order
instance. -
Amount: The
amount
that is set in yourBuckaroo::Ideal::Order
instance in cents. -
Currency: The
currency
that is set in yourBuckaroo::Ideal::Order
instance. -
Mode: The
test_mode
that is set inBuckaroo::Ideal::Config
.
To create a signature for an Buckaroo::Ideal::Order
, instantiate a new Buckaroo::Ideal::RequestSignature
and provide the order:
order = Buckaroo::Ideal::Order.new(amount: 100, invoice_number: 'EETNU-123')
signature = Buckaroo::Ideal::Signature.new(order)
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#order ⇒ Buckaroo::Ideal::Order
readonly
The order that is being signed.
Instance Method Summary collapse
-
#initialize(order) ⇒ Buckaroo::Ideal::Signature
constructor
Initialize a new
Buckaroo::Ideal::Signature
instance for the given order. -
#merchant_key ⇒ String
The configured merchant_key in
Buckaroo::Ideal::Config
. -
#secret_key ⇒ String
The configured secret_key in
Buckaroo::Ideal::Config
. - #signature ⇒ Object (also: #to_s)
-
#test_mode ⇒ Boolean
The configured test_mode in
Buckaroo::Ideal::Config
.
Methods included from Util
#compact, #from_cents, #from_numeric_boolean, #to_cents, #to_normalized_string, #to_numeric_boolean
Constructor Details
#initialize(order) ⇒ Buckaroo::Ideal::Signature
Initialize a new Buckaroo::Ideal::Signature
instance for the given order.
51 52 53 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 51 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Buckaroo::Ideal::Order (readonly)
Returns The order that is being signed.
32 33 34 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 32 def order @order end |
Instance Method Details
#merchant_key ⇒ String
Returns The configured merchant_key in Buckaroo::Ideal::Config
.
38 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 38 delegate :merchant_key, :to => Config |
#secret_key ⇒ String
Returns The configured secret_key in Buckaroo::Ideal::Config
.
41 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 41 delegate :secret_key, :to => Config |
#signature ⇒ Object Also known as: to_s
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 55 def signature salt = [ merchant_key, to_normalized_string(order.invoice_number), to_cents(order.amount), order.currency, to_numeric_boolean(test_mode), secret_key ].join Digest::MD5.hexdigest(salt) end |
#test_mode ⇒ Boolean
Returns The configured test_mode in Buckaroo::Ideal::Config
.
35 |
# File 'lib/buckaroo-ideal/request_signature.rb', line 35 delegate :test_mode, :to => Config |