killbill-litle 1.10.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -5
- data/.travis.yml +22 -3
- data/Gemfile +1 -1
- data/Gemfile.head +5 -0
- data/Gemfile.lock +129 -0
- data/Jarfile +9 -6
- data/Jarfile.lock +58 -0
- data/LICENSE +201 -0
- data/NEWS +3 -0
- data/README.md +58 -98
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/config.ru +1 -1
- data/db/ddl.sql +32 -21
- data/db/schema.rb +44 -32
- data/killbill-litle.gemspec +20 -16
- data/lib/litle.rb +82 -12
- data/lib/litle/api.rb +144 -204
- data/lib/litle/application.rb +96 -0
- data/lib/litle/models/payment_method.rb +21 -0
- data/lib/litle/models/response.rb +44 -0
- data/lib/litle/models/transaction.rb +11 -0
- data/lib/litle/private_api.rb +42 -13
- data/lib/litle/views/paypage.erb +8 -5
- data/litle.yml +33 -11
- data/pom.xml +3 -2
- data/release.sh +41 -21
- data/spec/litle/base_plugin_spec.rb +35 -62
- data/spec/litle/remote/certification_spec.rb +713 -0
- data/spec/litle/remote/integration_spec.rb +97 -168
- data/spec/spec_helper.rb +3 -16
- metadata +102 -55
- data/lib/litle/config/application.rb +0 -66
- data/lib/litle/config/configuration.rb +0 -51
- data/lib/litle/config/properties.rb +0 -23
- data/lib/litle/litle/gateway.rb +0 -32
- data/lib/litle/models/litle_payment_method.rb +0 -167
- data/lib/litle/models/litle_response.rb +0 -199
- data/lib/litle/models/litle_transaction.rb +0 -44
- data/spec/litle/currency_conversion_spec.rb +0 -21
- data/spec/litle/litle_payment_method_spec.rb +0 -95
- data/spec/litle/litle_response_spec.rb +0 -91
- data/spec/litle/utils_spec.rb +0 -22
@@ -0,0 +1,713 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
ActiveMerchant::Billing::Base.mode = :test
|
4
|
+
|
5
|
+
describe Killbill::Litle::PaymentPlugin do
|
6
|
+
|
7
|
+
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
::Killbill::Litle::LitlePaymentMethod.delete_all
|
11
|
+
::Killbill::Litle::LitleResponse.delete_all
|
12
|
+
::Killbill::Litle::LitleTransaction.delete_all
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
puts 'orderId,litleTxnId,api_call,message'
|
17
|
+
::Killbill::Litle::LitleResponse.all.each do |response|
|
18
|
+
next if response.params_litle_txn_id.blank?
|
19
|
+
puts "#{response.params_order_id},#{response.params_litle_txn_id},#{response.api_call},#{response.message}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@plugin = build_plugin(::Killbill::Litle::PaymentPlugin, 'litle')
|
25
|
+
@plugin.start_plugin
|
26
|
+
|
27
|
+
@call_context = build_call_context
|
28
|
+
|
29
|
+
@properties = []
|
30
|
+
@pm = create_payment_method(::Killbill::Litle::LitlePaymentMethod, nil, @call_context.tenant_id, [build_property(:skip_gw, true)], {}, false)
|
31
|
+
@currency = 'USD'
|
32
|
+
|
33
|
+
kb_payment_id = SecureRandom.uuid
|
34
|
+
1.upto(8) do
|
35
|
+
@kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
after(:each) do
|
40
|
+
@plugin.stop_plugin
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'passes certification for order id 1' do
|
44
|
+
properties = build_pm_properties(nil,
|
45
|
+
{
|
46
|
+
:cc_number => '4457010000000009',
|
47
|
+
:cc_first_name => 'John',
|
48
|
+
:cc_last_name => 'Smith',
|
49
|
+
:cc_type => 'visa',
|
50
|
+
:cc_exp_month => '01',
|
51
|
+
:cc_exp_year => '2016',
|
52
|
+
:cc_verification_value => '349',
|
53
|
+
:address1 => '1 Main St.',
|
54
|
+
:city => 'Burlington',
|
55
|
+
:state => 'MA',
|
56
|
+
:zip => '01803-3747',
|
57
|
+
:country => 'US'
|
58
|
+
},
|
59
|
+
false)
|
60
|
+
|
61
|
+
assertions = {
|
62
|
+
:avs => 'X',
|
63
|
+
:cvv => 'M'
|
64
|
+
}
|
65
|
+
|
66
|
+
txn_nb = 0
|
67
|
+
|
68
|
+
txn_nb = auth_assertions('1', 100.10, txn_nb, properties, assertions)
|
69
|
+
|
70
|
+
# 1: authorize avs
|
71
|
+
txn_nb = avs_assertions('1', txn_nb, properties, assertions)
|
72
|
+
|
73
|
+
sale_assertions('1', 100.10, txn_nb, properties, assertions)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'passes certification for order id 2' do
|
77
|
+
properties = build_pm_properties(nil,
|
78
|
+
{
|
79
|
+
:cc_number => '5112010000000003',
|
80
|
+
:cc_first_name => 'Mike J.',
|
81
|
+
:cc_last_name => 'Hammer',
|
82
|
+
:cc_type => 'master',
|
83
|
+
:cc_exp_month => '02',
|
84
|
+
:cc_exp_year => '2016',
|
85
|
+
:cc_verification_value => '261',
|
86
|
+
:address1 => '2 Main St.',
|
87
|
+
:city => 'Riverside',
|
88
|
+
:state => 'RI',
|
89
|
+
:zip => '02915',
|
90
|
+
:country => 'US'
|
91
|
+
},
|
92
|
+
false)
|
93
|
+
|
94
|
+
assertions = {
|
95
|
+
:avs => 'Z',
|
96
|
+
:cvv => 'M'
|
97
|
+
}
|
98
|
+
|
99
|
+
txn_nb = 0
|
100
|
+
|
101
|
+
txn_nb = auth_assertions('2', 200.20, txn_nb, properties, assertions)
|
102
|
+
|
103
|
+
# 2: authorize avs
|
104
|
+
txn_nb = avs_assertions('2', txn_nb, properties, assertions)
|
105
|
+
|
106
|
+
sale_assertions('2', 200.20, txn_nb, properties, assertions)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'passes certification for order id 3' do
|
110
|
+
properties = build_pm_properties(nil,
|
111
|
+
{
|
112
|
+
:cc_number => '6011010000000003',
|
113
|
+
:cc_first_name => 'Eileen',
|
114
|
+
:cc_last_name => 'Jones',
|
115
|
+
:cc_type => 'discover',
|
116
|
+
:cc_exp_month => '03',
|
117
|
+
:cc_exp_year => '2016',
|
118
|
+
:cc_verification_value => '758',
|
119
|
+
:address1 => '3 Main St.',
|
120
|
+
:city => 'Bloomfield',
|
121
|
+
:state => 'CT',
|
122
|
+
:zip => '06002',
|
123
|
+
:country => 'US'
|
124
|
+
},
|
125
|
+
false)
|
126
|
+
|
127
|
+
assertions = {
|
128
|
+
:avs => 'Z',
|
129
|
+
:cvv => 'M'
|
130
|
+
}
|
131
|
+
|
132
|
+
txn_nb = 0
|
133
|
+
|
134
|
+
auth_assertions('3', 300.30, txn_nb, properties, assertions)
|
135
|
+
|
136
|
+
# 3: authorize avs
|
137
|
+
txn_nb = avs_assertions('3', txn_nb, properties, assertions)
|
138
|
+
|
139
|
+
sale_assertions('3', 300.30, txn_nb, properties, assertions)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'passes certification for order id 4' do
|
143
|
+
properties = build_pm_properties(nil,
|
144
|
+
{
|
145
|
+
:cc_number => '375001000000005',
|
146
|
+
:cc_first_name => 'Bob',
|
147
|
+
:cc_last_name => 'Black',
|
148
|
+
:cc_type => 'american_express',
|
149
|
+
:cc_exp_month => '04',
|
150
|
+
:cc_exp_year => '2016',
|
151
|
+
:cc_verification_value => '261',
|
152
|
+
:address1 => '4 Main St.',
|
153
|
+
:city => 'Laurel',
|
154
|
+
:state => 'MD',
|
155
|
+
:zip => '20708',
|
156
|
+
:country => 'US'
|
157
|
+
},
|
158
|
+
false)
|
159
|
+
|
160
|
+
assertions = {
|
161
|
+
:avs => 'A',
|
162
|
+
:cvv => nil
|
163
|
+
}
|
164
|
+
|
165
|
+
txn_nb = 0
|
166
|
+
|
167
|
+
txn_nb = auth_assertions('4', 400.40, txn_nb, properties, assertions)
|
168
|
+
|
169
|
+
# 3: authorize avs
|
170
|
+
txn_nb = avs_assertions('4', txn_nb, properties, assertions)
|
171
|
+
|
172
|
+
sale_assertions('4', 400.40, txn_nb, properties, assertions)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'passes certification for order id 6' do
|
176
|
+
properties = build_pm_properties(nil,
|
177
|
+
{
|
178
|
+
:cc_number => '4457010100000008',
|
179
|
+
:cc_first_name => 'Joe',
|
180
|
+
:cc_last_name => 'Green',
|
181
|
+
:cc_type => 'visa',
|
182
|
+
:cc_exp_month => '06',
|
183
|
+
:cc_exp_year => '2016',
|
184
|
+
:cc_verification_value => '992',
|
185
|
+
:address1 => '6 Main St.',
|
186
|
+
:city => 'Derry',
|
187
|
+
:state => 'NH',
|
188
|
+
:zip => '03038',
|
189
|
+
:country => 'US'
|
190
|
+
},
|
191
|
+
false)
|
192
|
+
|
193
|
+
assertions = {
|
194
|
+
:success => false,
|
195
|
+
:message => 'Insufficient Funds',
|
196
|
+
:avs => 'I',
|
197
|
+
:cvv => 'P'
|
198
|
+
}
|
199
|
+
|
200
|
+
txn_nb = 0
|
201
|
+
|
202
|
+
txn_nb = authorize_assertions('6', 600.60, txn_nb, properties, assertions)
|
203
|
+
txn_nb = purchase_assertions('6', 600.60, txn_nb, properties, assertions)
|
204
|
+
|
205
|
+
assertions = {
|
206
|
+
:success => false,
|
207
|
+
:message => 'No transaction found with specified litleTxnId'
|
208
|
+
}
|
209
|
+
|
210
|
+
# Cannot be run since there is no successful Auth nor Purchase
|
211
|
+
# void_assertions('6', txn_nb, properties, assertions)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'passes certification for order id 7' do
|
215
|
+
properties = build_pm_properties(nil,
|
216
|
+
{
|
217
|
+
:cc_number => '5112010100000002',
|
218
|
+
:cc_first_name => 'Jane',
|
219
|
+
:cc_last_name => 'Murray',
|
220
|
+
:cc_type => 'master',
|
221
|
+
:cc_exp_month => '07',
|
222
|
+
:cc_exp_year => '2016',
|
223
|
+
:cc_verification_value => '992',
|
224
|
+
:address1 => '7 Main St.',
|
225
|
+
:city => 'Amesbury',
|
226
|
+
:state => 'MA',
|
227
|
+
:zip => '01913',
|
228
|
+
:country => 'US'
|
229
|
+
},
|
230
|
+
false)
|
231
|
+
|
232
|
+
assertions = {
|
233
|
+
:success => false,
|
234
|
+
:message => 'Invalid Account Number',
|
235
|
+
:avs => 'I',
|
236
|
+
:cvv => 'N'
|
237
|
+
}
|
238
|
+
|
239
|
+
txn_nb = 0
|
240
|
+
|
241
|
+
txn_nb = authorize_assertions('7', 700.70, txn_nb, properties, assertions)
|
242
|
+
txn_nb = avs_assertions('7', txn_nb, properties, assertions)
|
243
|
+
purchase_assertions('7', 700.70, txn_nb, properties, assertions)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'passes certification for order id 8' do
|
247
|
+
properties = build_pm_properties(nil,
|
248
|
+
{
|
249
|
+
:cc_number => '6011010100000002',
|
250
|
+
:cc_first_name => 'Mark',
|
251
|
+
:cc_last_name => 'Johnson',
|
252
|
+
:cc_type => 'discover',
|
253
|
+
:cc_exp_month => '08',
|
254
|
+
:cc_exp_year => '2016',
|
255
|
+
:cc_verification_value => '184',
|
256
|
+
:address1 => '8 Main St.',
|
257
|
+
:city => 'Manchester',
|
258
|
+
:state => 'MH',
|
259
|
+
:zip => '03101',
|
260
|
+
:country => 'US'
|
261
|
+
},
|
262
|
+
false)
|
263
|
+
|
264
|
+
assertions = {
|
265
|
+
:success => false,
|
266
|
+
:message => 'Call Discover',
|
267
|
+
:avs => 'I',
|
268
|
+
:cvv => 'P'
|
269
|
+
}
|
270
|
+
|
271
|
+
txn_nb = 0
|
272
|
+
|
273
|
+
txn_nb = authorize_assertions('8', 800.80, txn_nb, properties, assertions)
|
274
|
+
txn_nb = avs_assertions('8', txn_nb, properties, assertions)
|
275
|
+
purchase_assertions('8', 800.80, txn_nb, properties, assertions)
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'passes certification for order id 9' do
|
279
|
+
properties = build_pm_properties(nil,
|
280
|
+
{
|
281
|
+
:cc_number => '375001010000003',
|
282
|
+
:cc_first_name => 'James',
|
283
|
+
:cc_last_name => 'Miller',
|
284
|
+
:cc_type => 'american_express',
|
285
|
+
:cc_exp_month => '09',
|
286
|
+
:cc_exp_year => '2016',
|
287
|
+
:cc_verification_value => '0421',
|
288
|
+
:address1 => '9 Main St.',
|
289
|
+
:city => 'Boston',
|
290
|
+
:state => 'MA',
|
291
|
+
:zip => '02134',
|
292
|
+
:country => 'US'
|
293
|
+
},
|
294
|
+
false)
|
295
|
+
|
296
|
+
assertions = {
|
297
|
+
:success => false,
|
298
|
+
:message => 'Pick Up Card',
|
299
|
+
:avs => 'I'
|
300
|
+
}
|
301
|
+
|
302
|
+
txn_nb = 0
|
303
|
+
|
304
|
+
txn_nb = authorize_assertions('9', 900.90, txn_nb, properties, assertions)
|
305
|
+
txn_nb = avs_assertions('9', txn_nb, properties, assertions)
|
306
|
+
purchase_assertions('9', 900.90, txn_nb, properties, assertions)
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'passes certification for order id 32' do
|
310
|
+
properties = build_pm_properties(nil,
|
311
|
+
{
|
312
|
+
:cc_number => '4457010000000009',
|
313
|
+
:cc_first_name => 'John',
|
314
|
+
:cc_last_name => 'Smith',
|
315
|
+
:cc_type => 'visa',
|
316
|
+
:cc_exp_month => '01',
|
317
|
+
:cc_exp_year => '2016',
|
318
|
+
:cc_verification_value => '349',
|
319
|
+
:address1 => '1 Main St.',
|
320
|
+
:city => 'Burlington',
|
321
|
+
:state => 'MA',
|
322
|
+
:zip => '01803-3747',
|
323
|
+
:country => 'US'
|
324
|
+
},
|
325
|
+
false)
|
326
|
+
|
327
|
+
assertions = {}
|
328
|
+
|
329
|
+
txn_nb = 0
|
330
|
+
|
331
|
+
txn_nb = authorize_assertions('32', 100.10, txn_nb, properties, assertions)
|
332
|
+
|
333
|
+
txn_nb = capture_assertions('32A', 50.50, txn_nb, properties, assertions)
|
334
|
+
|
335
|
+
assertions = {
|
336
|
+
:success => false,
|
337
|
+
:message => 'Authorization amount has already been depleted'
|
338
|
+
}
|
339
|
+
|
340
|
+
properties << build_property(:linked_transaction_type, :authorize)
|
341
|
+
|
342
|
+
void_assertions('32B', txn_nb, properties, assertions)
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'passes certification for order id 33' do
|
346
|
+
properties = build_pm_properties(nil,
|
347
|
+
{
|
348
|
+
:cc_number => '5112010000000003',
|
349
|
+
:cc_first_name => 'Mike J.',
|
350
|
+
:cc_last_name => 'Hammer',
|
351
|
+
:cc_type => 'master',
|
352
|
+
:cc_exp_month => '02',
|
353
|
+
:cc_exp_year => '2016',
|
354
|
+
:cc_verification_value => '261',
|
355
|
+
:address1 => '2 Main St.',
|
356
|
+
:city => 'Riverside',
|
357
|
+
:state => 'RI',
|
358
|
+
:zip => '02915',
|
359
|
+
:country => 'US'
|
360
|
+
},
|
361
|
+
false)
|
362
|
+
|
363
|
+
assertions = {}
|
364
|
+
|
365
|
+
txn_nb = 0
|
366
|
+
|
367
|
+
txn_nb = authorize_assertions('33', 200.20, txn_nb, properties, assertions)
|
368
|
+
|
369
|
+
properties << build_property(:linked_transaction_type, :authorize)
|
370
|
+
|
371
|
+
void_assertions('33A', txn_nb, properties, assertions)
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'passes certification for order id 34' do
|
375
|
+
properties = build_pm_properties(nil,
|
376
|
+
{
|
377
|
+
:cc_number => '6011010000000003',
|
378
|
+
:cc_first_name => 'Eileen',
|
379
|
+
:cc_last_name => 'Jones',
|
380
|
+
:cc_type => 'discover',
|
381
|
+
:cc_exp_month => '03',
|
382
|
+
:cc_exp_year => '2016',
|
383
|
+
:cc_verification_value => '261',
|
384
|
+
:address1 => '3 Main St.',
|
385
|
+
:city => 'Bloomfield',
|
386
|
+
:state => 'CT',
|
387
|
+
:zip => '06002',
|
388
|
+
:country => 'US'
|
389
|
+
},
|
390
|
+
false)
|
391
|
+
|
392
|
+
assertions = {}
|
393
|
+
|
394
|
+
txn_nb = 0
|
395
|
+
|
396
|
+
txn_nb = authorize_assertions('34', 300.30, txn_nb, properties, assertions)
|
397
|
+
|
398
|
+
properties << build_property(:linked_transaction_type, :authorize)
|
399
|
+
|
400
|
+
void_assertions('34A', txn_nb, properties, assertions)
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'passes certification for order id 35' do
|
404
|
+
properties = build_pm_properties(nil,
|
405
|
+
{
|
406
|
+
:cc_number => '375001000000005',
|
407
|
+
:cc_first_name => 'Bob',
|
408
|
+
:cc_last_name => 'Black',
|
409
|
+
:cc_type => 'american_express',
|
410
|
+
:cc_exp_month => '04',
|
411
|
+
:cc_exp_year => '2016',
|
412
|
+
:cc_verification_value => '261',
|
413
|
+
:address1 => '4 Main St.',
|
414
|
+
:city => 'Laurel',
|
415
|
+
:state => 'MD',
|
416
|
+
:zip => '20708',
|
417
|
+
:country => 'US'
|
418
|
+
},
|
419
|
+
false)
|
420
|
+
|
421
|
+
assertions = {}
|
422
|
+
|
423
|
+
txn_nb = 0
|
424
|
+
|
425
|
+
txn_nb = authorize_assertions('35', 101.00, txn_nb, properties, assertions)
|
426
|
+
|
427
|
+
txn_nb = capture_assertions('35A', 50.50, txn_nb, properties, assertions)
|
428
|
+
|
429
|
+
assertions = {
|
430
|
+
:success => false,
|
431
|
+
:message => 'Reversal amount does not match Authorization amount'
|
432
|
+
}
|
433
|
+
|
434
|
+
properties << build_property(:linked_transaction_type, :authorize)
|
435
|
+
|
436
|
+
# ActiveMerchant doesn't pass an amount in the void call
|
437
|
+
#void_assertions('35B', txn_nb, properties, assertions)
|
438
|
+
end
|
439
|
+
|
440
|
+
it 'passes certification for order id 36' do
|
441
|
+
properties = build_pm_properties(nil,
|
442
|
+
{
|
443
|
+
:cc_number => '375000026600004',
|
444
|
+
:cc_type => 'american_express',
|
445
|
+
:cc_exp_month => '05',
|
446
|
+
:cc_exp_year => '2016'
|
447
|
+
},
|
448
|
+
false)
|
449
|
+
|
450
|
+
assertions = {}
|
451
|
+
|
452
|
+
txn_nb = 0
|
453
|
+
|
454
|
+
txn_nb = authorize_assertions('36', 205.00, txn_nb, properties, assertions)
|
455
|
+
|
456
|
+
assertions = {
|
457
|
+
:success => false,
|
458
|
+
:message => 'Reversal amount does not match Authorization amount'
|
459
|
+
}
|
460
|
+
|
461
|
+
properties << build_property(:linked_transaction_type, :authorize)
|
462
|
+
properties << build_property(:amount, 10000)
|
463
|
+
|
464
|
+
# ActiveMerchant doesn't pass an amount in the void call
|
465
|
+
#void_assertions('36A', txn_nb, properties, assertions)
|
466
|
+
end
|
467
|
+
|
468
|
+
# Conflicts with 52
|
469
|
+
xit 'passes certification for order id 50' do
|
470
|
+
properties = build_pm_properties(nil,
|
471
|
+
{
|
472
|
+
:cc_number => '4457119922390123'
|
473
|
+
},
|
474
|
+
false)
|
475
|
+
|
476
|
+
assertions = {
|
477
|
+
:success => false,
|
478
|
+
:message => 'Account number was successfully registered'
|
479
|
+
}
|
480
|
+
|
481
|
+
store_assertions('50', properties, assertions)
|
482
|
+
end
|
483
|
+
|
484
|
+
it 'passes certification for order id 51' do
|
485
|
+
properties = build_pm_properties(nil,
|
486
|
+
{
|
487
|
+
:cc_number => '4457119999999999'
|
488
|
+
},
|
489
|
+
false)
|
490
|
+
|
491
|
+
assertions = {
|
492
|
+
:success => false,
|
493
|
+
:message => 'Credit card number was invalid'
|
494
|
+
}
|
495
|
+
|
496
|
+
store_assertions('51', properties, assertions)
|
497
|
+
end
|
498
|
+
|
499
|
+
it 'passes certification for order id 52' do
|
500
|
+
properties = build_pm_properties(nil,
|
501
|
+
{
|
502
|
+
:cc_number => '4457119922390123'
|
503
|
+
},
|
504
|
+
false)
|
505
|
+
|
506
|
+
assertions = {
|
507
|
+
:success => false,
|
508
|
+
:message => 'Account number was previously registered'
|
509
|
+
}
|
510
|
+
|
511
|
+
store_assertions('52', properties, assertions)
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'passes certification for PayPage test case 14' do
|
515
|
+
properties = build_pm_properties(nil,
|
516
|
+
{
|
517
|
+
:cc_exp_month => '12',
|
518
|
+
:cc_exp_year => '2030',
|
519
|
+
:cc_verification_value => '987',
|
520
|
+
:paypageRegistrationId => 'cDZJcmd1VjNlYXNaSlRMTGpocVZQY1NWVXE4ZW5UTko4NU9KK3p1L1p1Vzg4YzVPQVlSUHNITG1JN2I0NzlyTg=='
|
521
|
+
},
|
522
|
+
false)
|
523
|
+
|
524
|
+
assertions = {
|
525
|
+
:success => false,
|
526
|
+
:message => 'Token was not found'
|
527
|
+
}
|
528
|
+
|
529
|
+
txn_nb = 0
|
530
|
+
|
531
|
+
authorize_assertions('14', 100.10, txn_nb, properties, assertions)
|
532
|
+
end
|
533
|
+
|
534
|
+
it 'passes certification for PayPage test case 15' do
|
535
|
+
properties = build_pm_properties(nil,
|
536
|
+
{
|
537
|
+
:cc_exp_month => '12',
|
538
|
+
:cc_exp_year => '2030',
|
539
|
+
:cc_verification_value => '987',
|
540
|
+
:paypageRegistrationId => 'RGFQNCt6U1d1M21SeVByVTM4dHlHb1FsVkUrSmpnWXhNY0o5UkMzRlZFanZiUHVnYjN1enJXbG1WSDF4aXlNcA=='
|
541
|
+
},
|
542
|
+
false)
|
543
|
+
|
544
|
+
assertions = {
|
545
|
+
:success => false,
|
546
|
+
:message => 'Expired paypage registration id'
|
547
|
+
}
|
548
|
+
|
549
|
+
txn_nb = 0
|
550
|
+
|
551
|
+
authorize_assertions('15', 100.10, txn_nb, properties, assertions)
|
552
|
+
end
|
553
|
+
|
554
|
+
private
|
555
|
+
|
556
|
+
def avs_assertions(order_id, txn_nb, properties, assertions = {})
|
557
|
+
authorize_assertions(order_id, 0, txn_nb, properties, assertions)
|
558
|
+
end
|
559
|
+
|
560
|
+
def auth_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
561
|
+
assertions = assertions.clone
|
562
|
+
|
563
|
+
# 1: authorize
|
564
|
+
txn_nb = authorize_assertions(order_id, amount, txn_nb, properties, assertions)
|
565
|
+
|
566
|
+
# No more AVS / CVV checks
|
567
|
+
assertions.delete(:avs)
|
568
|
+
assertions.delete(:cvv)
|
569
|
+
|
570
|
+
# 1A: capture
|
571
|
+
txn_nb = capture_assertions("#{order_id}A", amount, txn_nb, properties, assertions)
|
572
|
+
|
573
|
+
# 1B: credit
|
574
|
+
txn_nb = credit_assertions("#{order_id}B", amount, txn_nb, properties, assertions)
|
575
|
+
|
576
|
+
# 1C: void
|
577
|
+
void_assertions("#{order_id}C", txn_nb, properties, assertions)
|
578
|
+
end
|
579
|
+
|
580
|
+
def sale_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
581
|
+
assertions = assertions.clone
|
582
|
+
|
583
|
+
# 1: sale
|
584
|
+
txn_nb = purchase_assertions(order_id, amount, txn_nb, properties, assertions)
|
585
|
+
|
586
|
+
# No more AVS / CVV checks
|
587
|
+
assertions.delete(:avs)
|
588
|
+
assertions.delete(:cvv)
|
589
|
+
|
590
|
+
# 1B: credit
|
591
|
+
txn_nb = credit_assertions("#{order_id}B", amount, txn_nb, properties, assertions)
|
592
|
+
|
593
|
+
# 1C: void
|
594
|
+
void_assertions("#{order_id}C", txn_nb, properties, assertions)
|
595
|
+
end
|
596
|
+
|
597
|
+
def authorize_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
598
|
+
properties = properties.clone
|
599
|
+
properties << build_property(:order_id, order_id)
|
600
|
+
|
601
|
+
payment_response = @plugin.authorize_payment(@pm.kb_account_id,
|
602
|
+
@kb_payment.id,
|
603
|
+
@kb_payment.transactions[txn_nb].id,
|
604
|
+
@pm.kb_payment_method_id,
|
605
|
+
amount,
|
606
|
+
@currency,
|
607
|
+
properties,
|
608
|
+
@call_context)
|
609
|
+
common_checks(payment_response, assertions)
|
610
|
+
|
611
|
+
txn_nb + 1
|
612
|
+
end
|
613
|
+
|
614
|
+
def capture_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
615
|
+
properties = properties.clone
|
616
|
+
properties << build_property(:order_id, order_id)
|
617
|
+
|
618
|
+
payment_response = @plugin.capture_payment(@pm.kb_account_id,
|
619
|
+
@kb_payment.id,
|
620
|
+
@kb_payment.transactions[txn_nb].id,
|
621
|
+
@pm.kb_payment_method_id,
|
622
|
+
amount,
|
623
|
+
@currency,
|
624
|
+
properties,
|
625
|
+
@call_context)
|
626
|
+
common_checks(payment_response, assertions)
|
627
|
+
|
628
|
+
txn_nb + 1
|
629
|
+
end
|
630
|
+
|
631
|
+
def purchase_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
632
|
+
properties = properties.clone
|
633
|
+
properties << build_property(:order_id, order_id)
|
634
|
+
|
635
|
+
payment_response = @plugin.purchase_payment(@pm.kb_account_id,
|
636
|
+
@kb_payment.id,
|
637
|
+
@kb_payment.transactions[txn_nb].id,
|
638
|
+
@pm.kb_payment_method_id,
|
639
|
+
amount,
|
640
|
+
@currency,
|
641
|
+
properties,
|
642
|
+
@call_context)
|
643
|
+
common_checks(payment_response, assertions)
|
644
|
+
|
645
|
+
txn_nb + 1
|
646
|
+
end
|
647
|
+
|
648
|
+
def credit_assertions(order_id, amount, txn_nb, properties, assertions = {})
|
649
|
+
# TODO Unsupported by ActiveMerchant
|
650
|
+
return txn_nb + 1
|
651
|
+
|
652
|
+
properties = properties.clone
|
653
|
+
properties << build_property(:order_id, order_id)
|
654
|
+
|
655
|
+
payment_response = @plugin.credit_payment(@pm.kb_account_id,
|
656
|
+
@kb_payment.id,
|
657
|
+
@kb_payment.transactions[txn_nb].id,
|
658
|
+
@pm.kb_payment_method_id,
|
659
|
+
amount,
|
660
|
+
@currency,
|
661
|
+
properties,
|
662
|
+
@call_context)
|
663
|
+
common_checks(payment_response, assertions)
|
664
|
+
|
665
|
+
txn_nb + 1
|
666
|
+
end
|
667
|
+
|
668
|
+
def void_assertions(order_id, txn_nb, properties, assertions = {})
|
669
|
+
properties = properties.clone
|
670
|
+
properties << build_property(:order_id, order_id)
|
671
|
+
|
672
|
+
payment_response = @plugin.void_payment(@pm.kb_account_id,
|
673
|
+
@kb_payment.id,
|
674
|
+
@kb_payment.transactions[txn_nb].id,
|
675
|
+
@pm.kb_payment_method_id,
|
676
|
+
properties,
|
677
|
+
@call_context)
|
678
|
+
common_checks(payment_response, assertions)
|
679
|
+
|
680
|
+
txn_nb + 1
|
681
|
+
end
|
682
|
+
|
683
|
+
def common_checks(payment_response, assertions = {})
|
684
|
+
assertions[:success] = true if assertions[:success].nil?
|
685
|
+
payment_response.status.should eq(assertions[:success] ? :PROCESSED : :ERROR), payment_response.gateway_error
|
686
|
+
payment_response.gateway_error.should == (assertions[:message] || 'Approved')
|
687
|
+
check_property(payment_response.properties, 'avsResultCode', assertions[:avs]) if assertions[:avs]
|
688
|
+
check_property(payment_response.properties, 'cvvResultCode', assertions[:cvv]) if assertions[:cvv]
|
689
|
+
end
|
690
|
+
|
691
|
+
def check_property(properties, key, value)
|
692
|
+
(properties.find { |prop| prop.key == key }).value.should == value
|
693
|
+
end
|
694
|
+
|
695
|
+
def store_assertions(order_id, properties, assertions = {})
|
696
|
+
properties = properties.clone
|
697
|
+
properties << build_property(:order_id, order_id)
|
698
|
+
|
699
|
+
info = Killbill::Plugin::Model::PaymentMethodPlugin.new
|
700
|
+
info.properties = []
|
701
|
+
|
702
|
+
@plugin.add_payment_method(@pm.kb_account_id,
|
703
|
+
@pm.kb_payment_method_id,
|
704
|
+
info,
|
705
|
+
true,
|
706
|
+
properties,
|
707
|
+
@call_context)
|
708
|
+
rescue => e
|
709
|
+
e.message.should == assertions[:message]
|
710
|
+
ensure
|
711
|
+
::Killbill::Litle::LitleResponse.last.message.should == assertions[:message]
|
712
|
+
end
|
713
|
+
end
|