killbill-litle 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/pom.xml DELETED
@@ -1,45 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!--
3
- ~ Copyright 2010-2013 Ning, Inc.
4
- ~ Copyright 2014-2015 The Billing Project, LLC
5
- ~
6
- ~ The Billing Project licenses this file to you under the Apache License, version 2.0
7
- ~ (the "License"); you may not use this file except in compliance with the
8
- ~ License. You may obtain a copy of the License at:
9
- ~
10
- ~ http://www.apache.org/licenses/LICENSE-2.0
11
- ~
12
- ~ Unless required by applicable law or agreed to in writing, software
13
- ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
- ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
- ~ License for the specific language governing permissions and limitations
16
- ~ under the License.
17
- -->
18
-
19
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20
- <parent>
21
- <groupId>org.sonatype.oss</groupId>
22
- <artifactId>oss-parent</artifactId>
23
- <version>5</version>
24
- </parent>
25
- <modelVersion>4.0.0</modelVersion>
26
- <groupId>org.kill-bill.billing.plugin.ruby</groupId>
27
- <artifactId>litle-plugin</artifactId>
28
- <packaging>pom</packaging>
29
- <version>4.0.0</version>
30
- <name>litle-plugin</name>
31
- <url>http://github.com/killbill/killbill-litle-plugin</url>
32
- <description>Plugin for accessing Litle as a payment gateway</description>
33
- <licenses>
34
- <license>
35
- <name>Apache License 2.0</name>
36
- <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
37
- <distribution>repo</distribution>
38
- </license>
39
- </licenses>
40
- <scm>
41
- <connection>scm:git:git://github.com/killbill/killbill-litle-plugin.git</connection>
42
- <url>https://github.com/killbill/killbill-litle-plugin/</url>
43
- <developerConnection>scm:git:git@github.com:killbill/killbill-litle-plugin.git</developerConnection>
44
- </scm>
45
- </project>
data/release.sh DELETED
@@ -1,61 +0,0 @@
1
- set -e
2
-
3
- BUNDLE=${BUNDLE-"bundle exec"}
4
- MVN=${MVN-"mvn"}
5
-
6
- if [ 'GNU' != "$(tar --help | grep GNU | head -1 | awk '{print $1}')" ]; then
7
- echo 'Unable to release: make sure to use GNU tar'
8
- exit 1
9
- fi
10
-
11
- if $(ruby -e'require "java"'); then
12
- # Good
13
- echo 'Detected JRuby'
14
- else
15
- echo 'Unable to release: make sure to use JRuby'
16
- exit 1
17
- fi
18
-
19
- VERSION=`grep -E '<version>([0-9]+\.[0-9]+\.[0-9]+)</version>' pom.xml | sed 's/[\t \n]*<version>\(.*\)<\/version>[\t \n]*/\1/'`
20
- if [[ -z "$NO_RELEASE" && "$VERSION" != "$(cat $PWD/VERSION)" ]]; then
21
- echo 'Unable to release: make sure the versions in pom.xml and VERSION match'
22
- exit 1
23
- fi
24
-
25
- echo 'Cleaning up'
26
- $BUNDLE rake killbill:clean
27
-
28
- echo 'Building gem'
29
- $BUNDLE rake build
30
-
31
- if [[ -z "$NO_RELEASE" ]]; then
32
- echo 'Pushing the gem to Rubygems'
33
- $BUNDLE rake release
34
- fi
35
-
36
- echo 'Building artifact'
37
- $BUNDLE rake killbill:package
38
-
39
- ARTIFACT="$PWD/pkg/killbill-litle-$VERSION.tar.gz"
40
- echo "Pushing $ARTIFACT to Maven Central"
41
-
42
- if [[ -z "$NO_RELEASE" ]]; then
43
- GOAL=gpg:sign-and-deploy-file
44
- REPOSITORY_ID=ossrh-releases
45
- URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/
46
- else
47
- GOAL=deploy:deploy-file
48
- REPOSITORY_ID=sonatype-nexus-snapshots
49
- URL=https://oss.sonatype.org/content/repositories/snapshots/
50
- VERSION="$VERSION-SNAPSHOT"
51
- fi
52
-
53
- $MVN $GOAL \
54
- -DgroupId=org.kill-bill.billing.plugin.ruby \
55
- -DartifactId=litle-plugin \
56
- -Dversion=$VERSION \
57
- -Dpackaging=tar.gz \
58
- -DrepositoryId=$REPOSITORY_ID \
59
- -Durl=$URL \
60
- -Dfile=$ARTIFACT \
61
- -DpomFile=pom.xml
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Killbill::Litle::PaymentPlugin do
4
-
5
- include ::Killbill::Plugin::ActiveMerchant::RSpec
6
-
7
- before(:each) do
8
- Dir.mktmpdir do |dir|
9
- file = File.new(File.join(dir, 'litle.yml'), 'w+')
10
- file.write(<<-eos)
11
- :litle:
12
- :test: true
13
- # As defined by spec_helper.rb
14
- :database:
15
- :adapter: 'sqlite3'
16
- :database: 'test.db'
17
- eos
18
- file.close
19
-
20
- @plugin = build_plugin(::Killbill::Litle::PaymentPlugin, 'litle', File.dirname(file))
21
-
22
- # Start the plugin here - since the config file will be deleted
23
- @plugin.start_plugin
24
- end
25
- end
26
-
27
- it 'should start and stop correctly' do
28
- @plugin.stop_plugin
29
- end
30
-
31
- # No offsite payments integration
32
-
33
- #xit 'should generate forms correctly' do
34
- # kb_account_id = SecureRandom.uuid
35
- # kb_tenant_id = SecureRandom.uuid
36
- # context = @plugin.kb_apis.create_context(kb_tenant_id)
37
- # fields = @plugin.hash_to_properties({
38
- # :order_id => '1234',
39
- # :amount => 10
40
- # })
41
- # form = @plugin.build_form_descriptor kb_account_id, fields, [], context
42
- #
43
- # form.kb_account_id.should == kb_account_id
44
- # form.form_method.should == 'POST'
45
- # form.form_url.should == 'https://litle.com'
46
- #
47
- # form_fields = @plugin.properties_to_hash(form.form_fields)
48
- #end
49
-
50
- #xit 'should receive notifications correctly' do
51
- # description = 'description'
52
- #
53
- # kb_tenant_id = SecureRandom.uuid
54
- # context = @plugin.kb_apis.create_context(kb_tenant_id)
55
- # properties = @plugin.hash_to_properties({ :description => description })
56
- #
57
- # notification = ""
58
- # gw_notification = @plugin.process_notification notification, properties, context
59
- #end
60
- end
@@ -1,713 +0,0 @@
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