killbill-stripe 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +107 -131
- data/.gitignore +0 -35
- data/.travis.yml +0 -41
- data/Gemfile +0 -5
- data/Gemfile.head +0 -5
- data/Gemfile.lock +0 -151
- data/Jarfile +0 -12
- data/Jarfile.lock +0 -66
- data/LICENSE +0 -201
- data/NEWS +0 -37
- data/README.md +0 -159
- data/Rakefile +0 -30
- data/VERSION +0 -1
- data/config.ru +0 -4
- data/db/ddl.sql +0 -124
- data/db/schema.rb +0 -126
- data/killbill-stripe.gemspec +0 -53
- data/killbill.properties +0 -3
- data/pom.xml +0 -44
- data/release.sh +0 -61
- data/spec/spec_helper.rb +0 -24
- data/spec/stripe/base_plugin_spec.rb +0 -141
- data/spec/stripe/remote/connect_spec.rb +0 -133
- data/spec/stripe/remote/integration_spec.rb +0 -193
- data/stripe.yml +0 -32
data/killbill-stripe.gemspec
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'killbill-stripe'
|
5
|
-
s.version = version
|
6
|
-
s.summary = 'Plugin to use Stripe as a gateway.'
|
7
|
-
s.description = 'Kill Bill payment plugin for Stripe.'
|
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 'sinatra', '~> 1.3.4'
|
28
|
-
s.add_dependency 'thread_safe', '~> 0.3.4'
|
29
|
-
s.add_dependency 'activerecord', '~> 4.1.0'
|
30
|
-
if defined?(JRUBY_VERSION)
|
31
|
-
s.add_dependency 'activerecord-bogacs', '~> 0.3'
|
32
|
-
s.add_dependency 'activerecord-jdbc-adapter', '~> 1.3', '< 1.5'
|
33
|
-
s.add_dependency 'jruby-openssl', '~> 0.9.7'
|
34
|
-
end
|
35
|
-
s.add_dependency 'actionpack', '~> 4.1.0'
|
36
|
-
s.add_dependency 'actionview', '~> 4.1.0'
|
37
|
-
# 1.56.0 and above requires Ruby 2.0
|
38
|
-
s.add_dependency 'activemerchant', '~> 1.55.0'
|
39
|
-
s.add_dependency 'offsite_payments', '~> 2.1.0'
|
40
|
-
s.add_dependency 'monetize', '~> 1.1.0'
|
41
|
-
s.add_dependency 'money', '~> 6.5.1'
|
42
|
-
|
43
|
-
s.add_development_dependency 'jbundler', '~> 0.9.2'
|
44
|
-
s.add_development_dependency 'rake', '>= 10.0.0'
|
45
|
-
s.add_development_dependency 'rspec', '~> 2.12.0'
|
46
|
-
if defined?(JRUBY_VERSION)
|
47
|
-
s.add_development_dependency 'jdbc-sqlite3', '~> 3.7'
|
48
|
-
s.add_development_dependency 'jdbc-mariadb', '~> 1.1'
|
49
|
-
s.add_development_dependency 'jdbc-postgres', '~> 9.4'
|
50
|
-
else
|
51
|
-
s.add_development_dependency 'sqlite3', '~> 1.3.7'
|
52
|
-
end
|
53
|
-
end
|
data/killbill.properties
DELETED
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>stripe-plugin</artifactId>
|
27
|
-
<packaging>pom</packaging>
|
28
|
-
<version>4.1.0</version>
|
29
|
-
<name>stripe-plugin</name>
|
30
|
-
<url>http://github.com/killbill/killbill-stripe-plugin</url>
|
31
|
-
<description>Plugin for accessing Stripe 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-stripe-plugin.git</connection>
|
41
|
-
<url>https://github.com/killbill/killbill-stripe-plugin/</url>
|
42
|
-
<developerConnection>scm:git:git@github.com:killbill/killbill-stripe-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-stripe-$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=stripe-plugin \
|
56
|
-
-Dversion=$VERSION \
|
57
|
-
-Dpackaging=tar.gz \
|
58
|
-
-DrepositoryId=$REPOSITORY_ID \
|
59
|
-
-Durl=$URL \
|
60
|
-
-Dfile=$ARTIFACT \
|
61
|
-
-DpomFile=pom.xml
|
data/spec/spec_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'stripe'
|
3
|
-
require 'killbill/helpers/active_merchant/killbill_spec_helper'
|
4
|
-
|
5
|
-
require 'logger'
|
6
|
-
|
7
|
-
require 'rspec'
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.color_enabled = true
|
11
|
-
config.tty = true
|
12
|
-
config.formatter = 'documentation'
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'active_record'
|
16
|
-
ActiveRecord::Base.establish_connection(
|
17
|
-
:adapter => 'sqlite3',
|
18
|
-
:database => 'test.db'
|
19
|
-
)
|
20
|
-
# For debugging
|
21
|
-
#ActiveRecord::Base.logger = Logger.new(STDOUT)
|
22
|
-
# Create the schema
|
23
|
-
require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
|
24
|
-
|
@@ -1,141 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Killbill::Stripe::PaymentPlugin do
|
4
|
-
|
5
|
-
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
6
|
-
|
7
|
-
let(:kb_account_id) do
|
8
|
-
SecureRandom.uuid
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:kb_tenant_id) do
|
12
|
-
SecureRandom.uuid
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:context) do
|
16
|
-
build_call_context(kb_tenant_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
Dir.mktmpdir do |dir|
|
21
|
-
file = File.new(File.join(dir, 'stripe.yml'), 'w+')
|
22
|
-
file.write(<<-eos)
|
23
|
-
:stripe:
|
24
|
-
:api_secret_key: 'j2lkb12'
|
25
|
-
# As defined by spec_helper.rb
|
26
|
-
:database:
|
27
|
-
:adapter: 'sqlite3'
|
28
|
-
:database: 'test.db'
|
29
|
-
eos
|
30
|
-
file.close
|
31
|
-
|
32
|
-
@plugin = build_plugin(::Killbill::Stripe::PaymentPlugin, 'stripe', File.dirname(file))
|
33
|
-
|
34
|
-
# Start the plugin here - since the config file will be deleted
|
35
|
-
@plugin.start_plugin
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should start and stop correctly' do
|
40
|
-
@plugin.stop_plugin
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should reset payment methods' do
|
44
|
-
@plugin.get_payment_methods(kb_account_id, false, [], context).size.should == 0
|
45
|
-
verify_pms kb_account_id, 0, context
|
46
|
-
|
47
|
-
# Create a pm with a kb_payment_method_id
|
48
|
-
Killbill::Stripe::StripePaymentMethod.create(:kb_account_id => kb_account_id,
|
49
|
-
:kb_tenant_id => kb_tenant_id,
|
50
|
-
:kb_payment_method_id => 'kb-1',
|
51
|
-
:token => 'stripe-1',
|
52
|
-
:created_at => Time.now.utc,
|
53
|
-
:updated_at => Time.now.utc)
|
54
|
-
verify_pms kb_account_id, 1, context
|
55
|
-
|
56
|
-
# Add some in KillBill and reset
|
57
|
-
payment_methods = []
|
58
|
-
# Random order... Shouldn't matter...
|
59
|
-
payment_methods << create_pm_info_plugin(kb_account_id, 'kb-3', false, 'stripe-3')
|
60
|
-
payment_methods << create_pm_info_plugin(kb_account_id, 'kb-2', false, 'stripe-2')
|
61
|
-
payment_methods << create_pm_info_plugin(kb_account_id, 'kb-4', false, 'stripe-4')
|
62
|
-
@plugin.reset_payment_methods kb_account_id, payment_methods, [], context
|
63
|
-
verify_pms kb_account_id, 4, context
|
64
|
-
|
65
|
-
# Add a payment method without a kb_payment_method_id
|
66
|
-
Killbill::Stripe::StripePaymentMethod.create(:kb_account_id => kb_account_id,
|
67
|
-
:kb_tenant_id => kb_tenant_id,
|
68
|
-
:token => 'stripe-5',
|
69
|
-
:created_at => Time.now.utc,
|
70
|
-
:updated_at => Time.now.utc)
|
71
|
-
@plugin.get_payment_methods(kb_account_id, false, nil, context).size.should == 5
|
72
|
-
|
73
|
-
# Verify we can match it
|
74
|
-
payment_methods << create_pm_info_plugin(kb_account_id, 'kb-5', false, 'stripe-5')
|
75
|
-
@plugin.reset_payment_methods kb_account_id, payment_methods, [], context
|
76
|
-
verify_pms kb_account_id, 5, context
|
77
|
-
|
78
|
-
@plugin.stop_plugin
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'processes notifications' do
|
82
|
-
notification =<<EOF
|
83
|
-
{
|
84
|
-
"id": "evt_1234",
|
85
|
-
"user_id": "acct_12QkqYGSOD4VcegJ",
|
86
|
-
"type": "account.updated",
|
87
|
-
"data": {
|
88
|
-
"object": {
|
89
|
-
"legal_entity": {
|
90
|
-
"verification": {
|
91
|
-
"status": "unverified"
|
92
|
-
}
|
93
|
-
},
|
94
|
-
"verification": {
|
95
|
-
"fields_needed": ["legal_entity.personal_id_number"],
|
96
|
-
"due_by": null,
|
97
|
-
"contacted": false
|
98
|
-
}
|
99
|
-
},
|
100
|
-
"previous_attributes": {
|
101
|
-
"legal_entity": {
|
102
|
-
"verification": {
|
103
|
-
"status": "pending"
|
104
|
-
}
|
105
|
-
},
|
106
|
-
"verification": {
|
107
|
-
"fields_needed": []
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
EOF
|
113
|
-
gw_notification = @plugin.process_notification(notification, {}, context)
|
114
|
-
gw_notification.status.should == 200
|
115
|
-
|
116
|
-
response = ::Killbill::Stripe::StripeResponse.last
|
117
|
-
response.params_id.should == 'evt_1234'
|
118
|
-
response.api_call.should == 'webhook.account.updated'
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
|
123
|
-
def verify_pms(kb_account_id, size, context)
|
124
|
-
pms = @plugin.get_payment_methods(kb_account_id, false, [], context)
|
125
|
-
pms.size.should == size
|
126
|
-
pms.each do |pm|
|
127
|
-
pm.account_id.should == kb_account_id
|
128
|
-
pm.is_default.should == false
|
129
|
-
pm.external_payment_method_id.should == 'stripe-' + pm.payment_method_id.split('-')[1]
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def create_pm_info_plugin(kb_account_id, kb_payment_method_id, is_default, external_payment_method_id)
|
134
|
-
pm_info_plugin = Killbill::Plugin::Model::PaymentMethodInfoPlugin.new
|
135
|
-
pm_info_plugin.account_id = kb_account_id
|
136
|
-
pm_info_plugin.payment_method_id = kb_payment_method_id
|
137
|
-
pm_info_plugin.is_default = is_default
|
138
|
-
pm_info_plugin.external_payment_method_id = external_payment_method_id
|
139
|
-
pm_info_plugin
|
140
|
-
end
|
141
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
ActiveMerchant::Billing::Base.mode = :test
|
4
|
-
|
5
|
-
describe Killbill::Stripe::PaymentPlugin do
|
6
|
-
|
7
|
-
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
8
|
-
|
9
|
-
let(:kb_account_id_for_contractor) do
|
10
|
-
kb_account_id = SecureRandom.uuid
|
11
|
-
create_kb_account(kb_account_id, plugin.kb_apis.proxied_services[:account_user_api])
|
12
|
-
kb_account_id
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:kb_account_id_for_customer) do
|
16
|
-
kb_account_id = SecureRandom.uuid
|
17
|
-
create_kb_account(kb_account_id, plugin.kb_apis.proxied_services[:account_user_api])
|
18
|
-
kb_account_id
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:kb_payment) do
|
22
|
-
payment = nil
|
23
|
-
kb_payment_id = SecureRandom.uuid
|
24
|
-
1.upto(2) do
|
25
|
-
payment = plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
|
26
|
-
end
|
27
|
-
payment
|
28
|
-
end
|
29
|
-
|
30
|
-
let(:kb_tenant_id) do
|
31
|
-
SecureRandom.uuid
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:call_context) do
|
35
|
-
build_call_context(kb_tenant_id)
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:plugin) do
|
39
|
-
plugin = build_plugin(::Killbill::Stripe::PaymentPlugin, 'stripe')
|
40
|
-
plugin.start_plugin
|
41
|
-
plugin
|
42
|
-
end
|
43
|
-
|
44
|
-
let(:private_plugin) do
|
45
|
-
::Killbill::Stripe::PrivatePaymentPlugin.new
|
46
|
-
end
|
47
|
-
|
48
|
-
before(:all) do
|
49
|
-
# Start the plugin to initialize caches, etc.
|
50
|
-
plugin.should_not be_nil
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'creates a managed account and transfers money' do
|
54
|
-
init_balance = get_balance
|
55
|
-
|
56
|
-
#
|
57
|
-
# Create managed Stripe account for contractor Jane Doe
|
58
|
-
#
|
59
|
-
|
60
|
-
account = {}
|
61
|
-
account[:legal_entity] = {}
|
62
|
-
account[:legal_entity][:type] = 'individual'
|
63
|
-
account[:legal_entity][:first_name] = 'Jane'
|
64
|
-
account[:legal_entity][:last_name] = 'Doe'
|
65
|
-
account[:legal_entity][:address] = {}
|
66
|
-
account[:legal_entity][:address][:city] = 'San Francisco'
|
67
|
-
account[:legal_entity][:dob] = {}
|
68
|
-
account[:legal_entity][:dob][:day] = 31
|
69
|
-
account[:legal_entity][:dob][:month] = 12
|
70
|
-
account[:legal_entity][:dob][:year] = 1969
|
71
|
-
account[:legal_entity][:ssn_last_4] = 1234
|
72
|
-
account[:tos_acceptance] = {}
|
73
|
-
account[:tos_acceptance][:date] = 1468778430
|
74
|
-
account[:tos_acceptance][:ip] = '8.8.8.8'
|
75
|
-
|
76
|
-
stripe_account = private_plugin.create_managed_account(kb_account_id_for_contractor, kb_tenant_id, account, {}).params
|
77
|
-
stripe_account['id'].should_not be_nil
|
78
|
-
stripe_account['keys'].should_not be_nil
|
79
|
-
stripe_account['managed'].should be_true
|
80
|
-
|
81
|
-
::Killbill::Stripe::StripeResponse.managed_stripe_account_id_from_kb_account_id(SecureRandom.uuid, kb_tenant_id).should be_nil
|
82
|
-
::Killbill::Stripe::StripeResponse.managed_stripe_account_id_from_kb_account_id(kb_account_id_for_contractor, nil).should be_nil
|
83
|
-
::Killbill::Stripe::StripeResponse.managed_stripe_account_id_from_kb_account_id(kb_account_id_for_contractor, kb_tenant_id).should == stripe_account['id']
|
84
|
-
|
85
|
-
check_balance(kb_account_id_for_contractor)
|
86
|
-
|
87
|
-
#
|
88
|
-
# Tokenize card and charge customer John Doe
|
89
|
-
#
|
90
|
-
|
91
|
-
pm = create_payment_method(::Killbill::Stripe::StripePaymentMethod, kb_account_id_for_customer, kb_tenant_id, [], {}, true, plugin)
|
92
|
-
|
93
|
-
props = []
|
94
|
-
props << build_property(:destination, kb_account_id_for_contractor)
|
95
|
-
props << build_property(:fees_amount, 200)
|
96
|
-
payment_response = plugin.purchase_payment(kb_account_id_for_customer, kb_payment.id, kb_payment.transactions[0].id, pm.kb_payment_method_id, 10, :USD, props, call_context)
|
97
|
-
|
98
|
-
plugin.logger.info "Useful links:
|
99
|
-
Contractor dashboard: https://dashboard.stripe.com/#{stripe_account['id']}/test/dashboard
|
100
|
-
Customer dashboard: https://dashboard.stripe.com/test/customers/#{::Killbill::Stripe::StripePaymentMethod.stripe_customer_id_from_kb_account_id(kb_account_id_for_customer, kb_tenant_id)}
|
101
|
-
Collected fees: https://dashboard.stripe.com/test/applications/fees"
|
102
|
-
|
103
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
104
|
-
payment_response.amount.should == 10
|
105
|
-
payment_response.transaction_type.should == :PURCHASE
|
106
|
-
|
107
|
-
check_balance(nil, init_balance + 141)
|
108
|
-
check_balance(kb_account_id_for_contractor, 800)
|
109
|
-
|
110
|
-
props = []
|
111
|
-
props << build_property(:reverse_transfer, 'true')
|
112
|
-
props << build_property(:refund_application_fee, 'true')
|
113
|
-
refund_response = plugin.refund_payment(kb_account_id_for_customer, payment_response.kb_payment_id, kb_payment.transactions[1].id, pm.kb_payment_method_id, 10, :USD, props, call_context)
|
114
|
-
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
115
|
-
refund_response.amount.should == 10
|
116
|
-
refund_response.transaction_type.should == :REFUND
|
117
|
-
|
118
|
-
check_balance(nil, init_balance)
|
119
|
-
check_balance(kb_account_id_for_contractor, 0)
|
120
|
-
end
|
121
|
-
|
122
|
-
private
|
123
|
-
|
124
|
-
def check_balance(kb_account_id = nil, amount = 0)
|
125
|
-
balance = private_plugin.get_balance(kb_account_id, kb_tenant_id)
|
126
|
-
balance.params['pending'].first['currency'].should == 'usd'
|
127
|
-
balance.params['pending'].first['amount'].should == amount
|
128
|
-
end
|
129
|
-
|
130
|
-
def get_balance
|
131
|
-
private_plugin.get_balance(nil, kb_tenant_id).params['pending'].first['amount']
|
132
|
-
end
|
133
|
-
end
|