Class: AlphaCard::AlphaCardResponse
- Inherits:
-
Object
- Object
- AlphaCard::AlphaCardResponse
- Defined in:
- lib/alpha_card/alpha_card_response.rb
Overview
Implementation of Alpha Card Services response. Contains all the data, that Alpha Card Gateway returned for the request.
Constant Summary collapse
- APPROVED =
Success response code
'1'
- DECLINED =
Decline response code
'2'
- ERROR =
Error response code
'3'
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Alpha Card Gateway response as a
Hash
.
Instance Method Summary collapse
-
#code ⇒ String
The code of the Alpha Card Gateway response.
-
#declined? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway.
-
#error? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway.
-
#initialize(response_body) ⇒ AlphaCardResponse
constructor
AlphaCardResponse constructor.
-
#success? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway.
-
#text ⇒ String
The text of the Alpha Card Gateway response.
-
#transaction_id ⇒ String
The ID of the transaction.
Constructor Details
#initialize(response_body) ⇒ AlphaCardResponse
AlphaCardResponse constructor.
30 31 32 |
# File 'lib/alpha_card/alpha_card_response.rb', line 30 def initialize(response_body) @data = Rack::Utils.parse_query(response_body) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Alpha Card Gateway response as a Hash
.
9 10 11 |
# File 'lib/alpha_card/alpha_card_response.rb', line 9 def data @data end |
Instance Method Details
#code ⇒ String
The code of the Alpha Card Gateway response.
76 77 78 |
# File 'lib/alpha_card/alpha_card_response.rb', line 76 def code @data['response_code'] end |
#declined? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was declined.
110 111 112 |
# File 'lib/alpha_card/alpha_card_response.rb', line 110 def declined? @data['response'] == DECLINED end |
#error? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway. Returns true if request has some errors.
127 128 129 |
# File 'lib/alpha_card/alpha_card_response.rb', line 127 def error? @data['response'] == ERROR end |
#success? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was approved.
93 94 95 |
# File 'lib/alpha_card/alpha_card_response.rb', line 93 def success? @data['response'] == APPROVED end |
#text ⇒ String
The text of the Alpha Card Gateway response.
45 46 47 |
# File 'lib/alpha_card/alpha_card_response.rb', line 45 def text @data['responsetext'] end |
#transaction_id ⇒ String
The ID of the transaction. Can be used to process refund operation.
61 62 63 |
# File 'lib/alpha_card/alpha_card_response.rb', line 61 def transaction_id @data['transactionid'] end |