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
@@ -1,312 +1,312 @@
|
|
1
|
-
require 'hps'
|
2
|
-
|
3
|
-
|
4
|
-
describe "ExceptionMapper Tests" do
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
@mapper = Hps::ExceptionMapper.new
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
it "mapping version number accessible" do
|
12
|
-
expect(@mapper.version_number).to eq("1.0.1")
|
13
|
-
end
|
14
|
-
|
15
|
-
# Issuer Exceptions
|
16
|
-
|
17
|
-
it "issuer card declined test codes" do
|
18
|
-
|
19
|
-
[ "02", "03", "04", "05", "41", "43", "44", "51", "56", "61", "62", "63", "65", "78" ].each { |code|
|
20
|
-
|
21
|
-
result = @mapper.map_issuer_exception(1, code, "")
|
22
|
-
expect(result.transaction_id).to eq(1)
|
23
|
-
expect(result.code).to eq("card_declined")
|
24
|
-
expect(result.message).to eq(message_for_code("Exception_Message_CardDeclined"))
|
25
|
-
}
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
it "issuer processing error test codes" do
|
30
|
-
|
31
|
-
[ "06", "07", "12", "15", "19", "12", "52", "53", "57", "58", "76", "77", "91", "96", "EC" ].each { |code|
|
32
|
-
|
33
|
-
result = @mapper.map_issuer_exception(2, code, "")
|
34
|
-
expect(result.transaction_id).to eq(2)
|
35
|
-
expect(result.code).to eq("processing_error")
|
36
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
37
|
-
}
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
it "issuer invalid amount test" do
|
42
|
-
result = @mapper.map_issuer_exception(3, "13", "")
|
43
|
-
expect(result.transaction_id).to eq(3)
|
44
|
-
expect(result.code).to eq("invalid_amount")
|
45
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
46
|
-
end
|
47
|
-
|
48
|
-
it "issuer incorrect number test" do
|
49
|
-
result = @mapper.map_issuer_exception(4, "14", "")
|
50
|
-
expect(result.transaction_id).to eq(4)
|
51
|
-
expect(result.code).to eq("incorrect_number")
|
52
|
-
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectNumber"))
|
53
|
-
end
|
54
|
-
|
55
|
-
it "issuer expired card test" do
|
56
|
-
result = @mapper.map_issuer_exception(5, "54", "")
|
57
|
-
expect(result.transaction_id).to eq(5)
|
58
|
-
expect(result.code).to eq("expired_card")
|
59
|
-
expect(result.message).to eq(message_for_code("Exception_Message_CardExpired"))
|
60
|
-
end
|
61
|
-
|
62
|
-
it "issuer invalid pin test" do
|
63
|
-
result = @mapper.map_issuer_exception(6, "55", "")
|
64
|
-
expect(result.transaction_id).to eq(6)
|
65
|
-
expect(result.code).to eq("invalid_pin")
|
66
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidPin"))
|
67
|
-
end
|
68
|
-
|
69
|
-
it "issuer pin retries exceeded test" do
|
70
|
-
result = @mapper.map_issuer_exception(7, "75", "")
|
71
|
-
expect(result.transaction_id).to eq(7)
|
72
|
-
expect(result.code).to eq("pin_retries_exceeded")
|
73
|
-
expect(result.message).to eq(message_for_code("Exception_Message_PinExceeded"))
|
74
|
-
end
|
75
|
-
|
76
|
-
it "issuer invalid expiry test" do
|
77
|
-
result = @mapper.map_issuer_exception(8, "80", "")
|
78
|
-
expect(result.transaction_id).to eq(8)
|
79
|
-
expect(result.code).to eq("invalid_expiry")
|
80
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidExpiry"))
|
81
|
-
end
|
82
|
-
|
83
|
-
it "issuer pin verification test" do
|
84
|
-
result = @mapper.map_issuer_exception(9, "86", "")
|
85
|
-
expect(result.transaction_id).to eq(9)
|
86
|
-
expect(result.code).to eq("pin_verification")
|
87
|
-
expect(result.message).to eq(message_for_code("Exception_Message_PinVerification"))
|
88
|
-
end
|
89
|
-
|
90
|
-
it "issuer incorrect cvc test" do
|
91
|
-
[ "EB", "N7" ].each { |code|
|
92
|
-
result = @mapper.map_issuer_exception(10, code, "")
|
93
|
-
expect(result.transaction_id).to eq(10)
|
94
|
-
expect(result.code).to eq("incorrect_cvc")
|
95
|
-
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectCvc"))
|
96
|
-
}
|
97
|
-
end
|
98
|
-
|
99
|
-
it "issuer unknown test" do
|
100
|
-
result = @mapper.map_issuer_exception(11, "Foo", "Foo")
|
101
|
-
expect(result.transaction_id).to eq(11)
|
102
|
-
expect(result.code).to eq("unknown_card_exception")
|
103
|
-
expect(result.message).to eq("Foo")
|
104
|
-
end
|
105
|
-
|
106
|
-
it "issuer nil test" do
|
107
|
-
result = @mapper.map_issuer_exception(0, nil, nil)
|
108
|
-
expect(result.transaction_id).to eq(0)
|
109
|
-
expect(result.code).to eq("unknown_card_exception")
|
110
|
-
expect(result.message).to eq("Hps::CardException")
|
111
|
-
end
|
112
|
-
|
113
|
-
# Gateway exceptions
|
114
|
-
|
115
|
-
it "gateway authentication exception test" do
|
116
|
-
result = @mapper.map_gateway_exception(0, "-2", nil)
|
117
|
-
expect(result.code).to eq("unknown")
|
118
|
-
expect(result.message).to eq(message_for_code("Exception_Message_AuthenticationError"))
|
119
|
-
end
|
120
|
-
|
121
|
-
it "gateway invalid request exception cpc test" do
|
122
|
-
result = @mapper.map_gateway_exception(0, "12", nil)
|
123
|
-
expect(result.param).to eq("card")
|
124
|
-
expect(result.code).to eq("invalid_cpc_data")
|
125
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCpcData"))
|
126
|
-
end
|
127
|
-
|
128
|
-
it "gateway invalid request exception card data test" do
|
129
|
-
result = @mapper.map_gateway_exception(0, "13", nil)
|
130
|
-
expect(result.param).to eq("card")
|
131
|
-
expect(result.code).to eq("invalid_card_data")
|
132
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCardData"))
|
133
|
-
end
|
134
|
-
|
135
|
-
it "gateway card exception test" do
|
136
|
-
result = @mapper.map_gateway_exception(0, "14", nil)
|
137
|
-
expect(result.code).to eq("invalid_number")
|
138
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidNumber"))
|
139
|
-
end
|
140
|
-
|
141
|
-
it "gateway message passthrough test" do
|
142
|
-
result = @mapper.map_gateway_exception(0, "1", "Foo")
|
143
|
-
expect(result.code).to eq("unknown")
|
144
|
-
expect(result.message).to eq("Foo")
|
145
|
-
end
|
146
|
-
|
147
|
-
it "gateway invalid original transaction test" do
|
148
|
-
result = @mapper.map_gateway_exception(0, "3", "Foo")
|
149
|
-
expect(result.code).to eq("invalid_original_transaction")
|
150
|
-
expect(result.message).to eq("Foo")
|
151
|
-
end
|
152
|
-
|
153
|
-
it "gateway no open batch test" do
|
154
|
-
result = @mapper.map_gateway_exception(0, "5", "Foo")
|
155
|
-
expect(result.code).to eq("no_open_batch")
|
156
|
-
expect(result.message).to eq("Foo")
|
157
|
-
end
|
158
|
-
|
159
|
-
it "gateway timeout test" do
|
160
|
-
result = @mapper.map_gateway_exception(0, "30", nil)
|
161
|
-
expect(result.code).to eq("unknown")
|
162
|
-
expect(result.message).to eq(message_for_code("Exception_Message_GatewayTimedOut"))
|
163
|
-
end
|
164
|
-
|
165
|
-
it "gateway unknown test" do
|
166
|
-
result = @mapper.map_gateway_exception(0, "Foo", "Foo")
|
167
|
-
expect(result.code).to eq("unknown")
|
168
|
-
expect(result.message).to eq("Foo")
|
169
|
-
end
|
170
|
-
|
171
|
-
# Sdk Exceptions
|
172
|
-
|
173
|
-
it "sdk invalid transaction id test" do
|
174
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_transaction_id, nil)
|
175
|
-
expect(result.param).to eq("gatewayTransactionId")
|
176
|
-
expect(result.code).to eq("invalid_transaction_id")
|
177
|
-
expect(result.message).to eq(message_for_code("Exception_Message_TransactionIdLessThanEqualZero"))
|
178
|
-
end
|
179
|
-
|
180
|
-
it "sdk invalid gateway url test" do
|
181
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
182
|
-
expect(result.param).to eq("HpsServiceUri")
|
183
|
-
expect(result.code).to eq("sdk_exception")
|
184
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
185
|
-
end
|
186
|
-
|
187
|
-
it "sdk unable to process transaction test" do
|
188
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
189
|
-
expect(result.param).to eq("HpsServiceUri")
|
190
|
-
expect(result.code).to eq("sdk_exception")
|
191
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
192
|
-
end
|
193
|
-
|
194
|
-
it "sdk missing currency" do
|
195
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.missing_currency, nil)
|
196
|
-
expect(result.param).to eq("currency")
|
197
|
-
expect(result.code).to eq("missing_currency")
|
198
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ArgumentNull"))
|
199
|
-
end
|
200
|
-
|
201
|
-
it "sdk invalid currency" do
|
202
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_currency, nil)
|
203
|
-
expect(result.param).to eq("currency")
|
204
|
-
expect(result.code).to eq("invalid_currency")
|
205
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCurrency"))
|
206
|
-
end
|
207
|
-
|
208
|
-
it "sdk invalid amount" do
|
209
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_amount, nil)
|
210
|
-
expect(result.param).to eq("amount")
|
211
|
-
expect(result.code).to eq("invalid_amount")
|
212
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
213
|
-
end
|
214
|
-
|
215
|
-
it "sdk reversal error after gateway timeout" do
|
216
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_gateway_timeout, nil)
|
217
|
-
expect(result.code).to eq("gateway_timeout")
|
218
|
-
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterGatewayTimeout"))
|
219
|
-
end
|
220
|
-
|
221
|
-
it "sdk reversal error after issuer timeout" do
|
222
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_issuer_timeout, nil)
|
223
|
-
expect(result.code).to eq("issuer_timeout")
|
224
|
-
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterIssuerTimeout"))
|
225
|
-
end
|
226
|
-
|
227
|
-
it "sdk processing error" do
|
228
|
-
result = @mapper.map_sdk_exception(Hps::SdkCodes.processing_error, nil)
|
229
|
-
expect(result.code).to eq("processing_error")
|
230
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
231
|
-
end
|
232
|
-
|
233
|
-
# GiftCards
|
234
|
-
context "Gift card exception mapper" do
|
235
|
-
it "unknown gift card error" do
|
236
|
-
%w(1 2 11).each do |n|
|
237
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
238
|
-
expect( result.code ).to eql("unknown_card_exception")
|
239
|
-
expect( result.message ).to eql("Response Text")
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
it "invalid card data" do
|
244
|
-
%w(3 8).each do |n|
|
245
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
246
|
-
expect( result.code ).to eql("invalid_card_data")
|
247
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidCardData"))
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
it "expired card error" do
|
252
|
-
%w(4).each do |n|
|
253
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
254
|
-
expect( result.code ).to eql("expired_card")
|
255
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_CardExpired"))
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
it "declined card error" do
|
260
|
-
%w(5 12).each do |n|
|
261
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
262
|
-
expect( result.code ).to eql("card_declined")
|
263
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_CardDeclined"))
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
it "processing error" do
|
268
|
-
%w(6 7 10).each do |n|
|
269
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
270
|
-
expect( result.code ).to eql("processing_error")
|
271
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_ProcessingError"))
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
it "invalid amount error" do
|
276
|
-
%w(9).each do |n|
|
277
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
278
|
-
expect( result.code ).to eql("invalid_amount")
|
279
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_ChargeAmount"))
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
it "partial approval error" do
|
284
|
-
%w(13).each do |n|
|
285
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
286
|
-
expect( result.code ).to eql("partial_approval")
|
287
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_PartialApproval"))
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
it "invalid pin error" do
|
292
|
-
%w(14).each do |n|
|
293
|
-
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
294
|
-
expect( result.code ).to eql("invalid_pin")
|
295
|
-
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidPin"))
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
# Helper methods
|
301
|
-
|
302
|
-
def message_for_code(code)
|
303
|
-
|
304
|
-
mapping = @mapper.exceptions["exception_messages"].detect { |message|
|
305
|
-
message["code"] == code
|
306
|
-
}
|
307
|
-
|
308
|
-
mapping["message"] unless mapping.nil?
|
309
|
-
|
310
|
-
end
|
311
|
-
|
1
|
+
require 'hps'
|
2
|
+
|
3
|
+
|
4
|
+
describe "ExceptionMapper Tests" do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@mapper = Hps::ExceptionMapper.new
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
it "mapping version number accessible" do
|
12
|
+
expect(@mapper.version_number).to eq("1.0.1")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Issuer Exceptions
|
16
|
+
|
17
|
+
it "issuer card declined test codes" do
|
18
|
+
|
19
|
+
[ "02", "03", "04", "05", "41", "43", "44", "51", "56", "61", "62", "63", "65", "78" ].each { |code|
|
20
|
+
|
21
|
+
result = @mapper.map_issuer_exception(1, code, "")
|
22
|
+
expect(result.transaction_id).to eq(1)
|
23
|
+
expect(result.code).to eq("card_declined")
|
24
|
+
expect(result.message).to eq(message_for_code("Exception_Message_CardDeclined"))
|
25
|
+
}
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
it "issuer processing error test codes" do
|
30
|
+
|
31
|
+
[ "06", "07", "12", "15", "19", "12", "52", "53", "57", "58", "76", "77", "91", "96", "EC" ].each { |code|
|
32
|
+
|
33
|
+
result = @mapper.map_issuer_exception(2, code, "")
|
34
|
+
expect(result.transaction_id).to eq(2)
|
35
|
+
expect(result.code).to eq("processing_error")
|
36
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
37
|
+
}
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it "issuer invalid amount test" do
|
42
|
+
result = @mapper.map_issuer_exception(3, "13", "")
|
43
|
+
expect(result.transaction_id).to eq(3)
|
44
|
+
expect(result.code).to eq("invalid_amount")
|
45
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "issuer incorrect number test" do
|
49
|
+
result = @mapper.map_issuer_exception(4, "14", "")
|
50
|
+
expect(result.transaction_id).to eq(4)
|
51
|
+
expect(result.code).to eq("incorrect_number")
|
52
|
+
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectNumber"))
|
53
|
+
end
|
54
|
+
|
55
|
+
it "issuer expired card test" do
|
56
|
+
result = @mapper.map_issuer_exception(5, "54", "")
|
57
|
+
expect(result.transaction_id).to eq(5)
|
58
|
+
expect(result.code).to eq("expired_card")
|
59
|
+
expect(result.message).to eq(message_for_code("Exception_Message_CardExpired"))
|
60
|
+
end
|
61
|
+
|
62
|
+
it "issuer invalid pin test" do
|
63
|
+
result = @mapper.map_issuer_exception(6, "55", "")
|
64
|
+
expect(result.transaction_id).to eq(6)
|
65
|
+
expect(result.code).to eq("invalid_pin")
|
66
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidPin"))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "issuer pin retries exceeded test" do
|
70
|
+
result = @mapper.map_issuer_exception(7, "75", "")
|
71
|
+
expect(result.transaction_id).to eq(7)
|
72
|
+
expect(result.code).to eq("pin_retries_exceeded")
|
73
|
+
expect(result.message).to eq(message_for_code("Exception_Message_PinExceeded"))
|
74
|
+
end
|
75
|
+
|
76
|
+
it "issuer invalid expiry test" do
|
77
|
+
result = @mapper.map_issuer_exception(8, "80", "")
|
78
|
+
expect(result.transaction_id).to eq(8)
|
79
|
+
expect(result.code).to eq("invalid_expiry")
|
80
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidExpiry"))
|
81
|
+
end
|
82
|
+
|
83
|
+
it "issuer pin verification test" do
|
84
|
+
result = @mapper.map_issuer_exception(9, "86", "")
|
85
|
+
expect(result.transaction_id).to eq(9)
|
86
|
+
expect(result.code).to eq("pin_verification")
|
87
|
+
expect(result.message).to eq(message_for_code("Exception_Message_PinVerification"))
|
88
|
+
end
|
89
|
+
|
90
|
+
it "issuer incorrect cvc test" do
|
91
|
+
[ "EB", "N7" ].each { |code|
|
92
|
+
result = @mapper.map_issuer_exception(10, code, "")
|
93
|
+
expect(result.transaction_id).to eq(10)
|
94
|
+
expect(result.code).to eq("incorrect_cvc")
|
95
|
+
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectCvc"))
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
it "issuer unknown test" do
|
100
|
+
result = @mapper.map_issuer_exception(11, "Foo", "Foo")
|
101
|
+
expect(result.transaction_id).to eq(11)
|
102
|
+
expect(result.code).to eq("unknown_card_exception")
|
103
|
+
expect(result.message).to eq("Foo")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "issuer nil test" do
|
107
|
+
result = @mapper.map_issuer_exception(0, nil, nil)
|
108
|
+
expect(result.transaction_id).to eq(0)
|
109
|
+
expect(result.code).to eq("unknown_card_exception")
|
110
|
+
expect(result.message).to eq("Hps::CardException")
|
111
|
+
end
|
112
|
+
|
113
|
+
# Gateway exceptions
|
114
|
+
|
115
|
+
it "gateway authentication exception test" do
|
116
|
+
result = @mapper.map_gateway_exception(0, "-2", nil)
|
117
|
+
expect(result.code).to eq("unknown")
|
118
|
+
expect(result.message).to eq(message_for_code("Exception_Message_AuthenticationError"))
|
119
|
+
end
|
120
|
+
|
121
|
+
it "gateway invalid request exception cpc test" do
|
122
|
+
result = @mapper.map_gateway_exception(0, "12", nil)
|
123
|
+
expect(result.param).to eq("card")
|
124
|
+
expect(result.code).to eq("invalid_cpc_data")
|
125
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCpcData"))
|
126
|
+
end
|
127
|
+
|
128
|
+
it "gateway invalid request exception card data test" do
|
129
|
+
result = @mapper.map_gateway_exception(0, "13", nil)
|
130
|
+
expect(result.param).to eq("card")
|
131
|
+
expect(result.code).to eq("invalid_card_data")
|
132
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCardData"))
|
133
|
+
end
|
134
|
+
|
135
|
+
it "gateway card exception test" do
|
136
|
+
result = @mapper.map_gateway_exception(0, "14", nil)
|
137
|
+
expect(result.code).to eq("invalid_number")
|
138
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidNumber"))
|
139
|
+
end
|
140
|
+
|
141
|
+
it "gateway message passthrough test" do
|
142
|
+
result = @mapper.map_gateway_exception(0, "1", "Foo")
|
143
|
+
expect(result.code).to eq("unknown")
|
144
|
+
expect(result.message).to eq("Foo")
|
145
|
+
end
|
146
|
+
|
147
|
+
it "gateway invalid original transaction test" do
|
148
|
+
result = @mapper.map_gateway_exception(0, "3", "Foo")
|
149
|
+
expect(result.code).to eq("invalid_original_transaction")
|
150
|
+
expect(result.message).to eq("Foo")
|
151
|
+
end
|
152
|
+
|
153
|
+
it "gateway no open batch test" do
|
154
|
+
result = @mapper.map_gateway_exception(0, "5", "Foo")
|
155
|
+
expect(result.code).to eq("no_open_batch")
|
156
|
+
expect(result.message).to eq("Foo")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "gateway timeout test" do
|
160
|
+
result = @mapper.map_gateway_exception(0, "30", nil)
|
161
|
+
expect(result.code).to eq("unknown")
|
162
|
+
expect(result.message).to eq(message_for_code("Exception_Message_GatewayTimedOut"))
|
163
|
+
end
|
164
|
+
|
165
|
+
it "gateway unknown test" do
|
166
|
+
result = @mapper.map_gateway_exception(0, "Foo", "Foo")
|
167
|
+
expect(result.code).to eq("unknown")
|
168
|
+
expect(result.message).to eq("Foo")
|
169
|
+
end
|
170
|
+
|
171
|
+
# Sdk Exceptions
|
172
|
+
|
173
|
+
it "sdk invalid transaction id test" do
|
174
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_transaction_id, nil)
|
175
|
+
expect(result.param).to eq("gatewayTransactionId")
|
176
|
+
expect(result.code).to eq("invalid_transaction_id")
|
177
|
+
expect(result.message).to eq(message_for_code("Exception_Message_TransactionIdLessThanEqualZero"))
|
178
|
+
end
|
179
|
+
|
180
|
+
it "sdk invalid gateway url test" do
|
181
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
182
|
+
expect(result.param).to eq("HpsServiceUri")
|
183
|
+
expect(result.code).to eq("sdk_exception")
|
184
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
185
|
+
end
|
186
|
+
|
187
|
+
it "sdk unable to process transaction test" do
|
188
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
189
|
+
expect(result.param).to eq("HpsServiceUri")
|
190
|
+
expect(result.code).to eq("sdk_exception")
|
191
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
192
|
+
end
|
193
|
+
|
194
|
+
it "sdk missing currency" do
|
195
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.missing_currency, nil)
|
196
|
+
expect(result.param).to eq("currency")
|
197
|
+
expect(result.code).to eq("missing_currency")
|
198
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ArgumentNull"))
|
199
|
+
end
|
200
|
+
|
201
|
+
it "sdk invalid currency" do
|
202
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_currency, nil)
|
203
|
+
expect(result.param).to eq("currency")
|
204
|
+
expect(result.code).to eq("invalid_currency")
|
205
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCurrency"))
|
206
|
+
end
|
207
|
+
|
208
|
+
it "sdk invalid amount" do
|
209
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_amount, nil)
|
210
|
+
expect(result.param).to eq("amount")
|
211
|
+
expect(result.code).to eq("invalid_amount")
|
212
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
213
|
+
end
|
214
|
+
|
215
|
+
it "sdk reversal error after gateway timeout" do
|
216
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_gateway_timeout, nil)
|
217
|
+
expect(result.code).to eq("gateway_timeout")
|
218
|
+
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterGatewayTimeout"))
|
219
|
+
end
|
220
|
+
|
221
|
+
it "sdk reversal error after issuer timeout" do
|
222
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_issuer_timeout, nil)
|
223
|
+
expect(result.code).to eq("issuer_timeout")
|
224
|
+
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterIssuerTimeout"))
|
225
|
+
end
|
226
|
+
|
227
|
+
it "sdk processing error" do
|
228
|
+
result = @mapper.map_sdk_exception(Hps::SdkCodes.processing_error, nil)
|
229
|
+
expect(result.code).to eq("processing_error")
|
230
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
231
|
+
end
|
232
|
+
|
233
|
+
# GiftCards
|
234
|
+
context "Gift card exception mapper" do
|
235
|
+
it "unknown gift card error" do
|
236
|
+
%w(1 2 11).each do |n|
|
237
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
238
|
+
expect( result.code ).to eql("unknown_card_exception")
|
239
|
+
expect( result.message ).to eql("Response Text")
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
it "invalid card data" do
|
244
|
+
%w(3 8).each do |n|
|
245
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
246
|
+
expect( result.code ).to eql("invalid_card_data")
|
247
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidCardData"))
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
it "expired card error" do
|
252
|
+
%w(4).each do |n|
|
253
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
254
|
+
expect( result.code ).to eql("expired_card")
|
255
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_CardExpired"))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it "declined card error" do
|
260
|
+
%w(5 12).each do |n|
|
261
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
262
|
+
expect( result.code ).to eql("card_declined")
|
263
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_CardDeclined"))
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
it "processing error" do
|
268
|
+
%w(6 7 10).each do |n|
|
269
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
270
|
+
expect( result.code ).to eql("processing_error")
|
271
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_ProcessingError"))
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
it "invalid amount error" do
|
276
|
+
%w(9).each do |n|
|
277
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
278
|
+
expect( result.code ).to eql("invalid_amount")
|
279
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_ChargeAmount"))
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "partial approval error" do
|
284
|
+
%w(13).each do |n|
|
285
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
286
|
+
expect( result.code ).to eql("partial_approval")
|
287
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_PartialApproval"))
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
it "invalid pin error" do
|
292
|
+
%w(14).each do |n|
|
293
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
294
|
+
expect( result.code ).to eql("invalid_pin")
|
295
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidPin"))
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
# Helper methods
|
301
|
+
|
302
|
+
def message_for_code(code)
|
303
|
+
|
304
|
+
mapping = @mapper.exceptions["exception_messages"].detect { |message|
|
305
|
+
message["code"] == code
|
306
|
+
}
|
307
|
+
|
308
|
+
mapping["message"] unless mapping.nil?
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
312
|
end
|