hps 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/token_tests.rb
CHANGED
@@ -1,513 +1,513 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), 'test_helper' )
|
2
|
-
require File.join( File.dirname(__FILE__), 'hps_token_service')
|
3
|
-
require File.join( File.dirname(__FILE__), 'test_data' )
|
4
|
-
|
5
|
-
describe 'token_tests' do
|
6
|
-
|
7
|
-
let(:public_key) { Hps::TestHelper.valid_multi_use_public_key}
|
8
|
-
let(:token_service) { Hps::HpsTokenService.new(public_key) }
|
9
|
-
|
10
|
-
|
11
|
-
#Basic single token fetching tests
|
12
|
-
|
13
|
-
it 'Should return a one time use token' do
|
14
|
-
token_response = token_service.get_token(Hps::TestData.valid_visa)
|
15
|
-
token_response['token_value'].should_not eq(nil)
|
16
|
-
token_response['token_value'].should include('supt')
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'Should fail getting a token due to bad key' do
|
20
|
-
expect { Hps::HpsTokenService.new('bad_key') }.to raise_error('Public API Key must contain at least two underscores')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'Should fail getting an empty JSON response due to bad key' do
|
24
|
-
token_service = Hps::HpsTokenService.new('Still_bad_key')
|
25
|
-
expect { token_service.get_token(Hps::TestData.valid_visa) }.to raise_error('A JSON text must at least contain two octets!')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'Should fail and return an Error Card not Recognized' do
|
29
|
-
card = Hps::TestData.valid_visa
|
30
|
-
card.number = '11111111111111111'
|
31
|
-
token_response = token_service.get_token(card)
|
32
|
-
token_response['error']['message'].should eq('Card number is not a recognized brand.')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'Should fail and return Card Expiration Month invalid' do
|
36
|
-
card = Hps::TestData.valid_visa
|
37
|
-
card.exp_month = 13
|
38
|
-
token_response = token_service.get_token(card)
|
39
|
-
token_response['error']['message'].should eq('Card expiration month is invalid.')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'Should fail and return Card Expiration Year invalid' do
|
43
|
-
card = Hps::TestData.valid_visa
|
44
|
-
card.exp_year = 12
|
45
|
-
token_response = token_service.get_token(card)
|
46
|
-
token_response['error']['message'].should eq('Card expiration year is invalid.')
|
47
|
-
end
|
48
|
-
|
49
|
-
#Charge Testing with a token
|
50
|
-
|
51
|
-
it 'Should get a token from a Amex card and charge it with out error' do
|
52
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
53
|
-
charge = Hps::TestHelper.charge_token(token['token_value'])
|
54
|
-
|
55
|
-
charge.transaction_id.should_not eq(nil)
|
56
|
-
charge.response_code.should eq('00')
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'Should get a token from a Discover card and charge it with out error' do
|
60
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
61
|
-
charge = Hps::TestHelper.charge_token(token['token_value'])
|
62
|
-
|
63
|
-
charge.transaction_id.should_not eq(nil)
|
64
|
-
charge.response_code.should eq('00')
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'Should get a token from a Master card and charge it with out error' do
|
68
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
69
|
-
charge = Hps::TestHelper.charge_token(token['token_value'])
|
70
|
-
|
71
|
-
charge.transaction_id.should_not eq(nil)
|
72
|
-
charge.response_code.should eq('00')
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'Should get a token from a Visa card and charge it with out error' do
|
76
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
77
|
-
charge = Hps::TestHelper.charge_token(token['token_value'])
|
78
|
-
|
79
|
-
charge.transaction_id.should_not eq(nil)
|
80
|
-
charge.response_code.should eq('00')
|
81
|
-
end
|
82
|
-
|
83
|
-
# Charge Testing with a multi use token
|
84
|
-
|
85
|
-
it 'Should get a multi use token from a Amex card and charge it with out error' do
|
86
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
87
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
88
|
-
|
89
|
-
charge.transaction_id.should_not eq(nil)
|
90
|
-
charge.response_code.should eq('00')
|
91
|
-
charge.token_data.token_value.should_not eq(nil)
|
92
|
-
|
93
|
-
multi_token = charge.token_data.token_value
|
94
|
-
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
95
|
-
charge_multi_token.transaction_id.should_not eq(nil)
|
96
|
-
charge_multi_token.response_code.should eq('00')
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'Should get a multi use token from a Discover card and charge it with out error' do
|
100
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
101
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
102
|
-
|
103
|
-
charge.transaction_id.should_not eq(nil)
|
104
|
-
charge.response_code.should eq('00')
|
105
|
-
charge.token_data.token_value.should_not eq(nil)
|
106
|
-
|
107
|
-
multi_token = charge.token_data.token_value
|
108
|
-
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
109
|
-
charge_multi_token.transaction_id.should_not eq(nil)
|
110
|
-
charge_multi_token.response_code.should eq('00')
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'Should get a multi use token from a Master card and charge it with out error' do
|
114
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
115
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
116
|
-
|
117
|
-
charge.transaction_id.should_not eq(nil)
|
118
|
-
charge.response_code.should eq('00')
|
119
|
-
charge.token_data.token_value.should_not eq(nil)
|
120
|
-
|
121
|
-
multi_token = charge.token_data.token_value
|
122
|
-
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
123
|
-
charge_multi_token.transaction_id.should_not eq(nil)
|
124
|
-
charge_multi_token.response_code.should eq('00')
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'Should get a multi use token from a Visa card and charge it with out error' do
|
128
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
129
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
130
|
-
|
131
|
-
charge.transaction_id.should_not eq(nil)
|
132
|
-
charge.response_code.should eq('00')
|
133
|
-
charge.token_data.token_value.should_not eq(nil)
|
134
|
-
|
135
|
-
multi_token = charge.token_data.token_value
|
136
|
-
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
137
|
-
charge_multi_token.transaction_id.should_not eq(nil)
|
138
|
-
charge_multi_token.response_code.should eq('00')
|
139
|
-
end
|
140
|
-
|
141
|
-
## Auth Testing with a token
|
142
|
-
|
143
|
-
it 'Should get a token from a Amex card and auth it with out error' do
|
144
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
145
|
-
auth = Hps::TestHelper.auth_token(token['token_value'])
|
146
|
-
|
147
|
-
auth.transaction_id.should_not eq(nil)
|
148
|
-
auth.response_code.should eq('00')
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'Should get a token from a Discover card and auth it with out error' do
|
152
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
153
|
-
auth = Hps::TestHelper.auth_token(token['token_value'])
|
154
|
-
|
155
|
-
auth.transaction_id.should_not eq(nil)
|
156
|
-
auth.response_code.should eq('00')
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'Should get a token from a Master card and auth it with out error' do
|
160
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
161
|
-
auth = Hps::TestHelper.auth_token(token['token_value'])
|
162
|
-
|
163
|
-
auth.transaction_id.should_not eq(nil)
|
164
|
-
auth.response_code.should eq('00')
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'Should get a token from a Visa card and auth it with out error' do
|
168
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
169
|
-
auth = Hps::TestHelper.auth_token(token['token_value'])
|
170
|
-
|
171
|
-
auth.transaction_id.should_not eq(nil)
|
172
|
-
auth.response_code.should eq('00')
|
173
|
-
end
|
174
|
-
|
175
|
-
# Authorize Testing with a multi use token
|
176
|
-
|
177
|
-
it 'Should get a multi use token from a Amex card and auth it with out error' do
|
178
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
179
|
-
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
180
|
-
|
181
|
-
auth.transaction_id.should_not eq(nil)
|
182
|
-
auth.response_code.should eq('00')
|
183
|
-
auth.token_data.token_value.should_not eq(nil)
|
184
|
-
|
185
|
-
multi_token = auth.token_data.token_value
|
186
|
-
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
187
|
-
auth_multi_token.transaction_id.should_not eq(nil)
|
188
|
-
auth_multi_token.response_code.should eq('00')
|
189
|
-
end
|
190
|
-
|
191
|
-
it 'Should get a multi use token from a Discover card and auth it with out error' do
|
192
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
193
|
-
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
194
|
-
|
195
|
-
auth.transaction_id.should_not eq(nil)
|
196
|
-
auth.response_code.should eq('00')
|
197
|
-
auth.token_data.token_value.should_not eq(nil)
|
198
|
-
|
199
|
-
multi_token = auth.token_data.token_value
|
200
|
-
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
201
|
-
auth_multi_token.transaction_id.should_not eq(nil)
|
202
|
-
auth_multi_token.response_code.should eq('00')
|
203
|
-
end
|
204
|
-
|
205
|
-
it 'Should get a multi use token from a Master card and auth it with out error' do
|
206
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
207
|
-
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
208
|
-
|
209
|
-
auth.transaction_id.should_not eq(nil)
|
210
|
-
auth.response_code.should eq('00')
|
211
|
-
auth.token_data.token_value.should_not eq(nil)
|
212
|
-
|
213
|
-
multi_token = auth.token_data.token_value
|
214
|
-
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
215
|
-
auth_multi_token.transaction_id.should_not eq(nil)
|
216
|
-
auth_multi_token.response_code.should eq('00')
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'Should get a multi use token from a Visa card and auth it with out error' do
|
220
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
221
|
-
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
222
|
-
|
223
|
-
auth.transaction_id.should_not eq(nil)
|
224
|
-
auth.response_code.should eq('00')
|
225
|
-
auth.token_data.token_value.should_not eq(nil)
|
226
|
-
|
227
|
-
multi_token = auth.token_data.token_value
|
228
|
-
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
229
|
-
auth_multi_token.transaction_id.should_not eq(nil)
|
230
|
-
auth_multi_token.response_code.should eq('00')
|
231
|
-
end
|
232
|
-
|
233
|
-
# Verify Testing with a token
|
234
|
-
|
235
|
-
it 'Should get a token from a Amex card and verify it with out error' do
|
236
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
237
|
-
verify = Hps::TestHelper.verify_token(token['token_value'])
|
238
|
-
|
239
|
-
verify.transaction_id.should_not eq(nil)
|
240
|
-
verify.response_code.should eq('00')
|
241
|
-
end
|
242
|
-
|
243
|
-
it 'Should get a token from a Discover card and verify it with out error' do
|
244
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
245
|
-
verify = Hps::TestHelper.verify_token(token['token_value'])
|
246
|
-
|
247
|
-
verify.transaction_id.should_not eq(nil)
|
248
|
-
verify.response_code.should eq('85')
|
249
|
-
end
|
250
|
-
|
251
|
-
it 'Should get a token from a Master card and verify it with out error' do
|
252
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
253
|
-
verify = Hps::TestHelper.verify_token(token['token_value'])
|
254
|
-
|
255
|
-
verify.transaction_id.should_not eq(nil)
|
256
|
-
verify.response_code.should eq('85')
|
257
|
-
end
|
258
|
-
|
259
|
-
it 'Should get a token from a Visa card and verify it with out error' do
|
260
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
261
|
-
verify = Hps::TestHelper.verify_token(token['token_value'])
|
262
|
-
|
263
|
-
verify.transaction_id.should_not eq(nil)
|
264
|
-
verify.response_code.should eq('85')
|
265
|
-
end
|
266
|
-
|
267
|
-
# Verify Testing with a multi use token
|
268
|
-
|
269
|
-
it 'Should get a token from a Amex card verify it get a multi token and test with out error' do
|
270
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
271
|
-
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
272
|
-
|
273
|
-
verify.transaction_id.should_not eq(nil)
|
274
|
-
verify.response_code.should eq('00')
|
275
|
-
verify.token_data.token_value.should_not eq(nil)
|
276
|
-
|
277
|
-
multi_token = verify.token_data.token_value
|
278
|
-
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
279
|
-
verify_multi_token.transaction_id.should_not eq(nil)
|
280
|
-
verify_multi_token.response_code.should eq('00')
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'Should get a token from a Discover card verify it get a multi token and test with out error' do
|
284
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
285
|
-
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
286
|
-
|
287
|
-
verify.transaction_id.should_not eq(nil)
|
288
|
-
verify.response_code.should eq('85')
|
289
|
-
verify.token_data.token_value.should_not eq(nil)
|
290
|
-
|
291
|
-
multi_token = verify.token_data.token_value
|
292
|
-
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
293
|
-
verify_multi_token.transaction_id.should_not eq(nil)
|
294
|
-
verify_multi_token.response_code.should eq('85')
|
295
|
-
end
|
296
|
-
|
297
|
-
it 'Should get a token from a Master card verify it get a multi token and test with out error' do
|
298
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
299
|
-
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
300
|
-
|
301
|
-
verify.transaction_id.should_not eq(nil)
|
302
|
-
verify.response_code.should eq('85')
|
303
|
-
verify.token_data.token_value.should_not eq(nil)
|
304
|
-
|
305
|
-
multi_token = verify.token_data.token_value
|
306
|
-
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
307
|
-
verify_multi_token.transaction_id.should_not eq(nil)
|
308
|
-
verify_multi_token.response_code.should eq('85')
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'Should get a token from a Visa card verify it get a multi token and test with out error' do
|
312
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
313
|
-
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
314
|
-
|
315
|
-
verify.transaction_id.should_not eq(nil)
|
316
|
-
verify.response_code.should eq('85')
|
317
|
-
verify.token_data.token_value.should_not eq(nil)
|
318
|
-
|
319
|
-
multi_token = verify.token_data.token_value
|
320
|
-
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
321
|
-
verify_multi_token.transaction_id.should_not eq(nil)
|
322
|
-
verify_multi_token.response_code.should eq('85')
|
323
|
-
end
|
324
|
-
|
325
|
-
# Refund Token Tests
|
326
|
-
|
327
|
-
it 'Should get Amex token return should be okay' do
|
328
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
329
|
-
refund = Hps::TestHelper.refund_token(token['token_value'])
|
330
|
-
|
331
|
-
refund.transaction_id.should_not eq(nil)
|
332
|
-
refund.response_code.should eq('00')
|
333
|
-
end
|
334
|
-
|
335
|
-
|
336
|
-
it 'Should get Discover token return should be okay' do
|
337
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
338
|
-
refund = Hps::TestHelper.refund_token(token['token_value'])
|
339
|
-
|
340
|
-
refund.transaction_id.should_not eq(nil)
|
341
|
-
refund.response_code.should eq('00')
|
342
|
-
end
|
343
|
-
|
344
|
-
|
345
|
-
it 'Should get MasterCard token return should be okay' do
|
346
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
347
|
-
refund = Hps::TestHelper.refund_token(token['token_value'])
|
348
|
-
|
349
|
-
refund.transaction_id.should_not eq(nil)
|
350
|
-
refund.response_code.should eq('00')
|
351
|
-
end
|
352
|
-
|
353
|
-
it 'Should get Visa token return should be okay' do
|
354
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
355
|
-
refund = Hps::TestHelper.refund_token(token['token_value'])
|
356
|
-
|
357
|
-
refund.transaction_id.should_not eq(nil)
|
358
|
-
refund.response_code.should eq('00')
|
359
|
-
end
|
360
|
-
|
361
|
-
# Refund Multi Token Tests
|
362
|
-
|
363
|
-
it 'Should get Amex Mulit token return should be okay' do
|
364
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
365
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
366
|
-
|
367
|
-
charge.transaction_id.should_not eq(nil)
|
368
|
-
charge.response_code.should eq('00')
|
369
|
-
charge.token_data.token_value.should_not eq(nil)
|
370
|
-
|
371
|
-
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
372
|
-
|
373
|
-
refund.transaction_id.should_not eq(nil)
|
374
|
-
refund.response_code.should eq('00')
|
375
|
-
end
|
376
|
-
|
377
|
-
it 'Should get Discover Mulit token return should be okay' do
|
378
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
379
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
380
|
-
|
381
|
-
charge.transaction_id.should_not eq(nil)
|
382
|
-
charge.response_code.should eq('00')
|
383
|
-
charge.token_data.token_value.should_not eq(nil)
|
384
|
-
|
385
|
-
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
386
|
-
|
387
|
-
refund.transaction_id.should_not eq(nil)
|
388
|
-
refund.response_code.should eq('00')
|
389
|
-
end
|
390
|
-
|
391
|
-
it 'Should get MasterCard Mulit token return should be okay' do
|
392
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
393
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
394
|
-
|
395
|
-
charge.transaction_id.should_not eq(nil)
|
396
|
-
charge.response_code.should eq('00')
|
397
|
-
charge.token_data.token_value.should_not eq(nil)
|
398
|
-
|
399
|
-
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
400
|
-
|
401
|
-
refund.transaction_id.should_not eq(nil)
|
402
|
-
refund.response_code.should eq('00')
|
403
|
-
end
|
404
|
-
|
405
|
-
it 'Should get Visa Mulit token return should be okay' do
|
406
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
407
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
408
|
-
|
409
|
-
charge.transaction_id.should_not eq(nil)
|
410
|
-
charge.response_code.should eq('00')
|
411
|
-
charge.token_data.token_value.should_not eq(nil)
|
412
|
-
|
413
|
-
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
414
|
-
|
415
|
-
refund.transaction_id.should_not eq(nil)
|
416
|
-
refund.response_code.should eq('00')
|
417
|
-
end
|
418
|
-
|
419
|
-
# Reverse Token Tests
|
420
|
-
|
421
|
-
it 'Should get Amex token reverse should be okay' do
|
422
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
423
|
-
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
424
|
-
|
425
|
-
refund.transaction_id.should_not eq(nil)
|
426
|
-
refund.response_code.should eq('00')
|
427
|
-
end
|
428
|
-
|
429
|
-
|
430
|
-
it 'Should get Discover token reverse should be okay' do
|
431
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
432
|
-
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
433
|
-
|
434
|
-
refund.transaction_id.should_not eq(nil)
|
435
|
-
refund.response_code.should eq('00')
|
436
|
-
end
|
437
|
-
|
438
|
-
|
439
|
-
it 'Should get MasterCard token reverse should be okay' do
|
440
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
441
|
-
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
442
|
-
|
443
|
-
refund.transaction_id.should_not eq(nil)
|
444
|
-
refund.response_code.should eq('00')
|
445
|
-
end
|
446
|
-
|
447
|
-
it 'Should get Visa token reverse should be okay' do
|
448
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
449
|
-
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
450
|
-
|
451
|
-
refund.transaction_id.should_not eq(nil)
|
452
|
-
refund.response_code.should eq('00')
|
453
|
-
end
|
454
|
-
|
455
|
-
# Reverse Multi Token Tests
|
456
|
-
|
457
|
-
it 'Should get Amex Mulit token reverse should be okay' do
|
458
|
-
token = token_service.get_token(Hps::TestData.valid_amex)
|
459
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
460
|
-
|
461
|
-
charge.transaction_id.should_not eq(nil)
|
462
|
-
charge.response_code.should eq('00')
|
463
|
-
charge.token_data.token_value.should_not eq(nil)
|
464
|
-
|
465
|
-
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
466
|
-
|
467
|
-
refund.transaction_id.should_not eq(nil)
|
468
|
-
refund.response_code.should eq('00')
|
469
|
-
end
|
470
|
-
|
471
|
-
it 'Should get Discover Mulit token reverse should be okay' do
|
472
|
-
token = token_service.get_token(Hps::TestData.valid_discover)
|
473
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
474
|
-
|
475
|
-
charge.transaction_id.should_not eq(nil)
|
476
|
-
charge.response_code.should eq('00')
|
477
|
-
charge.token_data.token_value.should_not eq(nil)
|
478
|
-
|
479
|
-
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
480
|
-
|
481
|
-
refund.transaction_id.should_not eq(nil)
|
482
|
-
refund.response_code.should eq('00')
|
483
|
-
end
|
484
|
-
|
485
|
-
it 'Should get MasterCard Mulit token reverse should be okay' do
|
486
|
-
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
487
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
488
|
-
|
489
|
-
charge.transaction_id.should_not eq(nil)
|
490
|
-
charge.response_code.should eq('00')
|
491
|
-
charge.token_data.token_value.should_not eq(nil)
|
492
|
-
|
493
|
-
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
494
|
-
|
495
|
-
refund.transaction_id.should_not eq(nil)
|
496
|
-
refund.response_code.should eq('00')
|
497
|
-
end
|
498
|
-
|
499
|
-
it 'Should get Visa Mulit token reverse should be okay' do
|
500
|
-
token = token_service.get_token(Hps::TestData.valid_visa)
|
501
|
-
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
502
|
-
|
503
|
-
charge.transaction_id.should_not eq(nil)
|
504
|
-
charge.response_code.should eq('00')
|
505
|
-
charge.token_data.token_value.should_not eq(nil)
|
506
|
-
|
507
|
-
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
508
|
-
|
509
|
-
refund.transaction_id.should_not eq(nil)
|
510
|
-
refund.response_code.should eq('00')
|
511
|
-
end
|
512
|
-
|
513
|
-
end
|
1
|
+
require File.join( File.dirname(__FILE__), 'test_helper' )
|
2
|
+
require File.join( File.dirname(__FILE__), 'hps_token_service')
|
3
|
+
require File.join( File.dirname(__FILE__), 'test_data' )
|
4
|
+
|
5
|
+
describe 'token_tests' do
|
6
|
+
|
7
|
+
let(:public_key) { Hps::TestHelper.valid_multi_use_public_key}
|
8
|
+
let(:token_service) { Hps::HpsTokenService.new(public_key) }
|
9
|
+
|
10
|
+
|
11
|
+
#Basic single token fetching tests
|
12
|
+
|
13
|
+
it 'Should return a one time use token' do
|
14
|
+
token_response = token_service.get_token(Hps::TestData.valid_visa)
|
15
|
+
token_response['token_value'].should_not eq(nil)
|
16
|
+
token_response['token_value'].should include('supt')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'Should fail getting a token due to bad key' do
|
20
|
+
expect { Hps::HpsTokenService.new('bad_key') }.to raise_error('Public API Key must contain at least two underscores')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Should fail getting an empty JSON response due to bad key' do
|
24
|
+
token_service = Hps::HpsTokenService.new('Still_bad_key')
|
25
|
+
expect { token_service.get_token(Hps::TestData.valid_visa) }.to raise_error('A JSON text must at least contain two octets!')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'Should fail and return an Error Card not Recognized' do
|
29
|
+
card = Hps::TestData.valid_visa
|
30
|
+
card.number = '11111111111111111'
|
31
|
+
token_response = token_service.get_token(card)
|
32
|
+
token_response['error']['message'].should eq('Card number is not a recognized brand.')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'Should fail and return Card Expiration Month invalid' do
|
36
|
+
card = Hps::TestData.valid_visa
|
37
|
+
card.exp_month = 13
|
38
|
+
token_response = token_service.get_token(card)
|
39
|
+
token_response['error']['message'].should eq('Card expiration month is invalid.')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'Should fail and return Card Expiration Year invalid' do
|
43
|
+
card = Hps::TestData.valid_visa
|
44
|
+
card.exp_year = 12
|
45
|
+
token_response = token_service.get_token(card)
|
46
|
+
token_response['error']['message'].should eq('Card expiration year is invalid.')
|
47
|
+
end
|
48
|
+
|
49
|
+
#Charge Testing with a token
|
50
|
+
|
51
|
+
it 'Should get a token from a Amex card and charge it with out error' do
|
52
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
53
|
+
charge = Hps::TestHelper.charge_token(token['token_value'])
|
54
|
+
|
55
|
+
charge.transaction_id.should_not eq(nil)
|
56
|
+
charge.response_code.should eq('00')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'Should get a token from a Discover card and charge it with out error' do
|
60
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
61
|
+
charge = Hps::TestHelper.charge_token(token['token_value'])
|
62
|
+
|
63
|
+
charge.transaction_id.should_not eq(nil)
|
64
|
+
charge.response_code.should eq('00')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'Should get a token from a Master card and charge it with out error' do
|
68
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
69
|
+
charge = Hps::TestHelper.charge_token(token['token_value'])
|
70
|
+
|
71
|
+
charge.transaction_id.should_not eq(nil)
|
72
|
+
charge.response_code.should eq('00')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'Should get a token from a Visa card and charge it with out error' do
|
76
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
77
|
+
charge = Hps::TestHelper.charge_token(token['token_value'])
|
78
|
+
|
79
|
+
charge.transaction_id.should_not eq(nil)
|
80
|
+
charge.response_code.should eq('00')
|
81
|
+
end
|
82
|
+
|
83
|
+
# Charge Testing with a multi use token
|
84
|
+
|
85
|
+
it 'Should get a multi use token from a Amex card and charge it with out error' do
|
86
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
87
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
88
|
+
|
89
|
+
charge.transaction_id.should_not eq(nil)
|
90
|
+
charge.response_code.should eq('00')
|
91
|
+
charge.token_data.token_value.should_not eq(nil)
|
92
|
+
|
93
|
+
multi_token = charge.token_data.token_value
|
94
|
+
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
95
|
+
charge_multi_token.transaction_id.should_not eq(nil)
|
96
|
+
charge_multi_token.response_code.should eq('00')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'Should get a multi use token from a Discover card and charge it with out error' do
|
100
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
101
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
102
|
+
|
103
|
+
charge.transaction_id.should_not eq(nil)
|
104
|
+
charge.response_code.should eq('00')
|
105
|
+
charge.token_data.token_value.should_not eq(nil)
|
106
|
+
|
107
|
+
multi_token = charge.token_data.token_value
|
108
|
+
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
109
|
+
charge_multi_token.transaction_id.should_not eq(nil)
|
110
|
+
charge_multi_token.response_code.should eq('00')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'Should get a multi use token from a Master card and charge it with out error' do
|
114
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
115
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
116
|
+
|
117
|
+
charge.transaction_id.should_not eq(nil)
|
118
|
+
charge.response_code.should eq('00')
|
119
|
+
charge.token_data.token_value.should_not eq(nil)
|
120
|
+
|
121
|
+
multi_token = charge.token_data.token_value
|
122
|
+
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
123
|
+
charge_multi_token.transaction_id.should_not eq(nil)
|
124
|
+
charge_multi_token.response_code.should eq('00')
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'Should get a multi use token from a Visa card and charge it with out error' do
|
128
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
129
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
130
|
+
|
131
|
+
charge.transaction_id.should_not eq(nil)
|
132
|
+
charge.response_code.should eq('00')
|
133
|
+
charge.token_data.token_value.should_not eq(nil)
|
134
|
+
|
135
|
+
multi_token = charge.token_data.token_value
|
136
|
+
charge_multi_token = Hps::TestHelper.charge_token(multi_token)
|
137
|
+
charge_multi_token.transaction_id.should_not eq(nil)
|
138
|
+
charge_multi_token.response_code.should eq('00')
|
139
|
+
end
|
140
|
+
|
141
|
+
## Auth Testing with a token
|
142
|
+
|
143
|
+
it 'Should get a token from a Amex card and auth it with out error' do
|
144
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
145
|
+
auth = Hps::TestHelper.auth_token(token['token_value'])
|
146
|
+
|
147
|
+
auth.transaction_id.should_not eq(nil)
|
148
|
+
auth.response_code.should eq('00')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'Should get a token from a Discover card and auth it with out error' do
|
152
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
153
|
+
auth = Hps::TestHelper.auth_token(token['token_value'])
|
154
|
+
|
155
|
+
auth.transaction_id.should_not eq(nil)
|
156
|
+
auth.response_code.should eq('00')
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'Should get a token from a Master card and auth it with out error' do
|
160
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
161
|
+
auth = Hps::TestHelper.auth_token(token['token_value'])
|
162
|
+
|
163
|
+
auth.transaction_id.should_not eq(nil)
|
164
|
+
auth.response_code.should eq('00')
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'Should get a token from a Visa card and auth it with out error' do
|
168
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
169
|
+
auth = Hps::TestHelper.auth_token(token['token_value'])
|
170
|
+
|
171
|
+
auth.transaction_id.should_not eq(nil)
|
172
|
+
auth.response_code.should eq('00')
|
173
|
+
end
|
174
|
+
|
175
|
+
# Authorize Testing with a multi use token
|
176
|
+
|
177
|
+
it 'Should get a multi use token from a Amex card and auth it with out error' do
|
178
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
179
|
+
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
180
|
+
|
181
|
+
auth.transaction_id.should_not eq(nil)
|
182
|
+
auth.response_code.should eq('00')
|
183
|
+
auth.token_data.token_value.should_not eq(nil)
|
184
|
+
|
185
|
+
multi_token = auth.token_data.token_value
|
186
|
+
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
187
|
+
auth_multi_token.transaction_id.should_not eq(nil)
|
188
|
+
auth_multi_token.response_code.should eq('00')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'Should get a multi use token from a Discover card and auth it with out error' do
|
192
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
193
|
+
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
194
|
+
|
195
|
+
auth.transaction_id.should_not eq(nil)
|
196
|
+
auth.response_code.should eq('00')
|
197
|
+
auth.token_data.token_value.should_not eq(nil)
|
198
|
+
|
199
|
+
multi_token = auth.token_data.token_value
|
200
|
+
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
201
|
+
auth_multi_token.transaction_id.should_not eq(nil)
|
202
|
+
auth_multi_token.response_code.should eq('00')
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'Should get a multi use token from a Master card and auth it with out error' do
|
206
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
207
|
+
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
208
|
+
|
209
|
+
auth.transaction_id.should_not eq(nil)
|
210
|
+
auth.response_code.should eq('00')
|
211
|
+
auth.token_data.token_value.should_not eq(nil)
|
212
|
+
|
213
|
+
multi_token = auth.token_data.token_value
|
214
|
+
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
215
|
+
auth_multi_token.transaction_id.should_not eq(nil)
|
216
|
+
auth_multi_token.response_code.should eq('00')
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'Should get a multi use token from a Visa card and auth it with out error' do
|
220
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
221
|
+
auth = Hps::TestHelper.auth_token(token['token_value'],true)
|
222
|
+
|
223
|
+
auth.transaction_id.should_not eq(nil)
|
224
|
+
auth.response_code.should eq('00')
|
225
|
+
auth.token_data.token_value.should_not eq(nil)
|
226
|
+
|
227
|
+
multi_token = auth.token_data.token_value
|
228
|
+
auth_multi_token = Hps::TestHelper.auth_token(multi_token)
|
229
|
+
auth_multi_token.transaction_id.should_not eq(nil)
|
230
|
+
auth_multi_token.response_code.should eq('00')
|
231
|
+
end
|
232
|
+
|
233
|
+
# Verify Testing with a token
|
234
|
+
|
235
|
+
it 'Should get a token from a Amex card and verify it with out error' do
|
236
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
237
|
+
verify = Hps::TestHelper.verify_token(token['token_value'])
|
238
|
+
|
239
|
+
verify.transaction_id.should_not eq(nil)
|
240
|
+
verify.response_code.should eq('00')
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'Should get a token from a Discover card and verify it with out error' do
|
244
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
245
|
+
verify = Hps::TestHelper.verify_token(token['token_value'])
|
246
|
+
|
247
|
+
verify.transaction_id.should_not eq(nil)
|
248
|
+
verify.response_code.should eq('85')
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'Should get a token from a Master card and verify it with out error' do
|
252
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
253
|
+
verify = Hps::TestHelper.verify_token(token['token_value'])
|
254
|
+
|
255
|
+
verify.transaction_id.should_not eq(nil)
|
256
|
+
verify.response_code.should eq('85')
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'Should get a token from a Visa card and verify it with out error' do
|
260
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
261
|
+
verify = Hps::TestHelper.verify_token(token['token_value'])
|
262
|
+
|
263
|
+
verify.transaction_id.should_not eq(nil)
|
264
|
+
verify.response_code.should eq('85')
|
265
|
+
end
|
266
|
+
|
267
|
+
# Verify Testing with a multi use token
|
268
|
+
|
269
|
+
it 'Should get a token from a Amex card verify it get a multi token and test with out error' do
|
270
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
271
|
+
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
272
|
+
|
273
|
+
verify.transaction_id.should_not eq(nil)
|
274
|
+
verify.response_code.should eq('00')
|
275
|
+
verify.token_data.token_value.should_not eq(nil)
|
276
|
+
|
277
|
+
multi_token = verify.token_data.token_value
|
278
|
+
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
279
|
+
verify_multi_token.transaction_id.should_not eq(nil)
|
280
|
+
verify_multi_token.response_code.should eq('00')
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'Should get a token from a Discover card verify it get a multi token and test with out error' do
|
284
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
285
|
+
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
286
|
+
|
287
|
+
verify.transaction_id.should_not eq(nil)
|
288
|
+
verify.response_code.should eq('85')
|
289
|
+
verify.token_data.token_value.should_not eq(nil)
|
290
|
+
|
291
|
+
multi_token = verify.token_data.token_value
|
292
|
+
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
293
|
+
verify_multi_token.transaction_id.should_not eq(nil)
|
294
|
+
verify_multi_token.response_code.should eq('85')
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'Should get a token from a Master card verify it get a multi token and test with out error' do
|
298
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
299
|
+
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
300
|
+
|
301
|
+
verify.transaction_id.should_not eq(nil)
|
302
|
+
verify.response_code.should eq('85')
|
303
|
+
verify.token_data.token_value.should_not eq(nil)
|
304
|
+
|
305
|
+
multi_token = verify.token_data.token_value
|
306
|
+
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
307
|
+
verify_multi_token.transaction_id.should_not eq(nil)
|
308
|
+
verify_multi_token.response_code.should eq('85')
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'Should get a token from a Visa card verify it get a multi token and test with out error' do
|
312
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
313
|
+
verify = Hps::TestHelper.verify_token(token['token_value'],true)
|
314
|
+
|
315
|
+
verify.transaction_id.should_not eq(nil)
|
316
|
+
verify.response_code.should eq('85')
|
317
|
+
verify.token_data.token_value.should_not eq(nil)
|
318
|
+
|
319
|
+
multi_token = verify.token_data.token_value
|
320
|
+
verify_multi_token = Hps::TestHelper.verify_token(multi_token)
|
321
|
+
verify_multi_token.transaction_id.should_not eq(nil)
|
322
|
+
verify_multi_token.response_code.should eq('85')
|
323
|
+
end
|
324
|
+
|
325
|
+
# Refund Token Tests
|
326
|
+
|
327
|
+
it 'Should get Amex token return should be okay' do
|
328
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
329
|
+
refund = Hps::TestHelper.refund_token(token['token_value'])
|
330
|
+
|
331
|
+
refund.transaction_id.should_not eq(nil)
|
332
|
+
refund.response_code.should eq('00')
|
333
|
+
end
|
334
|
+
|
335
|
+
|
336
|
+
it 'Should get Discover token return should be okay' do
|
337
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
338
|
+
refund = Hps::TestHelper.refund_token(token['token_value'])
|
339
|
+
|
340
|
+
refund.transaction_id.should_not eq(nil)
|
341
|
+
refund.response_code.should eq('00')
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
it 'Should get MasterCard token return should be okay' do
|
346
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
347
|
+
refund = Hps::TestHelper.refund_token(token['token_value'])
|
348
|
+
|
349
|
+
refund.transaction_id.should_not eq(nil)
|
350
|
+
refund.response_code.should eq('00')
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'Should get Visa token return should be okay' do
|
354
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
355
|
+
refund = Hps::TestHelper.refund_token(token['token_value'])
|
356
|
+
|
357
|
+
refund.transaction_id.should_not eq(nil)
|
358
|
+
refund.response_code.should eq('00')
|
359
|
+
end
|
360
|
+
|
361
|
+
# Refund Multi Token Tests
|
362
|
+
|
363
|
+
it 'Should get Amex Mulit token return should be okay' do
|
364
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
365
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
366
|
+
|
367
|
+
charge.transaction_id.should_not eq(nil)
|
368
|
+
charge.response_code.should eq('00')
|
369
|
+
charge.token_data.token_value.should_not eq(nil)
|
370
|
+
|
371
|
+
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
372
|
+
|
373
|
+
refund.transaction_id.should_not eq(nil)
|
374
|
+
refund.response_code.should eq('00')
|
375
|
+
end
|
376
|
+
|
377
|
+
it 'Should get Discover Mulit token return should be okay' do
|
378
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
379
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
380
|
+
|
381
|
+
charge.transaction_id.should_not eq(nil)
|
382
|
+
charge.response_code.should eq('00')
|
383
|
+
charge.token_data.token_value.should_not eq(nil)
|
384
|
+
|
385
|
+
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
386
|
+
|
387
|
+
refund.transaction_id.should_not eq(nil)
|
388
|
+
refund.response_code.should eq('00')
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'Should get MasterCard Mulit token return should be okay' do
|
392
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
393
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
394
|
+
|
395
|
+
charge.transaction_id.should_not eq(nil)
|
396
|
+
charge.response_code.should eq('00')
|
397
|
+
charge.token_data.token_value.should_not eq(nil)
|
398
|
+
|
399
|
+
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
400
|
+
|
401
|
+
refund.transaction_id.should_not eq(nil)
|
402
|
+
refund.response_code.should eq('00')
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'Should get Visa Mulit token return should be okay' do
|
406
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
407
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
408
|
+
|
409
|
+
charge.transaction_id.should_not eq(nil)
|
410
|
+
charge.response_code.should eq('00')
|
411
|
+
charge.token_data.token_value.should_not eq(nil)
|
412
|
+
|
413
|
+
refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
|
414
|
+
|
415
|
+
refund.transaction_id.should_not eq(nil)
|
416
|
+
refund.response_code.should eq('00')
|
417
|
+
end
|
418
|
+
|
419
|
+
# Reverse Token Tests
|
420
|
+
|
421
|
+
it 'Should get Amex token reverse should be okay' do
|
422
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
423
|
+
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
424
|
+
|
425
|
+
refund.transaction_id.should_not eq(nil)
|
426
|
+
refund.response_code.should eq('00')
|
427
|
+
end
|
428
|
+
|
429
|
+
|
430
|
+
it 'Should get Discover token reverse should be okay' do
|
431
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
432
|
+
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
433
|
+
|
434
|
+
refund.transaction_id.should_not eq(nil)
|
435
|
+
refund.response_code.should eq('00')
|
436
|
+
end
|
437
|
+
|
438
|
+
|
439
|
+
it 'Should get MasterCard token reverse should be okay' do
|
440
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
441
|
+
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
442
|
+
|
443
|
+
refund.transaction_id.should_not eq(nil)
|
444
|
+
refund.response_code.should eq('00')
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'Should get Visa token reverse should be okay' do
|
448
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
449
|
+
refund = Hps::TestHelper.reverse_token(token['token_value'])
|
450
|
+
|
451
|
+
refund.transaction_id.should_not eq(nil)
|
452
|
+
refund.response_code.should eq('00')
|
453
|
+
end
|
454
|
+
|
455
|
+
# Reverse Multi Token Tests
|
456
|
+
|
457
|
+
it 'Should get Amex Mulit token reverse should be okay' do
|
458
|
+
token = token_service.get_token(Hps::TestData.valid_amex)
|
459
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
460
|
+
|
461
|
+
charge.transaction_id.should_not eq(nil)
|
462
|
+
charge.response_code.should eq('00')
|
463
|
+
charge.token_data.token_value.should_not eq(nil)
|
464
|
+
|
465
|
+
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
466
|
+
|
467
|
+
refund.transaction_id.should_not eq(nil)
|
468
|
+
refund.response_code.should eq('00')
|
469
|
+
end
|
470
|
+
|
471
|
+
it 'Should get Discover Mulit token reverse should be okay' do
|
472
|
+
token = token_service.get_token(Hps::TestData.valid_discover)
|
473
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
474
|
+
|
475
|
+
charge.transaction_id.should_not eq(nil)
|
476
|
+
charge.response_code.should eq('00')
|
477
|
+
charge.token_data.token_value.should_not eq(nil)
|
478
|
+
|
479
|
+
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
480
|
+
|
481
|
+
refund.transaction_id.should_not eq(nil)
|
482
|
+
refund.response_code.should eq('00')
|
483
|
+
end
|
484
|
+
|
485
|
+
it 'Should get MasterCard Mulit token reverse should be okay' do
|
486
|
+
token = token_service.get_token(Hps::TestData.valid_mastercard)
|
487
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
488
|
+
|
489
|
+
charge.transaction_id.should_not eq(nil)
|
490
|
+
charge.response_code.should eq('00')
|
491
|
+
charge.token_data.token_value.should_not eq(nil)
|
492
|
+
|
493
|
+
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
494
|
+
|
495
|
+
refund.transaction_id.should_not eq(nil)
|
496
|
+
refund.response_code.should eq('00')
|
497
|
+
end
|
498
|
+
|
499
|
+
it 'Should get Visa Mulit token reverse should be okay' do
|
500
|
+
token = token_service.get_token(Hps::TestData.valid_visa)
|
501
|
+
charge = Hps::TestHelper.charge_token(token['token_value'],true)
|
502
|
+
|
503
|
+
charge.transaction_id.should_not eq(nil)
|
504
|
+
charge.response_code.should eq('00')
|
505
|
+
charge.token_data.token_value.should_not eq(nil)
|
506
|
+
|
507
|
+
refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
|
508
|
+
|
509
|
+
refund.transaction_id.should_not eq(nil)
|
510
|
+
refund.response_code.should eq('00')
|
511
|
+
end
|
512
|
+
|
513
|
+
end
|