Class: Cardia::TransactionStatus
- Defined in:
- lib/cardia/transaction_status.rb
Overview
Wrapper around the result of the ReturnTransactionStatus call to Cardia
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#recurring_code ⇒ Object
Returns the value of attribute recurring_code.
-
#response_code ⇒ Object
Returns the value of attribute response_code.
Attributes inherited from Enum
Instance Method Summary collapse
-
#explanation ⇒ Object
Explains the current status.
-
#response_code_to_string ⇒ Object
:nodoc:.
-
#response_message ⇒ Object
Returns the response code as a human readable text.
-
#response_success? ⇒ Boolean
Whether the transaction was successful.
Methods inherited from Enum
#==, define_constructor, #description, enums, #initialize, map, #to_s
Constructor Details
This class inherits a constructor from Enum
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/cardia/transaction_status.rb', line 4 def amount @amount end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
4 5 6 |
# File 'lib/cardia/transaction_status.rb', line 4 def currency_code @currency_code end |
#recurring_code ⇒ Object
Returns the value of attribute recurring_code.
4 5 6 |
# File 'lib/cardia/transaction_status.rb', line 4 def recurring_code @recurring_code end |
#response_code ⇒ Object
Returns the value of attribute response_code.
4 5 6 |
# File 'lib/cardia/transaction_status.rb', line 4 def response_code @response_code end |
Instance Method Details
#explanation ⇒ Object
Explains the current status
12 13 14 15 16 17 |
# File 'lib/cardia/transaction_status.rb', line 12 def explanation if self.response_success? return description end return "#{}, #{description}" end |
#response_code_to_string ⇒ Object
:nodoc:
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cardia/transaction_status.rb', line 33 def response_code_to_string #:nodoc: result = { 0 => "Success", 6 => "Invalid card number", 7 => "Card is hot listed (known card used for fraud)", 17 => "Card is expired", 18 => "Invalid expiry date", 19 => "Card number is not valid", 22 => "Card type is not registered for merchant", 45 => "Amount exceeds allowed amount", 46 => "Amount is below minimum amount", 54 => "Card can not be used for internet purchases", 69 => "The bank do not authorise the payment (authorisation not OK)", 74 => "Card is rejected", 75 => "Not authorised"} [25, 26, 27, 28, 29, 31].each do |each| result[each] = "Card can not be used for internet purchases" end return result end |
#response_message ⇒ Object
Returns the response code as a human readable text
25 26 27 28 29 30 31 |
# File 'lib/cardia/transaction_status.rb', line 25 def result = response_code_to_string[response_code] if result.nil? result = "Unknown response code %s" % response_code end return result end |
#response_success? ⇒ Boolean
Whether the transaction was successful
20 21 22 |
# File 'lib/cardia/transaction_status.rb', line 20 def response_success? response_code == 0 end |