Class: Cardia::TransactionStatus

Inherits:
Enum show all
Defined in:
lib/cardia/transaction_status.rb

Overview

Wrapper around the result of the ReturnTransactionStatus call to Cardia

Instance Attribute Summary collapse

Attributes inherited from Enum

#code

Instance Method Summary collapse

Methods inherited from Enum

#==, define_constructor, #description, enums, #initialize, map, #to_s

Constructor Details

This class inherits a constructor from Enum

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/cardia/transaction_status.rb', line 4

def amount
  @amount
end

#currency_codeObject

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_codeObject

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_codeObject

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

#explanationObject

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 "#{response_message}, #{description}"
end

#response_code_to_stringObject

: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_messageObject

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 response_message
  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

Returns:

  • (Boolean)


20
21
22
# File 'lib/cardia/transaction_status.rb', line 20

def response_success?
  response_code == 0
end