hps 2.3.2 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +59 -0
- data/LICENSE.md +264 -264
- data/PRIVACY.txt +65 -65
- data/README.md +213 -213
- data/Rakefile +15 -15
- data/examples/sinatra-verify-only/Gemfile +4 -4
- data/examples/sinatra-verify-only/app.rb +32 -32
- data/examples/sinatra-verify-only/views/index.erb +478 -478
- data/examples/sinatra-verify-only/views/result.erb +39 -39
- data/hps.gemspec +28 -27
- data/lib/hps/configuration.rb +17 -17
- 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 +6 -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_check.rb +18 -18
- data/lib/hps/entities/hps_check_holder.rb +10 -10
- data/lib/hps/entities/hps_check_response.rb +45 -45
- data/lib/hps/entities/hps_check_response_details.rb +9 -9
- data/lib/hps/entities/hps_credit_card.rb +34 -34
- data/lib/hps/entities/hps_direct_market_data.rb +5 -5
- data/lib/hps/entities/hps_encryption_data.rb +6 -6
- data/lib/hps/entities/hps_gift_card.rb +133 -133
- data/lib/hps/entities/hps_manage_tokens.rb +8 -8
- 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_track_data.rb +5 -5
- 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 +547 -547
- data/lib/hps/infrastructure/hps_account_type.rb +11 -11
- data/lib/hps/infrastructure/hps_check_exception.rb +13 -13
- data/lib/hps/infrastructure/hps_check_type.rb +11 -11
- data/lib/hps/infrastructure/hps_data_entry_mode.rb +11 -11
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +145 -145
- data/lib/hps/infrastructure/hps_gateway_response_validation.rb +20 -20
- data/lib/hps/infrastructure/hps_input_validation.rb +13 -13
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- data/lib/hps/infrastructure/hps_sec_code.rb +27 -27
- data/lib/hps/infrastructure/hps_track_data_method.rb +6 -6
- 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 +773 -773
- data/lib/hps/services/hps_check_service.rb +110 -110
- data/lib/hps/services/hps_gift_card_service.rb +301 -301
- data/lib/hps/services/hps_service.rb +141 -136
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +63 -63
- data/tests/amex_tests.rb +292 -292
- data/tests/cert_tests.rb +80 -80
- data/tests/certification/card_present_spec.rb +320 -320
- data/tests/certification/gift_card_certification_test.rb +106 -106
- data/tests/certification/gift_card_certification_tests.rb +107 -107
- data/tests/check_tests.rb +50 -50
- data/tests/discover_tests.rb +386 -386
- data/tests/exception_mapper_tests.rb +311 -311
- data/tests/general_tests.rb +140 -140
- data/tests/giftcard_tests.rb +212 -212
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +387 -387
- data/tests/secret_key.rb +11 -11
- data/tests/test_check.rb +77 -77
- data/tests/test_data.rb +138 -138
- data/tests/test_helper.rb +179 -179
- data/tests/token_tests.rb +512 -512
- data/tests/visa_tests.rb +445 -445
- metadata +31 -11
data/tests/amex_tests.rb
CHANGED
@@ -1,292 +1,292 @@
|
|
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
|
-
it "Amex card present and reader not present" do
|
232
|
-
service = Hps::HpsChargeService.new()
|
233
|
-
card = Hps::TestData.valid_amex
|
234
|
-
card.card_present = true
|
235
|
-
result = service.charge(10.00, "usd", card, Hps::TestData.valid_cardholder)
|
236
|
-
expect(result.response_code).to eql("00")
|
237
|
-
end
|
238
|
-
|
239
|
-
it "Amex card present and reader present" do
|
240
|
-
service = Hps::HpsChargeService.new()
|
241
|
-
card = Hps::TestData.valid_amex
|
242
|
-
card.card_present = true
|
243
|
-
card.reader_present = true
|
244
|
-
result = service.charge(10.00, "usd", card, Hps::TestData.valid_cardholder)
|
245
|
-
expect(result.response_code).to eql("00")
|
246
|
-
end
|
247
|
-
|
248
|
-
it "Amex Dynamic Descriptor Authorize" do
|
249
|
-
service = Hps::HpsChargeService.new()
|
250
|
-
txn_descriptor = "Best Company Ever"
|
251
|
-
result = service.authorize(10.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, false, nil, txn_descriptor)
|
252
|
-
expect(result.response_code).to eql("00")
|
253
|
-
p result.transaction_id
|
254
|
-
end
|
255
|
-
|
256
|
-
it "Amex Dynamic Descriptor Charge" do
|
257
|
-
service = Hps::HpsChargeService.new()
|
258
|
-
txn_descriptor = "Best Company Ever"
|
259
|
-
result = service.charge(10.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, false, nil, txn_descriptor)
|
260
|
-
expect(result.response_code).to eql("00")
|
261
|
-
p result.transaction_id
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should charge with amex swipe and txn descriptor" do
|
265
|
-
Hps::TestHelper.valid_multi_use_config
|
266
|
-
service = Hps::HpsChargeService.new
|
267
|
-
txn_descriptor = "Best Company Ever"
|
268
|
-
track_data = Hps::HpsTrackData.new
|
269
|
-
track_data.value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'
|
270
|
-
track_data.method_obtained = Hps::HpsTrackDataMethod::SWIPE
|
271
|
-
|
272
|
-
charge = service.charge_swipe(10.00, "usd", track_data, nil, 0, false, txn_descriptor)
|
273
|
-
|
274
|
-
expect(charge).to_not be_nil
|
275
|
-
expect(charge.response_code).to eql("00")
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should authorize with amex swipe and txn descriptor" do
|
279
|
-
Hps::TestHelper.valid_multi_use_config
|
280
|
-
service = Hps::HpsChargeService.new
|
281
|
-
txn_descriptor = "Best Company Ever"
|
282
|
-
track_data = Hps::HpsTrackData.new
|
283
|
-
track_data.value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'
|
284
|
-
track_data.method_obtained = Hps::HpsTrackDataMethod::SWIPE
|
285
|
-
|
286
|
-
authorize = service.authorize_swipe(10.00, "usd", track_data, nil, 0, false, txn_descriptor)
|
287
|
-
|
288
|
-
expect(authorize).to_not be_nil
|
289
|
-
expect(authorize.response_code).to eql("00")
|
290
|
-
end
|
291
|
-
|
292
|
-
end
|
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
|
+
it "Amex card present and reader not present" do
|
232
|
+
service = Hps::HpsChargeService.new()
|
233
|
+
card = Hps::TestData.valid_amex
|
234
|
+
card.card_present = true
|
235
|
+
result = service.charge(10.00, "usd", card, Hps::TestData.valid_cardholder)
|
236
|
+
expect(result.response_code).to eql("00")
|
237
|
+
end
|
238
|
+
|
239
|
+
it "Amex card present and reader present" do
|
240
|
+
service = Hps::HpsChargeService.new()
|
241
|
+
card = Hps::TestData.valid_amex
|
242
|
+
card.card_present = true
|
243
|
+
card.reader_present = true
|
244
|
+
result = service.charge(10.00, "usd", card, Hps::TestData.valid_cardholder)
|
245
|
+
expect(result.response_code).to eql("00")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "Amex Dynamic Descriptor Authorize" do
|
249
|
+
service = Hps::HpsChargeService.new()
|
250
|
+
txn_descriptor = "Best Company Ever"
|
251
|
+
result = service.authorize(10.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, false, nil, txn_descriptor)
|
252
|
+
expect(result.response_code).to eql("00")
|
253
|
+
p result.transaction_id
|
254
|
+
end
|
255
|
+
|
256
|
+
it "Amex Dynamic Descriptor Charge" do
|
257
|
+
service = Hps::HpsChargeService.new()
|
258
|
+
txn_descriptor = "Best Company Ever"
|
259
|
+
result = service.charge(10.00, "usd", Hps::TestData.valid_amex, Hps::TestData.valid_cardholder, false, nil, txn_descriptor)
|
260
|
+
expect(result.response_code).to eql("00")
|
261
|
+
p result.transaction_id
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should charge with amex swipe and txn descriptor" do
|
265
|
+
Hps::TestHelper.valid_multi_use_config
|
266
|
+
service = Hps::HpsChargeService.new
|
267
|
+
txn_descriptor = "Best Company Ever"
|
268
|
+
track_data = Hps::HpsTrackData.new
|
269
|
+
track_data.value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'
|
270
|
+
track_data.method_obtained = Hps::HpsTrackDataMethod::SWIPE
|
271
|
+
|
272
|
+
charge = service.charge_swipe(10.00, "usd", track_data, nil, 0, false, txn_descriptor)
|
273
|
+
|
274
|
+
expect(charge).to_not be_nil
|
275
|
+
expect(charge.response_code).to eql("00")
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should authorize with amex swipe and txn descriptor" do
|
279
|
+
Hps::TestHelper.valid_multi_use_config
|
280
|
+
service = Hps::HpsChargeService.new
|
281
|
+
txn_descriptor = "Best Company Ever"
|
282
|
+
track_data = Hps::HpsTrackData.new
|
283
|
+
track_data.value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'
|
284
|
+
track_data.method_obtained = Hps::HpsTrackDataMethod::SWIPE
|
285
|
+
|
286
|
+
authorize = service.authorize_swipe(10.00, "usd", track_data, nil, 0, false, txn_descriptor)
|
287
|
+
|
288
|
+
expect(authorize).to_not be_nil
|
289
|
+
expect(authorize.response_code).to eql("00")
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|