Class: Buckaroo::Ideal::ResponseSignature

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/buckaroo-ideal/response_signature.rb

Constant Summary

Constants included from Util

Util::STRIP_ACCENTS_RE

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseBuckaroo::Ideal::Response (readonly)

Returns The response that was signed.

Returns:



18
19
20
# File 'lib/buckaroo-ideal/response_signature.rb', line 18

def response
  @response
end

#secretString (readonly)

Returns The secret key that is used to sign the order.

Returns:

  • (String)

    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

#signatureString (readonly)

Returns The signature that was given in the response.

Returns:

  • (String)

    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_signatureObject



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.timestamp,
    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_keyString

Returns The configured merchant_key in Buckaroo::Ideal::Config.

Returns:

  • (String)

    The configured merchant_key in Buckaroo::Ideal::Config



9
# File 'lib/buckaroo-ideal/response_signature.rb', line 9

delegate :merchant_key, :to => Config

#secret_keyString

Returns The configured secret_key in Buckaroo::Ideal::Config.

Returns:

  • (String)

    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

Returns:

  • (Boolean)


28
29
30
# File 'lib/buckaroo-ideal/response_signature.rb', line 28

def valid?
  signature == generate_signature
end