killbill-paypal-express 5.0.4 → 5.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +2 -36
- data/.gitignore +0 -35
- data/.travis.yml +0 -41
- data/Gemfile +0 -3
- data/Gemfile.head +0 -5
- data/Gemfile.lock +0 -160
- data/Jarfile +0 -12
- data/Jarfile.lock +0 -66
- data/LICENSE +0 -201
- data/NEWS +0 -120
- data/README.md +0 -265
- data/Rakefile +0 -30
- data/VERSION +0 -1
- data/config.ru +0 -4
- data/db/ddl.sql +0 -120
- data/db/migrate/20160326090325_add_indexes.rb +0 -7
- data/db/migrate/20160828090851_enlarge_message.rb +0 -11
- data/db/migrate/20161209090000_add_indexes.rb +0 -7
- data/db/schema.rb +0 -122
- data/killbill-paypal-express.gemspec +0 -53
- data/killbill.properties +0 -3
- data/paypal_express.yml +0 -30
- data/pom.xml +0 -45
- data/release.sh +0 -61
- data/spec/fixtures/DoExpressCheckoutPayment-duplicate.xml +0 -54
- data/spec/fixtures/GetExpressCheckoutDetails-success.xml +0 -102
- data/spec/paypal_express/base_plugin_spec.rb +0 -133
- data/spec/paypal_express/remote/baid_spec.rb +0 -305
- data/spec/paypal_express/remote/baid_spec_helpers.rb +0 -56
- data/spec/paypal_express/remote/browser_helpers.rb +0 -72
- data/spec/paypal_express/remote/build_plugin_helpers.rb +0 -33
- data/spec/paypal_express/remote/hpp_spec.rb +0 -502
- data/spec/paypal_express/remote/hpp_spec_helpers.rb +0 -365
- data/spec/paypal_express/response_spec.rb +0 -79
- data/spec/spec_helper.rb +0 -67
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Killbill::PaypalExpress::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, 'paypal_express.yml'), 'w+')
|
10
|
-
file.write(<<-eos)
|
11
|
-
:paypal_express:
|
12
|
-
:signature: 'signature'
|
13
|
-
:login: 'login'
|
14
|
-
:password: 'password'
|
15
|
-
:test: true
|
16
|
-
# As defined by spec_helper.rb
|
17
|
-
:database:
|
18
|
-
:adapter: 'sqlite3'
|
19
|
-
:database: 'test.db'
|
20
|
-
eos
|
21
|
-
file.close
|
22
|
-
|
23
|
-
@plugin = build_plugin(::Killbill::PaypalExpress::PaymentPlugin, 'paypal_express', File.dirname(file))
|
24
|
-
|
25
|
-
# Start the plugin here - since the config file will be deleted
|
26
|
-
@plugin.start_plugin
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should start and stop correctly' do
|
31
|
-
@plugin.stop_plugin
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should receive notifications correctly' do
|
35
|
-
description = 'description'
|
36
|
-
|
37
|
-
kb_tenant_id = SecureRandom.uuid
|
38
|
-
context = @plugin.kb_apis.create_context(kb_tenant_id)
|
39
|
-
properties = @plugin.hash_to_properties({ :description => description })
|
40
|
-
|
41
|
-
notification = ''
|
42
|
-
gw_notification = @plugin.process_notification notification, properties, context
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should correctly add and filter optional parameters' do
|
46
|
-
# Basic option test
|
47
|
-
options = { :amount => 9900,
|
48
|
-
:some_property => true}
|
49
|
-
amount = 99.99
|
50
|
-
amount_in_cents = 9999
|
51
|
-
property_hash = { :noShipping => true,
|
52
|
-
:max_amount => amount
|
53
|
-
}
|
54
|
-
@plugin.send(:add_optional_parameters, options, property_hash, 'USD')
|
55
|
-
expected_options = { :amount => 9900,
|
56
|
-
:some_property => true,
|
57
|
-
:no_shipping => true,
|
58
|
-
:max_amount => amount_in_cents
|
59
|
-
}
|
60
|
-
options.should == expected_options
|
61
|
-
|
62
|
-
# Test with correct option format and unwanted property, e.g., fakeKey and unlimited
|
63
|
-
options = { :amount => 9900,
|
64
|
-
:some_property => true}
|
65
|
-
amount = 99.99
|
66
|
-
amount_in_cents = 9999
|
67
|
-
property_hash = { :noShipping => true,
|
68
|
-
:max_amount => amount,
|
69
|
-
:subtotal => amount,
|
70
|
-
:shipping => amount,
|
71
|
-
:handling => amount,
|
72
|
-
:tax => amount,
|
73
|
-
:fakeKey => 'unlimited',
|
74
|
-
:insuranceTotal => amount,
|
75
|
-
:shipping_discount => amount,
|
76
|
-
:shipping_options => [{:default => false, :name => 'jack', :amount => amount, :unlimited => true}].to_json,
|
77
|
-
:items => [{:name => 'john', :number => 111, :quantity => 12, :amount => amount, :description => 'jacket', :url => 'test', :category => 'unknown', :unlimited => true}].to_json,
|
78
|
-
:shipping_address => {:name => 'john', :address1 => '111', :address2 => '12', :city => 'palo alto', :state => 'ca', :country => 'jacket', :phone => 'test', :zip => 'unknown', :family => 'unknown'}.to_json,
|
79
|
-
:address => {:name => 'john', :address1 => '111', :address2 => '12', :city => 'palo alto', :state => 'ca', :country => 'jacket', :phone => 'test', :zip => 'unknown', :family => 'unknown'}.to_json,
|
80
|
-
:funding_sources => {:source => 'unknown'}.to_json
|
81
|
-
}
|
82
|
-
@plugin.send(:add_optional_parameters, options, property_hash, 'USD')
|
83
|
-
expected_options = { :amount => 9900,
|
84
|
-
:some_property => true,
|
85
|
-
:no_shipping => true,
|
86
|
-
:max_amount => amount_in_cents,
|
87
|
-
:subtotal => amount_in_cents,
|
88
|
-
:shipping => amount_in_cents,
|
89
|
-
:handling => amount_in_cents,
|
90
|
-
:tax => amount_in_cents,
|
91
|
-
:insurance_total => amount_in_cents,
|
92
|
-
:shipping_discount => amount_in_cents,
|
93
|
-
:shipping_options => [{:default => false, :name => 'jack', :amount => amount_in_cents}],
|
94
|
-
:items => [{:name => 'john', :number => 111, :quantity => 12, :amount => amount_in_cents, :description => 'jacket', :url => 'test', :category => 'unknown'}],
|
95
|
-
:shipping_address => {:name => 'john', :address1 => '111', :address2 => '12', :state => 'ca', :city => 'palo alto', :country => 'jacket', :phone => 'test', :zip => 'unknown'},
|
96
|
-
:address => {:name => 'john', :address1 => '111', :address2 => '12', :state => 'ca', :city => 'palo alto', :country => 'jacket', :phone => 'test', :zip => 'unknown'},
|
97
|
-
:funding_sources => {:source => 'unknown'}
|
98
|
-
}
|
99
|
-
options.should == expected_options
|
100
|
-
|
101
|
-
# Test with incorrect option format and invalid json format
|
102
|
-
options = {}
|
103
|
-
property_hash = { :no_shipping => true,
|
104
|
-
:max_amount => amount,
|
105
|
-
:subtotal => amount,
|
106
|
-
:shipping => amount,
|
107
|
-
:handling => amount,
|
108
|
-
:tax => amount,
|
109
|
-
:fakeKey => 'unlimited',
|
110
|
-
:insurance_total => amount,
|
111
|
-
:shipping_discount => amount,
|
112
|
-
:shipping_options => "{\"default\":\"false\", [name]:\"jack\", \"amount\":12}",
|
113
|
-
:items => {:name => 'john', :number => 111, :quantity => 12, :amount => amount, :description => 'jacket', :url => 'test', :category => 'unknown', :unlimited => true}.to_json,
|
114
|
-
:shipping_address => [{:name => 'john', :address1 => '111', :address2 => '12', :city => 'amount', :country => 'jacket', :phone => 'test', :zip => 'unknown'}].to_json,
|
115
|
-
:address => [{:name => 'john', :address1 => '111', :address2 => '12', :city => 'amount', :country => 'jacket', :phone => 'test', :zip => 'unknown'}].to_json
|
116
|
-
}
|
117
|
-
@plugin.send(:add_optional_parameters, options, property_hash, 'USD')
|
118
|
-
expected_options = { :no_shipping => true,
|
119
|
-
:max_amount => amount_in_cents,
|
120
|
-
:subtotal => amount_in_cents,
|
121
|
-
:shipping => amount_in_cents,
|
122
|
-
:handling => amount_in_cents,
|
123
|
-
:tax => amount_in_cents,
|
124
|
-
:insurance_total => amount_in_cents,
|
125
|
-
:shipping_discount => amount_in_cents,
|
126
|
-
:items => nil,
|
127
|
-
:shipping_options => nil,
|
128
|
-
:shipping_address => nil,
|
129
|
-
:address => nil
|
130
|
-
}
|
131
|
-
options.should == expected_options
|
132
|
-
end
|
133
|
-
end
|
@@ -1,305 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'build_plugin_helpers'
|
3
|
-
require_relative 'baid_spec_helpers'
|
4
|
-
|
5
|
-
ActiveMerchant::Billing::Base.mode = :test
|
6
|
-
|
7
|
-
shared_examples 'baid_spec_common' do
|
8
|
-
before(:each) do
|
9
|
-
::Killbill::PaypalExpress::PaypalExpressTransaction.delete_all
|
10
|
-
kb_payment_id = SecureRandom.uuid
|
11
|
-
1.upto(6) do
|
12
|
-
@kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should be able to charge and refund' do
|
17
|
-
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)
|
18
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
19
|
-
payment_response.amount.should == @amount
|
20
|
-
payment_response.transaction_type.should == :PURCHASE
|
21
|
-
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
22
|
-
payer_id.should_not be_nil
|
23
|
-
|
24
|
-
validate_details_for(@kb_payment.id, :PURCHASE, payer_id)
|
25
|
-
# Verify GET API
|
26
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
27
|
-
payment_infos.size.should == 1
|
28
|
-
# purchase
|
29
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
30
|
-
payment_infos[0].transaction_type.should == :PURCHASE
|
31
|
-
payment_infos[0].amount.should == @amount
|
32
|
-
payment_infos[0].currency.should == @currency
|
33
|
-
payment_infos[0].status.should == :PROCESSED
|
34
|
-
payment_infos[0].gateway_error.should == 'Success'
|
35
|
-
payment_infos[0].gateway_error_code.should be_nil
|
36
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
37
|
-
find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
|
38
|
-
|
39
|
-
# Try a full refund
|
40
|
-
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)
|
41
|
-
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
42
|
-
refund_response.amount.should == @amount
|
43
|
-
refund_response.transaction_type.should == :REFUND
|
44
|
-
|
45
|
-
# Verify GET API
|
46
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
47
|
-
payment_infos.size.should == 2
|
48
|
-
# purchase
|
49
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
50
|
-
payment_infos[0].transaction_type.should == :PURCHASE
|
51
|
-
payment_infos[0].amount.should == @amount
|
52
|
-
payment_infos[0].currency.should == @currency
|
53
|
-
payment_infos[0].status.should == :PROCESSED
|
54
|
-
payment_infos[0].gateway_error.should == 'Success'
|
55
|
-
payment_infos[0].gateway_error_code.should be_nil
|
56
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
57
|
-
# refund
|
58
|
-
payment_infos[1].kb_payment_id.should == @kb_payment.id
|
59
|
-
payment_infos[1].transaction_type.should == :REFUND
|
60
|
-
payment_infos[1].amount.should == @amount
|
61
|
-
payment_infos[1].currency.should == @currency
|
62
|
-
payment_infos[1].status.should == :PROCESSED
|
63
|
-
payment_infos[1].gateway_error.should == 'Success'
|
64
|
-
payment_infos[1].gateway_error_code.should be_nil
|
65
|
-
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should be able to auth, capture and refund' do
|
69
|
-
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)
|
70
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
71
|
-
payment_response.amount.should == @amount
|
72
|
-
payment_response.transaction_type.should == :AUTHORIZE
|
73
|
-
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
74
|
-
payer_id.should_not be_nil
|
75
|
-
|
76
|
-
validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
|
77
|
-
# Verify GET API
|
78
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
79
|
-
payment_infos.size.should == 1
|
80
|
-
# purchase
|
81
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
82
|
-
payment_infos[0].transaction_type.should == :AUTHORIZE
|
83
|
-
payment_infos[0].amount.should == @amount
|
84
|
-
payment_infos[0].currency.should == @currency
|
85
|
-
payment_infos[0].status.should == :PROCESSED
|
86
|
-
payment_infos[0].gateway_error.should == 'Success'
|
87
|
-
payment_infos[0].gateway_error_code.should be_nil
|
88
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
89
|
-
find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
|
90
|
-
|
91
|
-
# Try multiple partial captures
|
92
|
-
partial_capture_amount = BigDecimal.new('10')
|
93
|
-
1.upto(3) do |i|
|
94
|
-
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)
|
95
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
96
|
-
payment_response.amount.should == partial_capture_amount
|
97
|
-
payment_response.transaction_type.should == :CAPTURE
|
98
|
-
|
99
|
-
# Verify GET API
|
100
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
101
|
-
payment_infos.size.should == i + 1
|
102
|
-
payment_infos[i].kb_payment_id.should == @kb_payment.id
|
103
|
-
payment_infos[i].transaction_type.should == :CAPTURE
|
104
|
-
payment_infos[i].amount.should == partial_capture_amount
|
105
|
-
payment_infos[i].currency.should == @currency
|
106
|
-
payment_infos[i].status.should == :PROCESSED
|
107
|
-
payment_infos[i].gateway_error.should == 'Success'
|
108
|
-
payment_infos[i].gateway_error_code.should be_nil
|
109
|
-
find_value_from_properties(payment_infos[i].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
110
|
-
end
|
111
|
-
|
112
|
-
# Try a partial refund
|
113
|
-
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)
|
114
|
-
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
115
|
-
refund_response.amount.should == partial_capture_amount
|
116
|
-
refund_response.transaction_type.should == :REFUND
|
117
|
-
|
118
|
-
# Verify GET API
|
119
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
120
|
-
payment_infos.size.should == 5
|
121
|
-
payment_infos[4].kb_payment_id.should == @kb_payment.id
|
122
|
-
payment_infos[4].transaction_type.should == :REFUND
|
123
|
-
payment_infos[4].amount.should == partial_capture_amount
|
124
|
-
payment_infos[4].currency.should == @currency
|
125
|
-
payment_infos[4].status.should == :PROCESSED
|
126
|
-
payment_infos[4].gateway_error.should == 'Success'
|
127
|
-
payment_infos[4].gateway_error_code.should be_nil
|
128
|
-
find_value_from_properties(payment_infos[4].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
129
|
-
|
130
|
-
# Try to capture again
|
131
|
-
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)
|
132
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
133
|
-
payment_response.amount.should == partial_capture_amount
|
134
|
-
payment_response.transaction_type.should == :CAPTURE
|
135
|
-
|
136
|
-
# Verify GET API
|
137
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
138
|
-
payment_infos.size.should == 6
|
139
|
-
payment_infos[5].kb_payment_id.should == @kb_payment.id
|
140
|
-
payment_infos[5].transaction_type.should == :CAPTURE
|
141
|
-
payment_infos[5].amount.should == partial_capture_amount
|
142
|
-
payment_infos[5].currency.should == @currency
|
143
|
-
payment_infos[5].status.should == :PROCESSED
|
144
|
-
payment_infos[5].gateway_error.should == 'Success'
|
145
|
-
payment_infos[5].gateway_error_code.should be_nil
|
146
|
-
find_value_from_properties(payment_infos[5].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'should be able to auth and void' do
|
150
|
-
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)
|
151
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
152
|
-
payment_response.amount.should == @amount
|
153
|
-
payment_response.transaction_type.should == :AUTHORIZE
|
154
|
-
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
155
|
-
payer_id.should_not be_nil
|
156
|
-
|
157
|
-
validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
|
158
|
-
# Verify GET API
|
159
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
160
|
-
payment_infos.size.should == 1
|
161
|
-
# authorize
|
162
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
163
|
-
payment_infos[0].transaction_type.should == :AUTHORIZE
|
164
|
-
payment_infos[0].amount.should == @amount
|
165
|
-
payment_infos[0].currency.should == @currency
|
166
|
-
payment_infos[0].status.should == :PROCESSED
|
167
|
-
payment_infos[0].gateway_error.should == 'Success'
|
168
|
-
payment_infos[0].gateway_error_code.should be_nil
|
169
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
170
|
-
|
171
|
-
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)
|
172
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
173
|
-
payment_response.transaction_type.should == :VOID
|
174
|
-
|
175
|
-
# Verify GET API
|
176
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
177
|
-
payment_infos.size.should == 2
|
178
|
-
# authorize
|
179
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
180
|
-
payment_infos[0].transaction_type.should == :AUTHORIZE
|
181
|
-
payment_infos[0].amount.should == @amount
|
182
|
-
payment_infos[0].currency.should == @currency
|
183
|
-
payment_infos[0].status.should == :PROCESSED
|
184
|
-
payment_infos[0].gateway_error.should == 'Success'
|
185
|
-
payment_infos[0].gateway_error_code.should be_nil
|
186
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
187
|
-
# void
|
188
|
-
payment_infos[1].kb_payment_id.should == @kb_payment.id
|
189
|
-
payment_infos[1].transaction_type.should == :VOID
|
190
|
-
payment_infos[1].amount.should be_nil
|
191
|
-
payment_infos[1].currency.should be_nil
|
192
|
-
payment_infos[1].status.should == :PROCESSED
|
193
|
-
payment_infos[1].gateway_error.should == 'Success'
|
194
|
-
payment_infos[1].gateway_error_code.should be_nil
|
195
|
-
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'should be able to auth, partial capture and void' do
|
199
|
-
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)
|
200
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
201
|
-
payment_response.amount.should == @amount
|
202
|
-
payment_response.transaction_type.should == :AUTHORIZE
|
203
|
-
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
204
|
-
payer_id.should_not be_nil
|
205
|
-
|
206
|
-
validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
|
207
|
-
# Verify GET API
|
208
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
209
|
-
payment_infos.size.should == 1
|
210
|
-
# authorize
|
211
|
-
payment_infos[0].kb_payment_id.should == @kb_payment.id
|
212
|
-
payment_infos[0].transaction_type.should == :AUTHORIZE
|
213
|
-
payment_infos[0].amount.should == @amount
|
214
|
-
payment_infos[0].currency.should == @currency
|
215
|
-
payment_infos[0].status.should == :PROCESSED
|
216
|
-
payment_infos[0].gateway_error.should == 'Success'
|
217
|
-
payment_infos[0].gateway_error_code.should be_nil
|
218
|
-
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
219
|
-
|
220
|
-
partial_capture_amount = BigDecimal.new('10')
|
221
|
-
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)
|
222
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
223
|
-
payment_response.amount.should == partial_capture_amount
|
224
|
-
payment_response.transaction_type.should == :CAPTURE
|
225
|
-
|
226
|
-
# Verify GET API
|
227
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
228
|
-
payment_infos.size.should == 2
|
229
|
-
payment_infos[1].kb_payment_id.should == @kb_payment.id
|
230
|
-
payment_infos[1].transaction_type.should == :CAPTURE
|
231
|
-
payment_infos[1].amount.should == partial_capture_amount
|
232
|
-
payment_infos[1].currency.should == @currency
|
233
|
-
payment_infos[1].status.should == :PROCESSED
|
234
|
-
payment_infos[1].gateway_error.should == 'Success'
|
235
|
-
payment_infos[1].gateway_error_code.should be_nil
|
236
|
-
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
237
|
-
|
238
|
-
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)
|
239
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
240
|
-
payment_response.transaction_type.should == :VOID
|
241
|
-
|
242
|
-
# Verify GET API
|
243
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
|
244
|
-
payment_infos.size.should == 3
|
245
|
-
payment_infos[2].kb_payment_id.should == @kb_payment.id
|
246
|
-
payment_infos[2].transaction_type.should == :VOID
|
247
|
-
payment_infos[2].amount.should be_nil
|
248
|
-
payment_infos[2].currency.should be_nil
|
249
|
-
payment_infos[2].status.should == :PROCESSED
|
250
|
-
payment_infos[2].gateway_error.should == 'Success'
|
251
|
-
payment_infos[2].gateway_error_code.should be_nil
|
252
|
-
find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == @payment_processor_account_id
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'should generate forms correctly' do
|
256
|
-
context = @plugin.kb_apis.create_context(@call_context.tenant_id)
|
257
|
-
fields = @plugin.hash_to_properties(
|
258
|
-
:order_id => '1234',
|
259
|
-
:amount => 12
|
260
|
-
)
|
261
|
-
|
262
|
-
properties = @plugin.hash_to_properties(
|
263
|
-
:create_pending_payment => false
|
264
|
-
)
|
265
|
-
|
266
|
-
form = @plugin.build_form_descriptor(@pm.kb_account_id, fields, properties, context)
|
267
|
-
|
268
|
-
form.kb_account_id.should == @pm.kb_account_id
|
269
|
-
form.form_method.should == 'GET'
|
270
|
-
form.form_url.should start_with('https://www.sandbox.paypal.com/cgi-bin/webscr')
|
271
|
-
end
|
272
|
-
|
273
|
-
end
|
274
|
-
|
275
|
-
describe Killbill::PaypalExpress::PaymentPlugin do
|
276
|
-
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
277
|
-
include ::Killbill::PaypalExpress::BuildPluginHelpers
|
278
|
-
include ::Killbill::PaypalExpress::BaidSpecHelpers
|
279
|
-
|
280
|
-
context 'baid test with a single account' do
|
281
|
-
# Share the BAID
|
282
|
-
before(:all) do
|
283
|
-
# delete once here because we need to keep the initial response for later tests to find the payment processor account id
|
284
|
-
::Killbill::PaypalExpress::PaypalExpressResponse.delete_all
|
285
|
-
@payment_processor_account_id = 'default'
|
286
|
-
@plugin = build_start_paypal_plugin
|
287
|
-
baid_setup
|
288
|
-
end
|
289
|
-
|
290
|
-
include_examples 'baid_spec_common'
|
291
|
-
end
|
292
|
-
|
293
|
-
context 'baid tests with multiple accounts' do
|
294
|
-
# Share the BAID
|
295
|
-
before(:all) do
|
296
|
-
# delete once here because we need to keep the initial response for later tests to find the payment processor account id
|
297
|
-
::Killbill::PaypalExpress::PaypalExpressResponse.delete_all
|
298
|
-
@payment_processor_account_id = 'paypal_test_account'
|
299
|
-
@plugin = build_start_paypal_plugin @payment_processor_account_id
|
300
|
-
baid_setup @payment_processor_account_id
|
301
|
-
end
|
302
|
-
|
303
|
-
include_examples 'baid_spec_common'
|
304
|
-
end
|
305
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require_relative 'browser_helpers'
|
2
|
-
|
3
|
-
module Killbill
|
4
|
-
module PaypalExpress
|
5
|
-
module BaidSpecHelpers
|
6
|
-
|
7
|
-
include ::Killbill::PaypalExpress::BrowserHelpers
|
8
|
-
|
9
|
-
def baid_setup(payment_processor_account_id = nil)
|
10
|
-
@call_context = build_call_context
|
11
|
-
|
12
|
-
options = {:payment_processor_account_id => payment_processor_account_id}
|
13
|
-
|
14
|
-
@amount = BigDecimal.new('100')
|
15
|
-
@currency = 'USD'
|
16
|
-
|
17
|
-
kb_account_id = SecureRandom.uuid
|
18
|
-
external_key, kb_account_id = create_kb_account(kb_account_id, @plugin.kb_apis.proxied_services[:account_user_api])
|
19
|
-
|
20
|
-
@private_plugin = ::Killbill::PaypalExpress::PrivatePaymentPlugin.new
|
21
|
-
|
22
|
-
# Initiate the setup process
|
23
|
-
response = create_token(kb_account_id, @call_context.tenant_id, options)
|
24
|
-
token = response.token
|
25
|
-
|
26
|
-
login_and_confirm @private_plugin.to_express_checkout_url(response, @call_context.tenant_id)
|
27
|
-
|
28
|
-
# Complete the setup process
|
29
|
-
@properties = []
|
30
|
-
@properties << build_property('token', token)
|
31
|
-
@pm = create_payment_method(::Killbill::PaypalExpress::PaypalExpressPaymentMethod, kb_account_id, @call_context.tenant_id, @properties)
|
32
|
-
|
33
|
-
verify_payment_method kb_account_id
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def create_token(kb_account_id, kb_tenant_id, options)
|
39
|
-
response = @private_plugin.initiate_express_checkout(kb_account_id, kb_tenant_id, @amount, @currency, true, options)
|
40
|
-
response.success.should be_true
|
41
|
-
response
|
42
|
-
end
|
43
|
-
|
44
|
-
def verify_payment_method(kb_account_id)
|
45
|
-
# Verify our table directly. Note that @pm.token is the baid
|
46
|
-
payment_methods = ::Killbill::PaypalExpress::PaypalExpressPaymentMethod.from_kb_account_id_and_token(@pm.token, kb_account_id, @call_context.tenant_id)
|
47
|
-
payment_methods.size.should == 1
|
48
|
-
payment_method = payment_methods.first
|
49
|
-
payment_method.should_not be_nil
|
50
|
-
payment_method.paypal_express_payer_id.should_not be_nil
|
51
|
-
payment_method.token.should == @pm.token
|
52
|
-
payment_method.kb_payment_method_id.should == @pm.kb_payment_method_id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|