Class: AbnAmro::Internetkassa::Response
- Inherits:
-
Object
- Object
- AbnAmro::Internetkassa::Response
show all
- Defined in:
- lib/abn-amro/internetkassa/response.rb,
lib/abn-amro/internetkassa/response_codes.rb
Defined Under Namespace
Modules: Codes
Classes: SignatureInvalidError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params) ⇒ Response
Returns a new instance of Response.
10
11
12
13
14
15
16
|
# File 'lib/abn-amro/internetkassa/response.rb', line 10
def initialize(params)
@params = params
unless valid?
raise SignatureInvalidError, "signature `#{signature}' does not match the signature calculated for this message `#{calculated_signature}'"
end
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
8
9
10
|
# File 'lib/abn-amro/internetkassa/response.rb', line 8
def params
@params
end
|
Instance Method Details
#acceptance ⇒ Object
23
|
# File 'lib/abn-amro/internetkassa/response.rb', line 23
def acceptance; @params['ACCEPTANCE'] end
|
#amount ⇒ Object
33
34
35
|
# File 'lib/abn-amro/internetkassa/response.rb', line 33
def amount
@amount ||= (@params['amount'].to_f * 100).to_i
end
|
#authorized? ⇒ Boolean
51
52
53
|
# File 'lib/abn-amro/internetkassa/response.rb', line 51
def authorized?
status_code == '5'
end
|
#captured? ⇒ Boolean
55
56
57
|
# File 'lib/abn-amro/internetkassa/response.rb', line 55
def captured?
status_code == '9'
end
|
#card_brand ⇒ Object
29
|
# File 'lib/abn-amro/internetkassa/response.rb', line 29
def card_brand; @params['BRAND'] end
|
#card_expiration_date ⇒ Object
31
|
# File 'lib/abn-amro/internetkassa/response.rb', line 31
def card_expiration_date; @params['ED'] end
|
#card_number ⇒ Object
30
|
# File 'lib/abn-amro/internetkassa/response.rb', line 30
def card_number; @params['CARDNO'] end
|
#currency ⇒ Object
24
|
# File 'lib/abn-amro/internetkassa/response.rb', line 24
def currency; @params['currency'] end
|
#customer_name ⇒ Object
28
|
# File 'lib/abn-amro/internetkassa/response.rb', line 28
def customer_name; @params['CN'] end
|
#error_code ⇒ Object
26
|
# File 'lib/abn-amro/internetkassa/response.rb', line 26
def error_code; @params['NCERROR'] if @params['NCERROR'] != '0' end
|
#error_message ⇒ Object
67
68
69
|
# File 'lib/abn-amro/internetkassa/response.rb', line 67
def error_message
Codes::ERROR_CODES[error_code][:explanation] if error_code
end
|
#order_id ⇒ Object
20
|
# File 'lib/abn-amro/internetkassa/response.rb', line 20
def order_id; @params['orderID'] end
|
#payment_id ⇒ Object
21
|
# File 'lib/abn-amro/internetkassa/response.rb', line 21
def payment_id; @params['PAYID'] end
|
#payment_method ⇒ Object
22
|
# File 'lib/abn-amro/internetkassa/response.rb', line 22
def payment_method; @params['PM'] end
|
#retry? ⇒ Boolean
59
60
61
|
# File 'lib/abn-amro/internetkassa/response.rb', line 59
def retry?
Codes::ERROR_CODES[error_code][:retry] if error_code
end
|
#signature ⇒ Object
27
|
# File 'lib/abn-amro/internetkassa/response.rb', line 27
def signature; @params['SHASIGN'] end
|
#status_code ⇒ Object
25
|
# File 'lib/abn-amro/internetkassa/response.rb', line 25
def status_code; @params['STATUS'] end
|
#status_message ⇒ Object
63
64
65
|
# File 'lib/abn-amro/internetkassa/response.rb', line 63
def status_message
Codes::STATUS_CODES[status_code]
end
|
#success? ⇒ Boolean
47
48
49
|
# File 'lib/abn-amro/internetkassa/response.rb', line 47
def success?
error_code.nil? && (authorized? || captured?)
end
|
#transaction_date ⇒ Object
37
38
39
|
# File 'lib/abn-amro/internetkassa/response.rb', line 37
def transaction_date
@transaction_date ||= Date.parse(@params['TRXDATE'], true)
end
|
#valid? ⇒ Boolean
43
44
45
|
# File 'lib/abn-amro/internetkassa/response.rb', line 43
def valid?
signature == calculated_signature
end
|