class AlphaCard::Response
Implementation of Alpha Card Services response. Contains all the data, that Alpha Card Gateway returned for the request.
Constants
- APPROVED
Success response code
- AVS_RESPONSES
Messages for AVS response codes
- CVV_RESPONSES
Messages for CVV response codes
- DECLINED
Decline response code
- ERROR
Error response code
- RESPONSE_MESSAGES
AlphaCard
response messages
Attributes
Alpha Card Gateway response as a Hash
. @attr_reader [Hash] data
Public Class Methods
Alpha Card Response
constructor.
@param response_body [String]
Alpha Card Gateway response body text
@return [Response] Alpha Card Response
object
@example
AlphaCard::Response.new('response=1&responsetext=Test') #=> #<AlphaCard::Response:0x00000003f2b568 @data={"response"=>"1", "responsetext"=>"Test"}>
# File lib/alpha_card/response.rb, line 39 def initialize(response_body) @data = Rack::Utils.parse_query(response_body) end
Public Instance Methods
Transaction
authorization code.
@return [String] auth code
@example
response = AlphaCardResponse.new("response=1&authcode=083319") response.code #=> '083319'
# File lib/alpha_card/response.rb, line 129 def auth_code @data['authcode'] end
AVS response message.
@return [String] AVS response message
@example
response = AlphaCardResponse.new("avsresponse=A") response.avs_response #=> 'Address match only'
# File lib/alpha_card/response.rb, line 225 def avs_response AVS_RESPONSES[@data['avsresponse']] end
Numeric mapping of processor responses.
@return [String] code of the response
@example
response = AlphaCardResponse.new("response=1&response_code=100") response.code #=> '100'
# File lib/alpha_card/response.rb, line 114 def code @data['response_code'] end
Credit
Card Authorization Message based on returned code in accordance with the Global Payment Systems Credit
Card Authorization Codes (codes.yml).
@return [String] auth message
@example
response = AlphaCardResponse.new("response_text=AP") response.credit_card_auth_message #=> 'Approved or completed successfully'
# File lib/alpha_card/response.rb, line 144 def credit_card_auth_message AlphaCard::CREDIT_CARD_CODES[text] end
CVV response message.
@return [String] CVV response message
@example
response = AlphaCardResponse.new("cvvresponse=M") response.cvv_response #=> 'CVV2/CVC2 match'
# File lib/alpha_card/response.rb, line 210 def cvv_response CVV_RESPONSES[@data['cvvresponse']] end
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was declined.
@return [Bool] true if request was declined
@example
response = AlphaCardResponse.new("response=2") response.declined? #=> true
# File lib/alpha_card/response.rb, line 178 def declined? @data['response'] == DECLINED end
Indicate the state of the request to the Alpha Card Gateway. Returns true if request has some errors.
@return [Bool] true if request has some errors
@example
response = AlphaCardResponse.new("response=3") response.error? #=> true
# File lib/alpha_card/response.rb, line 195 def error? @data['response'] == ERROR end
Response
message by response code.
@return [String] response message
@example
response = AlphaCardResponse.new("response_code=>300") response.message #=> 'Transaction was rejected by gateway'
# File lib/alpha_card/response.rb, line 69 def message RESPONSE_MESSAGES[code] end
The original order id passed in the transaction request.
@return [String] Order
ID
@example
response = AlphaCardResponse.new("response=1&orderid=123") response.order_id #=> '123'
# File lib/alpha_card/response.rb, line 99 def order_id @data['orderid'] end
Indicate the state of the request to the Alpha Card Gateway. Returns true if request was approved.
@return [Bool] true if request if successful
@example
response = AlphaCardResponse.new("response=1") response.success? #=> true
# File lib/alpha_card/response.rb, line 161 def success? @data['response'] == APPROVED end
Textual response of the Alpha Card Gateway.
@return [String] text of the response
@example
response = AlphaCardResponse.new("response=1&responsetext=Test") response.text #=> 'Test'
# File lib/alpha_card/response.rb, line 54 def text @data['responsetext'] end
Payment gateway transaction ID.
@return [String] transaction ID
@example
response = AlphaCardResponse.new("response=1&transactionid=123") response.transaction_id #=> '123'
# File lib/alpha_card/response.rb, line 84 def transaction_id @data['transactionid'] end