hps 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/LICENSE.txt +32 -32
- data/PRIVACY.txt +65 -65
- data/README.md +40 -40
- data/Rakefile +15 -15
- data/hps.gemspec +26 -26
- data/lib/hps/configuration.rb +16 -16
- data/lib/hps/entities/hps_account_verify.rb +8 -8
- data/lib/hps/entities/hps_address.rb +6 -6
- data/lib/hps/entities/hps_authorization.rb +12 -12
- data/lib/hps/entities/hps_batch.rb +6 -6
- data/lib/hps/entities/hps_cardholder.rb +10 -6
- data/lib/hps/entities/hps_charge.rb +8 -8
- data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
- data/lib/hps/entities/hps_credit_card.rb +32 -32
- data/lib/hps/entities/hps_refund.rb +8 -8
- data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
- data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
- data/lib/hps/entities/hps_reversal.rb +10 -10
- data/lib/hps/entities/hps_token_data.rb +10 -10
- data/lib/hps/entities/hps_transaction.rb +161 -161
- data/lib/hps/entities/hps_transaction_details.rb +6 -6
- data/lib/hps/entities/hps_transaction_header.rb +8 -8
- data/lib/hps/entities/hps_transaction_type.rb +16 -16
- data/lib/hps/entities/hps_void.rb +8 -8
- data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
- data/lib/hps/infrastructure/authentication_exception.rb +11 -11
- data/lib/hps/infrastructure/card_exception.rb +15 -15
- data/lib/hps/infrastructure/exceptions.json +468 -468
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +134 -134
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
- data/lib/hps/services/hps_batch_service.rb +29 -29
- data/lib/hps/services/hps_charge_service.rb +634 -634
- data/lib/hps/services/hps_service.rb +128 -128
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +45 -45
- data/tests/amex_tests.rb +230 -230
- data/tests/cert_tests.rb +80 -80
- data/tests/discover_tests.rb +324 -324
- data/tests/exception_mapper_tests.rb +244 -244
- data/tests/general_tests.rb +58 -58
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +325 -325
- data/tests/secret_key.rb +11 -11
- data/tests/test_data.rb +127 -127
- data/tests/test_helper.rb +108 -92
- data/tests/token_tests.rb +513 -513
- data/tests/visa_tests.rb +378 -378
- metadata +4 -6
- data/.DS_Store +0 -0
- data/.gitignore +0 -24
data/tests/amex_tests.rb
CHANGED
@@ -1,231 +1,231 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "test_helper" )
|
2
|
-
|
3
|
-
|
4
|
-
describe "Amex Tests" do
|
5
|
-
|
6
|
-
it "Amex when card is ok, should return valid result" do
|
7
|
-
charge = Hps::TestHelper.charge_valid_amex(50)
|
8
|
-
expect(charge.response_code).to eql("00")
|
9
|
-
end
|
10
|
-
|
11
|
-
# avs tests
|
12
|
-
|
13
|
-
it "Amex avs result code should equal A" do
|
14
|
-
charge = Hps::TestHelper.charge_valid_amex(90.01)
|
15
|
-
expect(charge.avs_result_code).to eql("A")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "Amex avs result code should equal N" do
|
19
|
-
charge = Hps::TestHelper.charge_valid_amex(90.02)
|
20
|
-
expect(charge.avs_result_code).to eql("N")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "Amex avs result code should equal R" do
|
24
|
-
charge = Hps::TestHelper.charge_valid_amex(90.03)
|
25
|
-
expect(charge.avs_result_code).to eql("R")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "Amex avs result code should equal S" do
|
29
|
-
charge = Hps::TestHelper.charge_valid_amex(90.04)
|
30
|
-
expect(charge.avs_result_code).to eql("S")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "Amex avs result code should equal U" do
|
34
|
-
charge = Hps::TestHelper.charge_valid_amex(90.05)
|
35
|
-
expect(charge.avs_result_code).to eql("U")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "Amex avs result code should equal W" do
|
39
|
-
charge = Hps::TestHelper.charge_valid_amex(90.06)
|
40
|
-
expect(charge.avs_result_code).to eql("W")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "Amex avs result code should equal X" do
|
44
|
-
charge = Hps::TestHelper.charge_valid_amex(90.07)
|
45
|
-
expect(charge.avs_result_code).to eql("X")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "Amex avs result code should equal Y" do
|
49
|
-
charge = Hps::TestHelper.charge_valid_amex(90.08)
|
50
|
-
expect(charge.avs_result_code).to eql("Y")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "Amex avs result code should equal Z" do
|
54
|
-
charge = Hps::TestHelper.charge_valid_amex(90.09)
|
55
|
-
expect(charge.avs_result_code).to eql("Z")
|
56
|
-
end
|
57
|
-
|
58
|
-
# cvv tests
|
59
|
-
|
60
|
-
# TODO: Gateway code changed, returning Y
|
61
|
-
it "Amex cvv result code should equal M" do
|
62
|
-
charge = Hps::TestHelper.charge_valid_amex(97.01)
|
63
|
-
#expect(charge.cvv_result_code).to eql("M")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "Amex cvv result code should equal N" do
|
67
|
-
charge = Hps::TestHelper.charge_valid_amex(97.02)
|
68
|
-
expect(charge.cvv_result_code).to eql("N")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "Amex cvv result code should equal P" do
|
72
|
-
charge = Hps::TestHelper.charge_valid_amex(97.03)
|
73
|
-
expect(charge.cvv_result_code).to eql("P")
|
74
|
-
end
|
75
|
-
|
76
|
-
# amex to visa 2nd
|
77
|
-
it "Amex response code should indicate denied" do
|
78
|
-
expect {
|
79
|
-
Hps::TestHelper.charge_valid_amex(10.08)
|
80
|
-
}.to raise_error(Hps::CardException) { |error|
|
81
|
-
expect(error.code).to eql("card_declined")
|
82
|
-
expect(error.response_code).to eql("51")
|
83
|
-
expect(error.response_text).to eql("DECLINE")
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
it "Amex response code should card expired" do
|
88
|
-
expect {
|
89
|
-
Hps::TestHelper.charge_valid_amex(10.32)
|
90
|
-
}.to raise_error(Hps::CardException) { |error|
|
91
|
-
expect(error.code).to eql("expired_card")
|
92
|
-
expect(error.response_code).to eql("54")
|
93
|
-
expect(error.response_text).to eql("EXPIRED CARD")
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
it "Amex response code should indicate please call" do
|
98
|
-
expect {
|
99
|
-
Hps::TestHelper.charge_valid_amex(10.34)
|
100
|
-
}.to raise_error(Hps::CardException) { |error|
|
101
|
-
expect(error.code).to eql("card_declined")
|
102
|
-
expect(error.response_code).to eql("02")
|
103
|
-
expect(error.response_text).to eql("CALL")
|
104
|
-
}
|
105
|
-
end
|
106
|
-
|
107
|
-
it "Amex response code should indicate invalid merchant" do
|
108
|
-
expect {
|
109
|
-
Hps::TestHelper.charge_valid_amex(10.22)
|
110
|
-
}.to raise_error(Hps::CardException) { |error|
|
111
|
-
expect(error.code).to eql("card_declined")
|
112
|
-
expect(error.response_code).to eql("03")
|
113
|
-
expect(error.response_text).to eql("TERM ID ERROR")
|
114
|
-
}
|
115
|
-
end
|
116
|
-
|
117
|
-
it "Amex response code should indicate invalid amount" do
|
118
|
-
expect {
|
119
|
-
Hps::TestHelper.charge_valid_amex(10.27)
|
120
|
-
}.to raise_error(Hps::CardException) { |error|
|
121
|
-
expect(error.code).to eql("invalid_amount")
|
122
|
-
expect(error.response_code).to eql("13")
|
123
|
-
expect(error.response_text).to eql("AMOUNT ERROR")
|
124
|
-
}
|
125
|
-
end
|
126
|
-
|
127
|
-
it "Amex response code should indicate no action taken" do
|
128
|
-
expect {
|
129
|
-
Hps::TestHelper.charge_valid_amex(10.14)
|
130
|
-
}.to raise_error(Hps::CardException) { |error|
|
131
|
-
# TODO: Gateway response changed
|
132
|
-
# expect(error.code).to eql("processing_error")
|
133
|
-
# expect(error.response_code).to eql("76")
|
134
|
-
# expect(error.response_text).to eql("NO ACTION TAKEN")
|
135
|
-
expect(error.code).to eql("incorrect_number")
|
136
|
-
expect(error.response_code).to eql("14")
|
137
|
-
expect(error.response_text).to eql("CARD NO. ERROR")
|
138
|
-
}
|
139
|
-
end
|
140
|
-
|
141
|
-
it "Amex response code should indicate invalid cvv2" do
|
142
|
-
expect {
|
143
|
-
Hps::TestHelper.charge_valid_amex(10.23)
|
144
|
-
}.to raise_error(Hps::CardException) { |error|
|
145
|
-
expect(error.code).to eql("incorrect_cvc")
|
146
|
-
expect(error.response_code).to eql("N7")
|
147
|
-
expect(error.response_text).to eql("CVV2 MISMATCH")
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
|
-
it "Amex response code should indicate invalid originator" do
|
152
|
-
expect {
|
153
|
-
Hps::TestHelper.charge_valid_amex(10.30)
|
154
|
-
}.to raise_error(Hps::CardException) { |error|
|
155
|
-
expect(error.code).to eql("processing_error")
|
156
|
-
expect(error.response_code).to eql("58")
|
157
|
-
expect(error.response_text).to eql("SERV NOT ALLOWED")
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
|
-
it "Amex response code should indicate card declined" do
|
162
|
-
expect {
|
163
|
-
Hps::TestHelper.charge_valid_amex(10.25)
|
164
|
-
}.to raise_error(Hps::CardException) { |error|
|
165
|
-
expect(error.code).to eql("card_declined")
|
166
|
-
expect(error.response_code).to eql("05")
|
167
|
-
expect(error.response_text).to eql("DECLINE")
|
168
|
-
}
|
169
|
-
end
|
170
|
-
|
171
|
-
it "Amex response code should indicate account canceled" do
|
172
|
-
expect {
|
173
|
-
Hps::TestHelper.charge_valid_amex(10.13)
|
174
|
-
}.to raise_error(Hps::CardException) { |error|
|
175
|
-
expect(error.code).to eql("card_declined")
|
176
|
-
expect(error.response_code).to eql("78")
|
177
|
-
expect(error.response_text).to eql("NO ACCOUNT")
|
178
|
-
}
|
179
|
-
end
|
180
|
-
|
181
|
-
it "Amex response code should indicate merchant close" do
|
182
|
-
expect {
|
183
|
-
Hps::TestHelper.charge_valid_amex(10.12)
|
184
|
-
}.to raise_error(Hps::CardException) { |error|
|
185
|
-
expect(error.code).to eql("processing_error")
|
186
|
-
expect(error.response_code).to eql("06")
|
187
|
-
expect(error.response_text).to eql("ERROR")
|
188
|
-
}
|
189
|
-
end
|
190
|
-
|
191
|
-
it "Amex response code should indicate pickup card" do
|
192
|
-
expect {
|
193
|
-
Hps::TestHelper.charge_valid_amex(10.04)
|
194
|
-
}.to raise_error(Hps::CardException) { |error|
|
195
|
-
expect(error.code).to eql("card_declined")
|
196
|
-
expect(error.response_code).to eql("44")
|
197
|
-
expect(error.response_text).to eql("HOLD-CALL")
|
198
|
-
}
|
199
|
-
end
|
200
|
-
|
201
|
-
# verify, authorize & capture
|
202
|
-
|
203
|
-
it "Amex verify should return OK" do
|
204
|
-
service = Hps::HpsChargeService.new()
|
205
|
-
result = service.verify(Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
206
|
-
expect(result.response_code).to eql("00")
|
207
|
-
end
|
208
|
-
|
209
|
-
it "Amex authorize should return OK" do
|
210
|
-
service = Hps::HpsChargeService.new()
|
211
|
-
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
212
|
-
expect(result.response_code).to eql("00")
|
213
|
-
end
|
214
|
-
|
215
|
-
it "Amex authorize and request token should return OK" do
|
216
|
-
service = Hps::HpsChargeService.new()
|
217
|
-
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, true)
|
218
|
-
expect(result.token_data.response_code).to eql("0")
|
219
|
-
expect(result.response_code).to eql("00")
|
220
|
-
end
|
221
|
-
|
222
|
-
it "Amex authorize and capture should return OK" do
|
223
|
-
service = Hps::HpsChargeService.new()
|
224
|
-
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
225
|
-
expect(result.response_code).to eql("00")
|
226
|
-
|
227
|
-
capture_result = service.capture(result.transaction_id)
|
228
|
-
expect(capture_result.response_code).to eql("00")
|
229
|
-
end
|
230
|
-
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper" )
|
2
|
+
|
3
|
+
|
4
|
+
describe "Amex Tests" do
|
5
|
+
|
6
|
+
it "Amex when card is ok, should return valid result" do
|
7
|
+
charge = Hps::TestHelper.charge_valid_amex(50)
|
8
|
+
expect(charge.response_code).to eql("00")
|
9
|
+
end
|
10
|
+
|
11
|
+
# avs tests
|
12
|
+
|
13
|
+
it "Amex avs result code should equal A" do
|
14
|
+
charge = Hps::TestHelper.charge_valid_amex(90.01)
|
15
|
+
expect(charge.avs_result_code).to eql("A")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "Amex avs result code should equal N" do
|
19
|
+
charge = Hps::TestHelper.charge_valid_amex(90.02)
|
20
|
+
expect(charge.avs_result_code).to eql("N")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Amex avs result code should equal R" do
|
24
|
+
charge = Hps::TestHelper.charge_valid_amex(90.03)
|
25
|
+
expect(charge.avs_result_code).to eql("R")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Amex avs result code should equal S" do
|
29
|
+
charge = Hps::TestHelper.charge_valid_amex(90.04)
|
30
|
+
expect(charge.avs_result_code).to eql("S")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "Amex avs result code should equal U" do
|
34
|
+
charge = Hps::TestHelper.charge_valid_amex(90.05)
|
35
|
+
expect(charge.avs_result_code).to eql("U")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "Amex avs result code should equal W" do
|
39
|
+
charge = Hps::TestHelper.charge_valid_amex(90.06)
|
40
|
+
expect(charge.avs_result_code).to eql("W")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "Amex avs result code should equal X" do
|
44
|
+
charge = Hps::TestHelper.charge_valid_amex(90.07)
|
45
|
+
expect(charge.avs_result_code).to eql("X")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "Amex avs result code should equal Y" do
|
49
|
+
charge = Hps::TestHelper.charge_valid_amex(90.08)
|
50
|
+
expect(charge.avs_result_code).to eql("Y")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "Amex avs result code should equal Z" do
|
54
|
+
charge = Hps::TestHelper.charge_valid_amex(90.09)
|
55
|
+
expect(charge.avs_result_code).to eql("Z")
|
56
|
+
end
|
57
|
+
|
58
|
+
# cvv tests
|
59
|
+
|
60
|
+
# TODO: Gateway code changed, returning Y
|
61
|
+
it "Amex cvv result code should equal M" do
|
62
|
+
charge = Hps::TestHelper.charge_valid_amex(97.01)
|
63
|
+
#expect(charge.cvv_result_code).to eql("M")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "Amex cvv result code should equal N" do
|
67
|
+
charge = Hps::TestHelper.charge_valid_amex(97.02)
|
68
|
+
expect(charge.cvv_result_code).to eql("N")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "Amex cvv result code should equal P" do
|
72
|
+
charge = Hps::TestHelper.charge_valid_amex(97.03)
|
73
|
+
expect(charge.cvv_result_code).to eql("P")
|
74
|
+
end
|
75
|
+
|
76
|
+
# amex to visa 2nd
|
77
|
+
it "Amex response code should indicate denied" do
|
78
|
+
expect {
|
79
|
+
Hps::TestHelper.charge_valid_amex(10.08)
|
80
|
+
}.to raise_error(Hps::CardException) { |error|
|
81
|
+
expect(error.code).to eql("card_declined")
|
82
|
+
expect(error.response_code).to eql("51")
|
83
|
+
expect(error.response_text).to eql("DECLINE")
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
it "Amex response code should card expired" do
|
88
|
+
expect {
|
89
|
+
Hps::TestHelper.charge_valid_amex(10.32)
|
90
|
+
}.to raise_error(Hps::CardException) { |error|
|
91
|
+
expect(error.code).to eql("expired_card")
|
92
|
+
expect(error.response_code).to eql("54")
|
93
|
+
expect(error.response_text).to eql("EXPIRED CARD")
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
it "Amex response code should indicate please call" do
|
98
|
+
expect {
|
99
|
+
Hps::TestHelper.charge_valid_amex(10.34)
|
100
|
+
}.to raise_error(Hps::CardException) { |error|
|
101
|
+
expect(error.code).to eql("card_declined")
|
102
|
+
expect(error.response_code).to eql("02")
|
103
|
+
expect(error.response_text).to eql("CALL")
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
it "Amex response code should indicate invalid merchant" do
|
108
|
+
expect {
|
109
|
+
Hps::TestHelper.charge_valid_amex(10.22)
|
110
|
+
}.to raise_error(Hps::CardException) { |error|
|
111
|
+
expect(error.code).to eql("card_declined")
|
112
|
+
expect(error.response_code).to eql("03")
|
113
|
+
expect(error.response_text).to eql("TERM ID ERROR")
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
it "Amex response code should indicate invalid amount" do
|
118
|
+
expect {
|
119
|
+
Hps::TestHelper.charge_valid_amex(10.27)
|
120
|
+
}.to raise_error(Hps::CardException) { |error|
|
121
|
+
expect(error.code).to eql("invalid_amount")
|
122
|
+
expect(error.response_code).to eql("13")
|
123
|
+
expect(error.response_text).to eql("AMOUNT ERROR")
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
it "Amex response code should indicate no action taken" do
|
128
|
+
expect {
|
129
|
+
Hps::TestHelper.charge_valid_amex(10.14)
|
130
|
+
}.to raise_error(Hps::CardException) { |error|
|
131
|
+
# TODO: Gateway response changed
|
132
|
+
# expect(error.code).to eql("processing_error")
|
133
|
+
# expect(error.response_code).to eql("76")
|
134
|
+
# expect(error.response_text).to eql("NO ACTION TAKEN")
|
135
|
+
expect(error.code).to eql("incorrect_number")
|
136
|
+
expect(error.response_code).to eql("14")
|
137
|
+
expect(error.response_text).to eql("CARD NO. ERROR")
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
141
|
+
it "Amex response code should indicate invalid cvv2" do
|
142
|
+
expect {
|
143
|
+
Hps::TestHelper.charge_valid_amex(10.23)
|
144
|
+
}.to raise_error(Hps::CardException) { |error|
|
145
|
+
expect(error.code).to eql("incorrect_cvc")
|
146
|
+
expect(error.response_code).to eql("N7")
|
147
|
+
expect(error.response_text).to eql("CVV2 MISMATCH")
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
it "Amex response code should indicate invalid originator" do
|
152
|
+
expect {
|
153
|
+
Hps::TestHelper.charge_valid_amex(10.30)
|
154
|
+
}.to raise_error(Hps::CardException) { |error|
|
155
|
+
expect(error.code).to eql("processing_error")
|
156
|
+
expect(error.response_code).to eql("58")
|
157
|
+
expect(error.response_text).to eql("SERV NOT ALLOWED")
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
it "Amex response code should indicate card declined" do
|
162
|
+
expect {
|
163
|
+
Hps::TestHelper.charge_valid_amex(10.25)
|
164
|
+
}.to raise_error(Hps::CardException) { |error|
|
165
|
+
expect(error.code).to eql("card_declined")
|
166
|
+
expect(error.response_code).to eql("05")
|
167
|
+
expect(error.response_text).to eql("DECLINE")
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
it "Amex response code should indicate account canceled" do
|
172
|
+
expect {
|
173
|
+
Hps::TestHelper.charge_valid_amex(10.13)
|
174
|
+
}.to raise_error(Hps::CardException) { |error|
|
175
|
+
expect(error.code).to eql("card_declined")
|
176
|
+
expect(error.response_code).to eql("78")
|
177
|
+
expect(error.response_text).to eql("NO ACCOUNT")
|
178
|
+
}
|
179
|
+
end
|
180
|
+
|
181
|
+
it "Amex response code should indicate merchant close" do
|
182
|
+
expect {
|
183
|
+
Hps::TestHelper.charge_valid_amex(10.12)
|
184
|
+
}.to raise_error(Hps::CardException) { |error|
|
185
|
+
expect(error.code).to eql("processing_error")
|
186
|
+
expect(error.response_code).to eql("06")
|
187
|
+
expect(error.response_text).to eql("ERROR")
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
it "Amex response code should indicate pickup card" do
|
192
|
+
expect {
|
193
|
+
Hps::TestHelper.charge_valid_amex(10.04)
|
194
|
+
}.to raise_error(Hps::CardException) { |error|
|
195
|
+
expect(error.code).to eql("card_declined")
|
196
|
+
expect(error.response_code).to eql("44")
|
197
|
+
expect(error.response_text).to eql("HOLD-CALL")
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
# verify, authorize & capture
|
202
|
+
|
203
|
+
it "Amex verify should return OK" do
|
204
|
+
service = Hps::HpsChargeService.new()
|
205
|
+
result = service.verify(Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
206
|
+
expect(result.response_code).to eql("00")
|
207
|
+
end
|
208
|
+
|
209
|
+
it "Amex authorize should return OK" do
|
210
|
+
service = Hps::HpsChargeService.new()
|
211
|
+
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
212
|
+
expect(result.response_code).to eql("00")
|
213
|
+
end
|
214
|
+
|
215
|
+
it "Amex authorize and request token should return OK" do
|
216
|
+
service = Hps::HpsChargeService.new()
|
217
|
+
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, true)
|
218
|
+
expect(result.token_data.response_code).to eql("0")
|
219
|
+
expect(result.response_code).to eql("00")
|
220
|
+
end
|
221
|
+
|
222
|
+
it "Amex authorize and capture should return OK" do
|
223
|
+
service = Hps::HpsChargeService.new()
|
224
|
+
result = service.authorize(50.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder)
|
225
|
+
expect(result.response_code).to eql("00")
|
226
|
+
|
227
|
+
capture_result = service.capture(result.transaction_id)
|
228
|
+
expect(capture_result.response_code).to eql("00")
|
229
|
+
end
|
230
|
+
|
231
231
|
end
|
data/tests/cert_tests.rb
CHANGED
@@ -1,81 +1,81 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "test_helper" )
|
2
|
-
|
3
|
-
describe "Certification Tests" do
|
4
|
-
|
5
|
-
RSpec.configure do |config|
|
6
|
-
config.order_groups_and_examples do |tests|
|
7
|
-
tests.sort_by { |test| test.description }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
before(:each) do
|
12
|
-
Hps::TestHelper.configure_hps_module_for_certification()
|
13
|
-
@service = Hps::HpsChargeService.new()
|
14
|
-
end
|
15
|
-
|
16
|
-
it "A batch should close OK" do
|
17
|
-
begin
|
18
|
-
service = Hps::HpsBatchService.new
|
19
|
-
batch = service.close_batch
|
20
|
-
expect(batch).not_to be_nil
|
21
|
-
rescue => e
|
22
|
-
expect(e.code).to eql("no_open_batch")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "B visa should charge OK" do
|
27
|
-
result = @service.charge(17.01, "usd", Hps::TestData.valid_visa, Hps::TestData.cert_cardholder_shortzip)
|
28
|
-
expect(result.response_code).to eql("00")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "C mastercard should charge OK" do
|
32
|
-
result = @service.charge(17.02, "usd", Hps::TestData.valid_mastercard, Hps::TestData.cert_cardholder_shortzip_no_street)
|
33
|
-
expect(result.response_code).to eql("00")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "D discover should charge OK" do
|
37
|
-
result = @service.charge(17.03, "usd", Hps::TestData.valid_discover, Hps::TestData.cert_cardholder_longzip_no_street)
|
38
|
-
expect(result.response_code).to eql("00")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "E amex should charge OK" do
|
42
|
-
result = @service.charge(17.04, "usd", Hps::TestData.valid_amex, Hps::TestData.cert_cardholder_shortzip)
|
43
|
-
expect(result.response_code).to eql("00")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "F jcb should charge OK" do
|
47
|
-
result = @service.charge(17.05, "usd", Hps::TestData.valid_jcb, Hps::TestData.cert_cardholder_longzip)
|
48
|
-
expect(result.response_code).to eql("00")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "G visa should verify OK" do
|
52
|
-
result = @service.verify(Hps::TestData.valid_visa)
|
53
|
-
expect(result.response_code).to eql("85")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "H mastercard should verify OK" do
|
57
|
-
result = @service.verify(Hps::TestData.valid_mastercard)
|
58
|
-
expect(result.response_code).to eql("85")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "I discover should verify OK" do
|
62
|
-
result = @service.verify(Hps::TestData.valid_discover)
|
63
|
-
expect(result.response_code).to eql("85")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "J amex should avs should be OK" do
|
67
|
-
result = @service.verify(Hps::TestData.valid_amex, Hps::TestData.cert_cardholder_shortzip_no_street)
|
68
|
-
expect(result.response_code).to eql("00")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "K mastercard return should be OK" do
|
72
|
-
result = @service.refund(15.15, "usd", Hps::TestData.valid_mastercard, Hps::TestData.cert_cardholder_shortzip)
|
73
|
-
expect(result.response_code).to eql("00")
|
74
|
-
end
|
75
|
-
|
76
|
-
it "L visa should reverse OK" do
|
77
|
-
result = @service.reverse(Hps::TestData.valid_visa, 17.01, "usd")
|
78
|
-
expect(result.response_code).to eql("00")
|
79
|
-
end
|
80
|
-
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper" )
|
2
|
+
|
3
|
+
describe "Certification Tests" do
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.order_groups_and_examples do |tests|
|
7
|
+
tests.sort_by { |test| test.description }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
Hps::TestHelper.configure_hps_module_for_certification()
|
13
|
+
@service = Hps::HpsChargeService.new()
|
14
|
+
end
|
15
|
+
|
16
|
+
it "A batch should close OK" do
|
17
|
+
begin
|
18
|
+
service = Hps::HpsBatchService.new
|
19
|
+
batch = service.close_batch
|
20
|
+
expect(batch).not_to be_nil
|
21
|
+
rescue => e
|
22
|
+
expect(e.code).to eql("no_open_batch")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "B visa should charge OK" do
|
27
|
+
result = @service.charge(17.01, "usd", Hps::TestData.valid_visa, Hps::TestData.cert_cardholder_shortzip)
|
28
|
+
expect(result.response_code).to eql("00")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "C mastercard should charge OK" do
|
32
|
+
result = @service.charge(17.02, "usd", Hps::TestData.valid_mastercard, Hps::TestData.cert_cardholder_shortzip_no_street)
|
33
|
+
expect(result.response_code).to eql("00")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "D discover should charge OK" do
|
37
|
+
result = @service.charge(17.03, "usd", Hps::TestData.valid_discover, Hps::TestData.cert_cardholder_longzip_no_street)
|
38
|
+
expect(result.response_code).to eql("00")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "E amex should charge OK" do
|
42
|
+
result = @service.charge(17.04, "usd", Hps::TestData.valid_amex, Hps::TestData.cert_cardholder_shortzip)
|
43
|
+
expect(result.response_code).to eql("00")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "F jcb should charge OK" do
|
47
|
+
result = @service.charge(17.05, "usd", Hps::TestData.valid_jcb, Hps::TestData.cert_cardholder_longzip)
|
48
|
+
expect(result.response_code).to eql("00")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "G visa should verify OK" do
|
52
|
+
result = @service.verify(Hps::TestData.valid_visa)
|
53
|
+
expect(result.response_code).to eql("85")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "H mastercard should verify OK" do
|
57
|
+
result = @service.verify(Hps::TestData.valid_mastercard)
|
58
|
+
expect(result.response_code).to eql("85")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "I discover should verify OK" do
|
62
|
+
result = @service.verify(Hps::TestData.valid_discover)
|
63
|
+
expect(result.response_code).to eql("85")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "J amex should avs should be OK" do
|
67
|
+
result = @service.verify(Hps::TestData.valid_amex, Hps::TestData.cert_cardholder_shortzip_no_street)
|
68
|
+
expect(result.response_code).to eql("00")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "K mastercard return should be OK" do
|
72
|
+
result = @service.refund(15.15, "usd", Hps::TestData.valid_mastercard, Hps::TestData.cert_cardholder_shortzip)
|
73
|
+
expect(result.response_code).to eql("00")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "L visa should reverse OK" do
|
77
|
+
result = @service.reverse(Hps::TestData.valid_visa, 17.01, "usd")
|
78
|
+
expect(result.response_code).to eql("00")
|
79
|
+
end
|
80
|
+
|
81
81
|
end
|