killbill-braintree_blue 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,54 +0,0 @@
1
- version = File.read(File.expand_path('../VERSION', __FILE__)).strip
2
-
3
- Gem::Specification.new do |s|
4
- s.name = 'killbill-braintree_blue'
5
- s.version = version
6
- s.summary = 'Plugin to use BraintreeBlue as a gateway.'
7
- s.description = 'Kill Bill payment plugin for BraintreeBlue.'
8
-
9
- s.required_ruby_version = '>= 1.9.3'
10
-
11
- s.license = 'Apache License (2.0)'
12
-
13
- s.author = 'Kill Bill core team'
14
- s.email = 'killbilling-users@googlegroups.com'
15
- s.homepage = 'http://killbill.io'
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.bindir = 'bin'
20
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
- s.require_paths = ['lib']
22
-
23
- s.rdoc_options << '--exclude' << '.'
24
-
25
- s.add_dependency 'killbill', '~> 8.0'
26
-
27
- s.add_dependency 'braintree', '~> 2.0'
28
-
29
- s.add_dependency 'sinatra', '~> 1.3.4'
30
- s.add_dependency 'thread_safe', '~> 0.3.4'
31
- s.add_dependency 'activerecord', '~> 4.1.0'
32
- if defined?(JRUBY_VERSION)
33
- s.add_dependency 'activerecord-bogacs', '~> 0.3'
34
- s.add_dependency 'activerecord-jdbc-adapter', '~> 1.3'
35
- # Required to avoid errors like java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
36
- s.add_dependency 'jruby-openssl', '~> 0.9.6'
37
- end
38
- s.add_dependency 'actionpack', '~> 4.1.0'
39
- s.add_dependency 'actionview', '~> 4.1.0'
40
- s.add_dependency 'activemerchant', '~> 1.55.0'
41
- s.add_dependency 'offsite_payments', '~> 2.1.0'
42
- s.add_dependency 'monetize', '~> 1.1.0'
43
- s.add_dependency 'money', '~> 6.5.1'
44
-
45
- s.add_development_dependency 'jbundler', '~> 0.9.2'
46
- s.add_development_dependency 'rake', '>= 10.0.0'
47
- s.add_development_dependency 'rspec', '~> 2.12.0'
48
- if defined?(JRUBY_VERSION)
49
- s.add_development_dependency 'jdbc-sqlite3', '~> 3.7'
50
- s.add_development_dependency 'jdbc-mariadb', '~> 1.1'
51
- else
52
- s.add_development_dependency 'sqlite3', '~> 1.3.7'
53
- end
54
- end
@@ -1,3 +0,0 @@
1
- mainClass=Killbill::BraintreeBlue::PaymentPlugin
2
- require=braintree_blue
3
- pluginType=PAYMENT
data/pom.xml DELETED
@@ -1,44 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!--
3
- ~ Copyright 2014-2015 The Billing Project, LLC
4
- ~
5
- ~ The Billing Project licenses this file to you under the Apache License, version 2.0
6
- ~ (the "License"); you may not use this file except in compliance with the
7
- ~ License. You may obtain a copy of the License at:
8
- ~
9
- ~ http://www.apache.org/licenses/LICENSE-2.0
10
- ~
11
- ~ Unless required by applicable law or agreed to in writing, software
12
- ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- ~ License for the specific language governing permissions and limitations
15
- ~ under the License.
16
- -->
17
-
18
- <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">
19
- <parent>
20
- <groupId>org.sonatype.oss</groupId>
21
- <artifactId>oss-parent</artifactId>
22
- <version>5</version>
23
- </parent>
24
- <modelVersion>4.0.0</modelVersion>
25
- <groupId>org.kill-bill.billing.plugin.ruby</groupId>
26
- <artifactId>braintree_blue-plugin</artifactId>
27
- <packaging>pom</packaging>
28
- <version>0.3.0</version>
29
- <name>braintree_blue-plugin</name>
30
- <url>http://github.com/killbill/killbill-braintree_blue-plugin</url>
31
- <description>Plugin for accessing BraintreeBlue as a payment gateway</description>
32
- <licenses>
33
- <license>
34
- <name>Apache License 2.0</name>
35
- <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
36
- <distribution>repo</distribution>
37
- </license>
38
- </licenses>
39
- <scm>
40
- <connection>scm:git:git://github.com/killbill/killbill-braintree_blue-plugin.git</connection>
41
- <url>https://github.com/killbill/killbill-braintree_blue-plugin/</url>
42
- <developerConnection>scm:git:git@github.com:killbill/killbill-braintree_blue-plugin.git</developerConnection>
43
- </scm>
44
- </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-braintree_blue-$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=braintree_blue-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::BraintreeBlue::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, 'braintree_blue.yml'), 'w+')
10
- file.write(<<-eos)
11
- :braintree_blue:
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::BraintreeBlue::PaymentPlugin, 'braintree_blue', 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
- =begin
32
- it 'should generate forms correctly' do
33
- kb_account_id = SecureRandom.uuid
34
- kb_tenant_id = SecureRandom.uuid
35
- context = @plugin.kb_apis.create_context(kb_tenant_id)
36
- fields = @plugin.hash_to_properties({
37
- :order_id => '1234',
38
- :amount => 10
39
- })
40
- form = @plugin.build_form_descriptor kb_account_id, fields, [], context
41
-
42
- form.kb_account_id.should == kb_account_id
43
- form.form_method.should == 'POST'
44
- form.form_url.should == 'https://braintree_blue.com'
45
-
46
- form_fields = @plugin.properties_to_hash(form.form_fields)
47
- end
48
-
49
- it 'should receive notifications correctly' do
50
- description = 'description'
51
-
52
- kb_tenant_id = SecureRandom.uuid
53
- context = @plugin.kb_apis.create_context(kb_tenant_id)
54
- properties = @plugin.hash_to_properties({ :description => description })
55
-
56
- notification = ""
57
- gw_notification = @plugin.process_notification notification, properties, context
58
- end
59
- =end
60
- end
@@ -1,85 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Killbill::BraintreeBlue::BraintreeBluePaymentMethod do
4
- before :all do
5
- Killbill::BraintreeBlue::BraintreeBluePaymentMethod.delete_all
6
- end
7
-
8
- it 'should search all fields' do
9
- kb_tenant_id = '77-88-99-00'
10
-
11
- do_search('foo', kb_tenant_id).size.should == 0
12
-
13
- pm = Killbill::BraintreeBlue::BraintreeBluePaymentMethod.create :kb_account_id => '11-22-33-44',
14
- :kb_payment_method_id => '55-66-77-88',
15
- :kb_tenant_id => kb_tenant_id,
16
- :braintree_customer_id => '123xka',
17
- :token => '38102343',
18
- :cc_first_name => 'ccFirstName',
19
- :cc_last_name => 'ccLastName',
20
- :cc_type => 'ccType',
21
- :cc_exp_month => 10,
22
- :cc_exp_year => 11,
23
- :cc_last_4 => 1234,
24
- :address1 => 'address1',
25
- :address2 => 'address2',
26
- :city => 'city',
27
- :state => 'state',
28
- :zip => 'zip',
29
- :country => 'country',
30
- :created_at => Time.now,
31
- :updated_at => Time.now
32
-
33
- do_search('foo', kb_tenant_id).size.should == 0
34
- do_search(pm.token, kb_tenant_id).size.should == 1
35
- do_search('ccType', kb_tenant_id).size.should == 1
36
- # Exact match only for cc_last_4
37
- do_search('123', kb_tenant_id).size.should == 0
38
- do_search('1234', kb_tenant_id).size.should == 1
39
- # Test partial match
40
- do_search('address', kb_tenant_id).size.should == 1
41
- do_search('Name', kb_tenant_id).size.should == 1
42
-
43
- pm2 = Killbill::BraintreeBlue::BraintreeBluePaymentMethod.create :kb_account_id => '22-33-44-55',
44
- :kb_payment_method_id => '66-77-88-99',
45
- :kb_tenant_id => kb_tenant_id,
46
- :braintree_customer_id => '123xka',
47
- :token => '49384029302',
48
- :cc_first_name => 'ccFirstName',
49
- :cc_last_name => 'ccLastName',
50
- :cc_type => 'ccType',
51
- :cc_exp_month => 10,
52
- :cc_exp_year => 11,
53
- :cc_last_4 => 1234,
54
- :address1 => 'address1',
55
- :address2 => 'address2',
56
- :city => 'city',
57
- :state => 'state',
58
- :zip => 'zip',
59
- :country => 'country',
60
- :created_at => Time.now,
61
- :updated_at => Time.now
62
-
63
- do_search('foo', kb_tenant_id).size.should == 0
64
- do_search(pm.token, kb_tenant_id).size.should == 1
65
- do_search(pm2.token, kb_tenant_id).size.should == 1
66
- do_search('ccType', kb_tenant_id).size.should == 2
67
- # Exact match only for cc_last_4
68
- do_search('123', kb_tenant_id).size.should == 0
69
- do_search('1234', kb_tenant_id).size.should == 2
70
- # Test partial match
71
- do_search('cc', kb_tenant_id).size.should == 2
72
- do_search('address', kb_tenant_id).size.should == 2
73
- do_search('Name', kb_tenant_id).size.should == 2
74
- end
75
-
76
- private
77
-
78
- def do_search(search_key, kb_tenant_id)
79
- pagination = Killbill::BraintreeBlue::BraintreeBluePaymentMethod.search(search_key, kb_tenant_id)
80
- pagination.current_offset.should == 0
81
- results = pagination.iterator.to_a
82
- pagination.total_nb_records.should == results.size
83
- results
84
- end
85
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Killbill::BraintreeBlue::BraintreeBlueResponse do
4
- before :all do
5
- Killbill::BraintreeBlue::BraintreeBlueResponse.delete_all
6
- end
7
-
8
- it 'should search all fields' do
9
- kb_account_id = '33-44-55-66'
10
- kb_tenant_id = '77-88-99-00'
11
-
12
- do_search('foo', kb_tenant_id).size.should == 0
13
-
14
- pm = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
15
- :kb_payment_id => '11-22-33-44',
16
- :kb_account_id => kb_account_id,
17
- :kb_tenant_id => kb_tenant_id,
18
- :authorization => 'aa-bb-cc-dd',
19
- :params_braintree_customer_id => '123456',
20
- :params_braintree_customer_credit_card_token => '38102343',
21
- :success => true,
22
- :created_at => Time.now,
23
- :updated_at => Time.now
24
- # Not successful
25
- ignored2 = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
26
- :kb_payment_id => pm.kb_payment_id,
27
- :kb_account_id => kb_account_id,
28
- :kb_tenant_id => kb_tenant_id,
29
- :authorization => pm.authorization,
30
- :params_braintree_customer_id => pm.params_braintree_customer_id,
31
- :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
32
- :success => false,
33
- :created_at => Time.now,
34
- :updated_at => Time.now
35
-
36
- do_search('foo', kb_tenant_id).size.should == 0
37
- do_search(pm.authorization, kb_tenant_id).size.should == 1
38
- do_search(pm.params_braintree_customer_id, kb_tenant_id).size.should == 1
39
- do_search(pm.params_braintree_customer_credit_card_token, kb_tenant_id).size.should == 1
40
-
41
- pm2 = Killbill::BraintreeBlue::BraintreeBlueResponse.create :api_call => 'charge',
42
- :kb_payment_id => '11-22-33-44',
43
- :kb_account_id => kb_account_id,
44
- :kb_tenant_id => kb_tenant_id,
45
- :authorization => 'AA-BB-CC-DD',
46
- :params_braintree_customer_id => '1234567',
47
- :params_braintree_customer_credit_card_token => pm.params_braintree_customer_credit_card_token,
48
- :success => true,
49
- :created_at => Time.now,
50
- :updated_at => Time.now
51
-
52
- do_search('foo', kb_tenant_id).size.should == 0
53
- do_search(pm.authorization, kb_tenant_id).size.should == 1
54
- do_search(pm.params_braintree_customer_id, kb_tenant_id).size.should == 1
55
- do_search(pm.params_braintree_customer_credit_card_token, kb_tenant_id).size.should == 2
56
- do_search(pm2.authorization, kb_tenant_id).size.should == 1
57
- do_search(pm2.params_braintree_customer_id, kb_tenant_id).size.should == 1
58
- do_search(pm2.params_braintree_customer_credit_card_token, kb_tenant_id).size.should == 2
59
- end
60
-
61
- private
62
-
63
- def do_search(search_key, kb_tenant_id)
64
- pagination = Killbill::BraintreeBlue::BraintreeBlueResponse.search(search_key, kb_tenant_id)
65
- pagination.current_offset.should == 0
66
- results = pagination.iterator.to_a
67
- pagination.total_nb_records.should == results.size
68
- results
69
- end
70
- end
@@ -1,206 +0,0 @@
1
- require 'spec_helper'
2
-
3
- ActiveMerchant::Billing::Base.mode = :test
4
-
5
- describe Killbill::BraintreeBlue::PaymentPlugin do
6
-
7
- include ::Killbill::Plugin::ActiveMerchant::RSpec
8
-
9
- before(:each) do
10
- ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.delete_all
11
- ::Killbill::BraintreeBlue::BraintreeBlueResponse.delete_all
12
- ::Killbill::BraintreeBlue::BraintreeBlueTransaction.delete_all
13
-
14
- @plugin = build_plugin(::Killbill::BraintreeBlue::PaymentPlugin, 'braintree_blue')
15
- @plugin.start_plugin
16
-
17
- @call_context = build_call_context
18
-
19
- @properties = []
20
- pm_overrides = {
21
- # ActiveMerchant wants zip to be a string
22
- :zip => '12345',
23
- :cc_verification_value => 123
24
- }
25
- @pm = create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, nil, @call_context.tenant_id, @properties, pm_overrides)
26
- @amount = BigDecimal.new('100')
27
- @currency = 'USD'
28
-
29
- kb_payment_id = SecureRandom.uuid
30
- 1.upto(6) do
31
- @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
32
- end
33
- end
34
-
35
- after(:each) do
36
- @plugin.stop_plugin
37
- end
38
-
39
- # See https://github.com/killbill/killbill-braintree-blue-plugin/issues/3
40
- it 'should be able to add multiple cards to the same customer' do
41
- kb_account_id = SecureRandom.uuid
42
- kb_tenant_id = @call_context.tenant_id
43
- ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should be_nil
44
-
45
- properties = []
46
- pm_overrides = {
47
- :zip => '12345',
48
- :cc_verification_value => 123
49
- }
50
- create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
51
- b_customer_id = ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id)
52
- b_customer_id.should_not be_nil
53
-
54
- # Add a second card on the same account (same Braintree customer)
55
- pm_overrides[:cc_number] = '4111111111111111'
56
- create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
57
- ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should == b_customer_id
58
-
59
- pms = @plugin.get_payment_methods(kb_account_id, false, properties, @call_context)
60
- pms.size.should == 2
61
-
62
- # Verify tokens are different, and don't match the Braintree customer id
63
- pm1 = @plugin.get_payment_method_detail(kb_account_id, pms[0].payment_method_id, properties, @call_context)
64
- pm2 = @plugin.get_payment_method_detail(kb_account_id, pms[1].payment_method_id, properties, @call_context)
65
- pm1.external_payment_method_id.should_not == pm2.external_payment_method_id
66
- pm1.external_payment_method_id.should_not == b_customer_id
67
- pm2.external_payment_method_id.should_not == b_customer_id
68
-
69
- # Add a third card on the same account (same Braintree customer)
70
- pm_overrides[:cc_number] = '5555555555554444'
71
- create_payment_method(::Killbill::BraintreeBlue::BraintreeBluePaymentMethod, kb_account_id, kb_tenant_id, properties, pm_overrides.dup)
72
- ::Killbill::BraintreeBlue::BraintreeBluePaymentMethod.braintree_customer_id_from_kb_account_id(kb_account_id, kb_tenant_id).should == b_customer_id
73
-
74
- pms = @plugin.get_payment_methods(kb_account_id, false, properties, @call_context)
75
- pms.size.should == 3
76
-
77
- # Verify tokens are different, and don't match the Braintree customer id
78
- pm1 = @plugin.get_payment_method_detail(kb_account_id, pms[0].payment_method_id, properties, @call_context)
79
- pm2 = @plugin.get_payment_method_detail(kb_account_id, pms[1].payment_method_id, properties, @call_context)
80
- pm3 = @plugin.get_payment_method_detail(kb_account_id, pms[2].payment_method_id, properties, @call_context)
81
- pm1.external_payment_method_id.should_not == pm2.external_payment_method_id
82
- pm1.external_payment_method_id.should_not == pm3.external_payment_method_id
83
- pm2.external_payment_method_id.should_not == pm3.external_payment_method_id
84
- pm1.external_payment_method_id.should_not == b_customer_id
85
- pm2.external_payment_method_id.should_not == b_customer_id
86
- pm3.external_payment_method_id.should_not == b_customer_id
87
- end
88
-
89
- it 'should be able to create a customer with a nonce' do
90
- kb_account_id = SecureRandom.uuid
91
- kb_payment_method_id = SecureRandom.uuid
92
-
93
- info = ::Killbill::Plugin::Model::PaymentMethodPlugin.new
94
- info.properties = []
95
- info.properties << build_property('token', 'ABCDEF')
96
- info.properties << build_property('cc_first_name', 'John')
97
- info.properties << build_property('cc_last_name', 'Doe')
98
-
99
- begin
100
- @plugin.add_payment_method(kb_account_id, kb_payment_method_id, info, true, [], @call_context)
101
- fail('it should not accept a random nonce')
102
- rescue => e
103
- # TODO Could we generate a valid nonce?
104
- e.message.starts_with?('Unknown or expired payment_method_nonce.').should be_true
105
- end
106
- end
107
-
108
- it 'should be able to charge a Credit Card directly' do
109
- properties = build_pm_properties(nil,
110
- {
111
- # ActiveMerchant wants zip to be a string
112
- :zip => '12345',
113
- :cc_verification_value => 123
114
- })
115
-
116
- # We created the payment method, hence the rows
117
- Killbill::BraintreeBlue::BraintreeBlueResponse.all.size.should == 1
118
- Killbill::BraintreeBlue::BraintreeBlueTransaction.all.size.should == 0
119
-
120
- payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
121
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
122
- payment_response.amount.should == @amount
123
- payment_response.transaction_type.should == :PURCHASE
124
-
125
- responses = Killbill::BraintreeBlue::BraintreeBlueResponse.all
126
- responses.size.should == 2
127
- responses[0].api_call.should == 'add_payment_method'
128
- responses[0].message.should == 'OK'
129
- responses[1].api_call.should == 'purchase'
130
- responses[1].message.should == '1000 Approved'
131
- transactions = Killbill::BraintreeBlue::BraintreeBlueTransaction.all
132
- transactions.size.should == 1
133
- transactions[0].api_call.should == 'purchase'
134
- end
135
-
136
- # TODO Settlement?
137
- xit 'should be able to charge and refund' do
138
- payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
139
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
140
- payment_response.amount.should == @amount
141
- payment_response.transaction_type.should == :PURCHASE
142
-
143
- # Try a full refund
144
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
145
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
146
- refund_response.amount.should == @amount
147
- refund_response.transaction_type.should == :REFUND
148
- end
149
-
150
- # TODO Settlement?
151
- xit 'should be able to auth, capture and refund' do
152
- payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
153
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
154
- payment_response.amount.should == @amount
155
- payment_response.transaction_type.should == :AUTHORIZE
156
-
157
- # Try multiple partial captures
158
- partial_capture_amount = BigDecimal.new('10')
159
- 1.upto(3) do |i|
160
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[i].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
161
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
162
- payment_response.amount.should == partial_capture_amount
163
- payment_response.transaction_type.should == :CAPTURE
164
- end
165
-
166
- # Try a partial refund
167
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[4].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
168
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
169
- refund_response.amount.should == partial_capture_amount
170
- refund_response.transaction_type.should == :REFUND
171
-
172
- # Try to capture again
173
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[5].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
174
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
175
- payment_response.amount.should == partial_capture_amount
176
- payment_response.transaction_type.should == :CAPTURE
177
- end
178
-
179
- it 'should be able to auth and void' do
180
- payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
181
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
182
- payment_response.amount.should == @amount
183
- payment_response.transaction_type.should == :AUTHORIZE
184
-
185
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @properties, @call_context)
186
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
187
- payment_response.transaction_type.should == :VOID
188
- end
189
-
190
- it 'should be able to auth, partial capture and void' do
191
- payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
192
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
193
- payment_response.amount.should == @amount
194
- payment_response.transaction_type.should == :AUTHORIZE
195
-
196
- partial_capture_amount = BigDecimal.new('10')
197
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
198
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
199
- payment_response.amount.should == partial_capture_amount
200
- payment_response.transaction_type.should == :CAPTURE
201
-
202
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[2].id, @pm.kb_payment_method_id, @properties, @call_context)
203
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
204
- payment_response.transaction_type.should == :VOID
205
- end
206
- end