|
1
|
1 |
|
module AuthorizeNet |
|
2
|
|
|
# The core, key/value response class. You shouldn't instantiate this one. |
|
3
|
|
|
# Instead you should use AuthorizeNet::AIM::Response or AuthorizeNet::SIM::Response. |
|
4
|
1 |
|
class KeyValueResponse < AuthorizeNet::Response |
|
5
|
|
|
# Defines constants for each response code. |
|
6
|
1 |
|
module ResponseCode |
|
7
|
1 |
|
APPROVED = '1'.freeze |
|
8
|
1 |
|
DECLINED = '2'.freeze |
|
9
|
1 |
|
ERROR = '3'.freeze |
|
10
|
1 |
|
HELD = '4'.freeze |
|
11
|
|
|
end |
|
12
|
|
|
|
|
13
|
|
|
# Defines constants for each address verification response code. |
|
14
|
1 |
|
module AVSResponseCode |
|
15
|
1 |
|
ADDRESS_MATCH_NOT_ZIP = 'A'.freeze |
|
16
|
1 |
|
NO_INFO = 'B'.freeze |
|
17
|
1 |
|
ERROR = 'E'.freeze |
|
18
|
1 |
|
NON_US = 'G'.freeze |
|
19
|
1 |
|
NO_MATCH = 'N'.freeze |
|
20
|
1 |
|
NOT_APPLICABLE = 'P'.freeze |
|
21
|
1 |
|
RETRY = 'R'.freeze |
|
22
|
1 |
|
NOT_SUPPOPRTED = 'S'.freeze |
|
23
|
1 |
|
UNAVAILABLE = 'U'.freeze |
|
24
|
1 |
|
ZIP9_MATCH_NOT_ADDRESS = 'W'.freeze |
|
25
|
1 |
|
ADDRESS_AND_ZIP9_MATCH = 'X'.freeze |
|
26
|
1 |
|
ADDRESS_AND_ZIP5_MATCH = 'Y'.freeze |
|
27
|
1 |
|
ZIP5_MATCH_NOT_ADDRESS = 'Z'.freeze |
|
28
|
|
|
end |
|
29
|
|
|
|
|
30
|
|
|
# Defines constants for each supported credit card type. |
|
31
|
1 |
|
module CardType |
|
32
|
1 |
|
VISA = 'Visa'.freeze |
|
33
|
1 |
|
MASTER_CARD = 'MasterCard'.freeze |
|
34
|
1 |
|
AMEX = 'American Express'.freeze |
|
35
|
1 |
|
DISCOVER = 'Discover'.freeze |
|
36
|
1 |
|
DINERS_CLUB = 'Diners Club'.freeze |
|
37
|
1 |
|
JCB = 'JCB'.freeze |
|
38
|
|
|
end |
|
39
|
|
|
|
|
40
|
|
|
# Defines constants for CCV code validation responses. |
|
41
|
1 |
|
module CCVResponseCode |
|
42
|
1 |
|
MATCH = 'M'.freeze |
|
43
|
1 |
|
NO_MATCH = 'N'.freeze |
|
44
|
1 |
|
NOT_PROCESSED = 'P'.freeze |
|
45
|
1 |
|
SHOULD_HAVE_BEEN_PRESENT = 'S'.freeze |
|
46
|
1 |
|
UNABLE_TO_PROCESS = 'U'.freeze |
|
47
|
|
|
end |
|
48
|
|
|
|
|
49
|
|
|
# Defines constants for CAVV code validation responses. |
|
50
|
1 |
|
module CAVVResponseCode |
|
51
|
1 |
|
ERRONEOUS_DATA = '0'.freeze |
|
52
|
1 |
|
FAILED_VALIDATION = '1'.freeze |
|
53
|
1 |
|
PASSED_VALIDATION = '2'.freeze |
|
54
|
1 |
|
ISSUER_ATTEMPT_INCOMPLETE = '3'.freeze |
|
55
|
1 |
|
ISSUER_SYSTEM_ERROR = '4'.freeze |
|
56
|
1 |
|
FAILED_ISSUER_AVAILABLE = '7'.freeze |
|
57
|
1 |
|
PASSED_ISSUER_AVAILABLE = '8'.freeze |
|
58
|
1 |
|
FAILED_ISSUER_UNAVAILABLE = '9'.freeze |
|
59
|
1 |
|
PASSED_ISSUER_UNAVAILABLE = 'A'.freeze |
|
60
|
1 |
|
PASSED_NO_LIABILITY_SHIFT = 'B'.freeze |
|
61
|
|
|
end |
|
62
|
|
|
|
|
63
|
|
|
# Check to see if the transaction was approved. |
|
64
|
1 |
|
def approved? |
|
65
|
|
|
@fields[:response_code] == ResponseCode::APPROVED |
|
66
|
|
|
end |
|
67
|
|
|
|
|
68
|
|
|
# Check to see if the transaction was declined. |
|
69
|
1 |
|
def declined? |
|
70
|
|
|
@fields[:response_code] == ResponseCode::DECLINED |
|
71
|
|
|
end |
|
72
|
|
|
|
|
73
|
|
|
# Check to see if the transaction was returned with an error. |
|
74
|
1 |
|
def error? |
|
75
|
|
|
@fields[:response_code] == ResponseCode::ERROR |
|
76
|
|
|
end |
|
77
|
|
|
|
|
78
|
|
|
# Check to see if the transaction was held for review by Authorize.Net. |
|
79
|
1 |
|
def held? |
|
80
|
|
|
@fields[:response_code] == ResponseCode::HELD |
|
81
|
|
|
end |
|
82
|
|
|
|
|
83
|
|
|
# Returns the response code received from the gateway. Note: its better to use |
|
84
|
|
|
# success?, approved?, etc. to check the response code. |
|
85
|
1 |
|
def response_code |
|
86
|
|
|
@fields[:response_code] |
|
87
|
|
|
end |
|
88
|
|
|
|
|
89
|
|
|
# Returns the response reason code received from the gateway. This code can be used |
|
90
|
|
|
# to identify why something failed by referencing the AIM documentation. |
|
91
|
1 |
|
def response_reason_code |
|
92
|
|
|
@fields[:response_reason_code] |
|
93
|
|
|
end |
|
94
|
|
|
|
|
95
|
|
|
# Returns the response reason text received from the gateway. This is a brief, human readable |
|
96
|
|
|
# explanation of why you got the response code that you got. Note that these strings tend to be |
|
97
|
|
|
# a bit vague. More detail can be gleaned from the response_reason_code. |
|
98
|
1 |
|
def response_reason_text |
|
99
|
|
|
@fields[:response_reason_text] |
|
100
|
|
|
end |
|
101
|
|
|
|
|
102
|
|
|
# Returns all the fields returned in the response, keyed by their API name. Custom fields are NOT |
|
103
|
|
|
# included (see custom_fields). |
|
104
|
1 |
|
attr_reader :fields |
|
105
|
|
|
|
|
106
|
|
|
# Returns all the custom fields returned in the response, keyed by their field name. |
|
107
|
1 |
|
attr_reader :custom_fields |
|
108
|
|
|
end |
|
109
|
|
|
end |
|
110
|
|
|
|