Class: AlphaCard::Response
- Inherits:
-
Object
- Object
- AlphaCard::Response
- Defined in:
- lib/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'.freeze
- DECLINED =
Decline response code
'2'.freeze
- ERROR =
Error response code
'3'.freeze
- CVV_RESPONSES =
Messages for CVV response codes
YAML.load_file(File.('../data/cvv_responses.yml', __FILE__)).freeze
- AVS_RESPONSES =
Messages for AVS response codes
YAML.load_file(File.('../data/avs_responses.yml', __FILE__)).freeze
- RESPONSE_MESSAGES =
AlphaCard response messages
YAML.load_file(File.('../data/response_messages.yml', __FILE__)).freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Alpha Card Gateway response as a
Hash.
Instance Method Summary collapse
-
#auth_code ⇒ String
Transaction authorization code.
-
#avs_response ⇒ String
AVS response message.
-
#code ⇒ String
Numeric mapping of processor responses.
-
#credit_card_auth_message ⇒ String
Credit Card Authorization Message based on returned code in accordance with the Global Payment Systems Credit Card Authorization Codes (codes.yml).
-
#cvv_response ⇒ String
CVV response message.
-
#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) ⇒ Response
constructor
Alpha Card Response constructor.
-
#message ⇒ String
Response message by response code.
-
#order_id ⇒ String
The original order id passed in the transaction request.
-
#success? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway.
-
#text ⇒ String
Textual response of the Alpha Card Gateway.
-
#transaction_id ⇒ String
Payment gateway transaction ID.
Constructor Details
#initialize(response_body) ⇒ Response
Alpha Card Response constructor.
39 40 41 |
# File 'lib/alpha_card/response.rb', line 39 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/response.rb', line 9 def data @data end |
Instance Method Details
#auth_code ⇒ String
Transaction authorization code.
129 130 131 |
# File 'lib/alpha_card/response.rb', line 129 def auth_code @data['authcode'] end |
#avs_response ⇒ String
AVS response message.
225 226 227 |
# File 'lib/alpha_card/response.rb', line 225 def avs_response AVS_RESPONSES[@data['avsresponse']] end |
#code ⇒ String
Numeric mapping of processor responses.
114 115 116 |
# File 'lib/alpha_card/response.rb', line 114 def code @data['response_code'] end |
#credit_card_auth_message ⇒ String
Credit Card Authorization Message based on returned code in accordance with the Global Payment Systems Credit Card Authorization Codes (codes.yml).
144 145 146 |
# File 'lib/alpha_card/response.rb', line 144 def AlphaCard::CREDIT_CARD_CODES[text] end |
#cvv_response ⇒ String
CVV response message.
210 211 212 |
# File 'lib/alpha_card/response.rb', line 210 def cvv_response CVV_RESPONSES[@data['cvvresponse']] end |
#declined? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was declined.
178 179 180 |
# File 'lib/alpha_card/response.rb', line 178 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.
195 196 197 |
# File 'lib/alpha_card/response.rb', line 195 def error? @data['response'] == ERROR end |
#message ⇒ String
Response message by response code.
69 70 71 |
# File 'lib/alpha_card/response.rb', line 69 def RESPONSE_MESSAGES[code] end |
#order_id ⇒ String
The original order id passed in the transaction request.
99 100 101 |
# File 'lib/alpha_card/response.rb', line 99 def order_id @data['orderid'] end |
#success? ⇒ Bool
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was approved.
161 162 163 |
# File 'lib/alpha_card/response.rb', line 161 def success? @data['response'] == APPROVED end |
#text ⇒ String
Textual response of the Alpha Card Gateway.
54 55 56 |
# File 'lib/alpha_card/response.rb', line 54 def text @data['responsetext'] end |
#transaction_id ⇒ String
Payment gateway transaction ID.
84 85 86 |
# File 'lib/alpha_card/response.rb', line 84 def transaction_id @data['transactionid'] end |