killbill-paypal-express 4.1.2 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -2
- data/NEWS +4 -0
- data/README.md +2 -1
- data/VERSION +1 -1
- data/killbill-paypal-express.gemspec +1 -0
- data/lib/paypal_express/api.rb +142 -103
- data/lib/paypal_express/models/response.rb +10 -0
- data/pom.xml +1 -1
- data/spec/paypal_express/remote/baid_spec.rb +52 -56
- data/spec/paypal_express/remote/baid_spec_helpers.rb +55 -0
- data/spec/paypal_express/remote/browser_helpers.rb +72 -0
- data/spec/paypal_express/remote/build_plugin_helpers.rb +33 -0
- data/spec/paypal_express/remote/hpp_spec.rb +189 -123
- data/spec/paypal_express/remote/hpp_spec_helpers.rb +364 -0
- data/spec/spec_helper.rb +14 -1
- metadata +20 -2
@@ -0,0 +1,55 @@
|
|
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
|
+
# Initiate the setup process
|
21
|
+
response = create_token(kb_account_id, @call_context.tenant_id, options)
|
22
|
+
token = response.token
|
23
|
+
|
24
|
+
login_and_confirm @plugin.to_express_checkout_url(response, @call_context.tenant_id)
|
25
|
+
|
26
|
+
# Complete the setup process
|
27
|
+
@properties = []
|
28
|
+
@properties << build_property('token', token)
|
29
|
+
@pm = create_payment_method(::Killbill::PaypalExpress::PaypalExpressPaymentMethod, kb_account_id, @call_context.tenant_id, @properties)
|
30
|
+
|
31
|
+
verify_payment_method kb_account_id
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def create_token(kb_account_id, kb_tenant_id, options)
|
37
|
+
private_plugin = ::Killbill::PaypalExpress::PrivatePaymentPlugin.new
|
38
|
+
response = private_plugin.initiate_express_checkout(kb_account_id, kb_tenant_id, @amount, @currency, true, options)
|
39
|
+
response.success.should be_true
|
40
|
+
response
|
41
|
+
end
|
42
|
+
|
43
|
+
def verify_payment_method(kb_account_id)
|
44
|
+
# Verify our table directly. Note that @pm.token is the baid
|
45
|
+
payment_methods = ::Killbill::PaypalExpress::PaypalExpressPaymentMethod.from_kb_account_id_and_token(@pm.token, kb_account_id, @call_context.tenant_id)
|
46
|
+
payment_methods.size.should == 1
|
47
|
+
payment_method = payment_methods.first
|
48
|
+
payment_method.should_not be_nil
|
49
|
+
payment_method.paypal_express_payer_id.should_not be_nil
|
50
|
+
payment_method.token.should == @pm.token
|
51
|
+
payment_method.kb_payment_method_id.should == @pm.kb_payment_method_id
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
|
3
|
+
module Killbill
|
4
|
+
module PaypalExpress
|
5
|
+
module BrowserHelpers
|
6
|
+
def login_and_confirm(url)
|
7
|
+
if ENV['BUYER_USERNAME'].blank? || ENV['BUYER_PASSWORD'].blank?
|
8
|
+
print "\nPlease go to #{url} to proceed and press any key to continue... Note: you need to log-in with a paypal sandbox account (create one here: https://developer.paypal.com/webapps/developer/applications/accounts)\n"
|
9
|
+
$stdin.gets
|
10
|
+
else
|
11
|
+
driver = Selenium::WebDriver.for :firefox
|
12
|
+
# Login page
|
13
|
+
driver.get url
|
14
|
+
|
15
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
|
16
|
+
wait.until {
|
17
|
+
driver.switch_to.frame('injectedUl') rescue nil
|
18
|
+
}
|
19
|
+
|
20
|
+
email_element, pwd_element, login_element = wait.until {
|
21
|
+
email_element = driver.find_element(:id, 'email') rescue nil
|
22
|
+
pwd_element = driver.find_element(:id, 'password') rescue nil
|
23
|
+
login_element = driver.find_element(:id, 'btnLogin') rescue nil
|
24
|
+
if ready?(email_element, pwd_element, login_element)
|
25
|
+
[email_element, pwd_element, login_element]
|
26
|
+
else
|
27
|
+
# Find the element ids from the old UI
|
28
|
+
old_email_element = driver.find_element(:id, 'login_email') rescue nil
|
29
|
+
old_pwd_element = driver.find_element(:id, 'login_password') rescue nil
|
30
|
+
old_login_element = driver.find_element(:id, 'submitLogin') rescue nil
|
31
|
+
if ready?(old_email_element, old_pwd_element, old_login_element)
|
32
|
+
[old_email_element, old_pwd_element, old_login_element]
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
}
|
38
|
+
email_element.send_keys(ENV['BUYER_USERNAME'])
|
39
|
+
pwd_element.send_keys(ENV['BUYER_PASSWORD'])
|
40
|
+
login_element.click
|
41
|
+
|
42
|
+
# Confirmation page
|
43
|
+
driver.switch_to.default_content
|
44
|
+
confirm_element = wait.until {
|
45
|
+
confirm_element = driver.find_element(:id, 'confirmButtonTop') rescue nil
|
46
|
+
if ready?(confirm_element)
|
47
|
+
confirm_element
|
48
|
+
else
|
49
|
+
old_confirm_element = driver.find_element(:id, 'continue_abovefold') rescue nil
|
50
|
+
ready?(old_confirm_element) ? old_confirm_element : false
|
51
|
+
end
|
52
|
+
}
|
53
|
+
|
54
|
+
# Wait for page to load. Even if it is displayed and enabled, sometimes the element is still not clickable.
|
55
|
+
sleep 2
|
56
|
+
confirm_element.click
|
57
|
+
|
58
|
+
driver.quit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def ready?(*elements)
|
65
|
+
elements.each do |element|
|
66
|
+
return false unless element && element.displayed? && element.enabled?
|
67
|
+
end
|
68
|
+
true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Killbill
|
2
|
+
module PaypalExpress
|
3
|
+
module BuildPluginHelpers
|
4
|
+
def build_start_paypal_plugin(account_id = nil)
|
5
|
+
if account_id.nil?
|
6
|
+
plugin = build_plugin(::Killbill::PaypalExpress::PaymentPlugin, 'paypal_express')
|
7
|
+
start_plugin plugin
|
8
|
+
else
|
9
|
+
config = YAML.load_file('paypal_express.yml')
|
10
|
+
existing_credential = {:account_id => account_id}.merge config[:paypal_express]
|
11
|
+
second_credential = {:account_id => "#{account_id}_duplicate"}.merge config[:paypal_express]
|
12
|
+
config[:paypal_express] = [second_credential, existing_credential]
|
13
|
+
Dir.mktmpdir do |dir|
|
14
|
+
file_name = File.join(dir, 'paypal_express.yml')
|
15
|
+
File.open(file_name, 'w+') do |file|
|
16
|
+
YAML.dump(config, file)
|
17
|
+
end
|
18
|
+
plugin = build_plugin(::Killbill::PaypalExpress::PaymentPlugin, 'paypal_express', File.dirname(file_name))
|
19
|
+
start_plugin plugin
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_plugin(plugin)
|
25
|
+
svcs = plugin.kb_apis.proxied_services
|
26
|
+
svcs[:payment_api] = PaypalExpressJavaPaymentApi.new(plugin)
|
27
|
+
plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('paypal_express', svcs)
|
28
|
+
plugin.start_plugin
|
29
|
+
plugin
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,38 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require_relative 'hpp_spec_helpers'
|
3
|
+
require_relative 'build_plugin_helpers'
|
2
4
|
|
3
5
|
ActiveMerchant::Billing::Base.mode = :test
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
8
|
-
|
9
|
-
before(:all) do
|
10
|
-
@plugin = build_plugin(::Killbill::PaypalExpress::PaymentPlugin, 'paypal_express')
|
11
|
-
svcs = @plugin.kb_apis.proxied_services
|
12
|
-
svcs[:payment_api] = PaypalExpressJavaPaymentApi.new(@plugin)
|
13
|
-
@plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('paypal_express', svcs)
|
14
|
-
@plugin.start_plugin
|
15
|
-
|
16
|
-
@call_context = build_call_context
|
17
|
-
|
18
|
-
@amount = BigDecimal.new('100')
|
19
|
-
@currency = 'USD'
|
20
|
-
@form_fields = @plugin.hash_to_properties(
|
21
|
-
:order_id => '1234',
|
22
|
-
:amount => @amount,
|
23
|
-
:currency => @currency
|
24
|
-
)
|
25
|
-
|
26
|
-
kb_account_id = SecureRandom.uuid
|
27
|
-
create_kb_account(kb_account_id, @plugin.kb_apis.proxied_services[:account_user_api])
|
28
|
-
|
29
|
-
@pm = create_payment_method(::Killbill::PaypalExpress::PaypalExpressPaymentMethod, kb_account_id, @call_context.tenant_id)
|
30
|
-
verify_payment_method
|
31
|
-
end
|
7
|
+
shared_examples 'hpp_spec_common' do
|
32
8
|
|
33
9
|
before(:each) do
|
34
10
|
::Killbill::PaypalExpress::PaypalExpressTransaction.delete_all
|
35
11
|
::Killbill::PaypalExpress::PaypalExpressResponse.delete_all
|
12
|
+
# clean the payments before each spec to avoid one influences each other
|
13
|
+
@plugin.kb_apis.proxied_services[:payment_api].delete_all_payments
|
36
14
|
end
|
37
15
|
|
38
16
|
it 'should generate forms correctly' do
|
@@ -141,116 +119,204 @@ describe Killbill::PaypalExpress::PaymentPlugin do
|
|
141
119
|
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 1 + 9 * n
|
142
120
|
end
|
143
121
|
|
144
|
-
|
122
|
+
it 'should generate forms and perform auth, capture and refund correctly' do
|
123
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 0
|
124
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 0
|
145
125
|
|
146
|
-
|
147
|
-
|
148
|
-
form.form_url.should start_with('https://www.sandbox.paypal.com/cgi-bin/webscr')
|
149
|
-
form.form_method.should == 'GET'
|
150
|
-
end
|
126
|
+
# Verify the authorization cannot go through without the token
|
127
|
+
authorize_with_missing_token
|
151
128
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
129
|
+
# Verify multiple payments can be triggered for the same payment method
|
130
|
+
n = 2
|
131
|
+
1.upto(n) do |i|
|
132
|
+
payment_external_key = SecureRandom.uuid
|
133
|
+
is_pending_payment_test = i % 2 == 1 ? false : true
|
134
|
+
properties = @plugin.hash_to_properties(
|
135
|
+
:transaction_external_key => payment_external_key,
|
136
|
+
# test both with and without pending payments
|
137
|
+
:create_pending_payment => is_pending_payment_test,
|
138
|
+
:payment_processor_account_id => @payment_processor_account_id,
|
139
|
+
:auth_mode => true
|
140
|
+
)
|
141
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
142
|
+
validate_form(form)
|
143
|
+
token = validate_form_property(form, 'token')
|
144
|
+
# Verify payments were created when create_pending_payment is true
|
145
|
+
@plugin.kb_apis.proxied_services[:payment_api].payments.size.should == i / 2
|
146
|
+
if is_pending_payment_test
|
147
|
+
kb_payment_id = validate_form_property(form, 'kb_payment_id')
|
148
|
+
validate_form_property(form, 'kb_transaction_external_key', payment_external_key)
|
149
|
+
@plugin.kb_apis.proxied_services[:payment_api].get_payment(kb_payment_id).transactions.first.external_key.should == payment_external_key
|
150
|
+
# Verify GET API
|
151
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
152
|
+
payment_infos.size.should == 1
|
153
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
154
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
155
|
+
payment_infos[0].amount.should be_nil
|
156
|
+
payment_infos[0].currency.should be_nil
|
157
|
+
payment_infos[0].status.should == :PENDING
|
158
|
+
payment_infos[0].gateway_error.should == '{"payment_plugin_status":"PENDING"}'
|
159
|
+
payment_infos[0].gateway_error_code.should be_nil
|
160
|
+
find_value_from_properties(payment_infos[0].properties, :payment_processor_account_id).should == @payment_processor_account_id
|
161
|
+
else
|
162
|
+
kb_payment_id = SecureRandom.uuid
|
163
|
+
validate_nil_form_property(form, 'kb_payment_id')
|
164
|
+
validate_nil_form_property(form, 'kb_transaction_external_key')
|
165
|
+
end
|
156
166
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
167
|
+
properties = []
|
168
|
+
properties << build_property(:token, token)
|
169
|
+
# Verify the payment cannot be authorized without the token being validated
|
170
|
+
authorize_with_invalid_token(properties)
|
171
|
+
# Go to PayPal to validate the token
|
172
|
+
validate_token(form)
|
164
173
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
174
|
+
# Verify auth, capture and refund
|
175
|
+
authorize_capture_and_refund(kb_payment_id, payment_external_key, properties, @payment_processor_account_id)
|
176
|
+
|
177
|
+
# Verify no extra payment was created in Kill Bill by the plugin
|
178
|
+
@plugin.kb_apis.proxied_services[:payment_api].payments.size.should == (i / 2)
|
179
|
+
|
180
|
+
# Verify no token/baid was stored
|
181
|
+
verify_payment_method
|
182
|
+
end
|
170
183
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
175
|
-
payment_response.amount.should == @amount
|
176
|
-
payment_response.transaction_type.should == :PURCHASE
|
177
|
-
|
178
|
-
# Verify GET API
|
179
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
180
|
-
payment_infos.size.should == 1
|
181
|
-
payment_infos[0].kb_payment_id.should == kb_payment_id
|
182
|
-
payment_infos[0].transaction_type.should == :PURCHASE
|
183
|
-
payment_infos[0].amount.should == @amount
|
184
|
-
payment_infos[0].currency.should == @currency
|
185
|
-
payment_infos[0].status.should == :PROCESSED
|
186
|
-
payment_infos[0].gateway_error.should == 'Success'
|
187
|
-
payment_infos[0].gateway_error_code.should be_nil
|
188
|
-
|
189
|
-
# Try a full refund
|
190
|
-
refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
|
191
|
-
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
192
|
-
refund_response.amount.should == @amount
|
193
|
-
refund_response.transaction_type.should == :REFUND
|
194
|
-
|
195
|
-
# Verify GET API
|
196
|
-
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
197
|
-
payment_infos.size.should == 2
|
198
|
-
payment_infos[0].kb_payment_id.should == kb_payment_id
|
199
|
-
payment_infos[0].transaction_type.should == :PURCHASE
|
200
|
-
payment_infos[0].amount.should == @amount
|
201
|
-
payment_infos[0].currency.should == @currency
|
202
|
-
payment_infos[0].status.should == :PROCESSED
|
203
|
-
payment_infos[0].gateway_error.should == 'Success'
|
204
|
-
payment_infos[0].gateway_error_code.should be_nil
|
205
|
-
payment_infos[1].kb_payment_id.should.should == kb_payment_id
|
206
|
-
payment_infos[1].transaction_type.should == :REFUND
|
207
|
-
payment_infos[1].amount.should == @amount
|
208
|
-
payment_infos[1].currency.should == @currency
|
209
|
-
payment_infos[1].status.should == :PROCESSED
|
210
|
-
payment_infos[1].gateway_error.should == 'Success'
|
211
|
-
payment_infos[1].gateway_error_code.should be_nil
|
184
|
+
# Each loop triggers one successful auth, one successful capture and one successful refund
|
185
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 3 * n
|
186
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 1 + 15 * n / 2 + 7 * n % 2
|
212
187
|
end
|
213
188
|
|
214
|
-
|
215
|
-
|
189
|
+
it 'should perform auth and void correctly' do
|
190
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 0
|
191
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 0
|
192
|
+
|
193
|
+
# Verify multiple payments can be triggered for the same payment method
|
194
|
+
n = 2
|
195
|
+
1.upto(n) do |i|
|
196
|
+
payment_external_key = SecureRandom.uuid
|
197
|
+
is_pending_payment_test = i % 2 == 1 ? false : true
|
198
|
+
properties = @plugin.hash_to_properties(
|
199
|
+
:transaction_external_key => payment_external_key,
|
200
|
+
:create_pending_payment => is_pending_payment_test,
|
201
|
+
:auth_mode => true,
|
202
|
+
:payment_processor_account_id => @payment_processor_account_id
|
203
|
+
)
|
204
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
205
|
+
validate_form(form)
|
206
|
+
token = validate_form_property(form, 'token')
|
207
|
+
if is_pending_payment_test
|
208
|
+
kb_payment_id = validate_form_property(form, 'kb_payment_id')
|
209
|
+
else
|
210
|
+
kb_payment_id = SecureRandom.uuid
|
211
|
+
end
|
212
|
+
|
213
|
+
# Go to PayPal to validate the token
|
214
|
+
validate_token(form)
|
215
|
+
|
216
|
+
properties = []
|
217
|
+
properties << build_property('token', token)
|
218
|
+
|
219
|
+
authorize_and_void(kb_payment_id, payment_external_key, properties, @payment_processor_account_id)
|
220
|
+
|
221
|
+
# Verify no extra payment was created in Kill Bill by the plugin
|
222
|
+
@plugin.kb_apis.proxied_services[:payment_api].payments.size.should == i / 2
|
223
|
+
end
|
224
|
+
|
225
|
+
# Each loop triggers one successful authorize and one successful void
|
226
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 2 * n
|
227
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 9 * n / 2 + 5 * n % 2
|
216
228
|
end
|
217
229
|
|
218
|
-
|
219
|
-
|
230
|
+
it 'should not capture the same transaction twice with full amount' do
|
231
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 0
|
232
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 0
|
233
|
+
|
234
|
+
payment_external_key = SecureRandom.uuid
|
235
|
+
properties = @plugin.hash_to_properties(
|
236
|
+
:transaction_external_key => payment_external_key,
|
237
|
+
:create_pending_payment => true,
|
238
|
+
:auth_mode => true
|
239
|
+
)
|
240
|
+
|
241
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
242
|
+
validate_form(form)
|
243
|
+
kb_payment_id = validate_form_property(form, 'kb_payment_id')
|
244
|
+
validate_form_property(form, 'kb_transaction_external_key', payment_external_key)
|
245
|
+
token = validate_form_property(form, 'token')
|
246
|
+
|
247
|
+
properties = []
|
248
|
+
properties << build_property('token', token)
|
249
|
+
properties << build_property('auth_mode', 'true')
|
250
|
+
|
251
|
+
validate_token(form)
|
252
|
+
|
253
|
+
authorize_and_double_capture(kb_payment_id, payment_external_key, properties)
|
220
254
|
end
|
221
255
|
|
222
|
-
|
223
|
-
|
256
|
+
it 'should find the payment processor id from the initial_express_call' do
|
257
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 0
|
258
|
+
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 0
|
259
|
+
|
260
|
+
properties = @plugin.hash_to_properties(
|
261
|
+
:transaction_external_key => SecureRandom.uuid,
|
262
|
+
:create_pending_payment => true,
|
263
|
+
:auth_mode => true,
|
264
|
+
:payment_processor_account_id => @payment_processor_account_id
|
265
|
+
)
|
266
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
267
|
+
token = validate_form_property(form, 'token')
|
268
|
+
@plugin.send(:find_payment_processor_id_from_initial_call, @pm.kb_account_id, @call_context.tenant_id, token).should == @payment_processor_account_id
|
269
|
+
|
270
|
+
properties = @plugin.hash_to_properties(
|
271
|
+
:transaction_external_key => SecureRandom.uuid,
|
272
|
+
:auth_mode => true,
|
273
|
+
:payment_processor_account_id => @payment_processor_account_id
|
274
|
+
)
|
275
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
276
|
+
token = validate_form_property(form, 'token')
|
277
|
+
@plugin.send(:find_payment_processor_id_from_initial_call, @pm.kb_account_id, @call_context.tenant_id, token).should == @payment_processor_account_id
|
278
|
+
|
279
|
+
properties = @plugin.hash_to_properties(
|
280
|
+
:transaction_external_key => SecureRandom.uuid,
|
281
|
+
:create_pending_payment => true,
|
282
|
+
:payment_processor_account_id => @payment_processor_account_id
|
283
|
+
)
|
284
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
285
|
+
token = validate_form_property(form, 'token')
|
286
|
+
@plugin.send(:find_payment_processor_id_from_initial_call, @pm.kb_account_id, @call_context.tenant_id, token).should == @payment_processor_account_id
|
287
|
+
|
288
|
+
properties = @plugin.hash_to_properties(
|
289
|
+
:transaction_external_key => SecureRandom.uuid,
|
290
|
+
:payment_processor_account_id => @payment_processor_account_id
|
291
|
+
)
|
292
|
+
form = @plugin.build_form_descriptor(@pm.kb_account_id, @form_fields, properties, @call_context)
|
293
|
+
token = validate_form_property(form, 'token')
|
294
|
+
@plugin.send(:find_payment_processor_id_from_initial_call, @pm.kb_account_id, @call_context.tenant_id, token).should == @payment_processor_account_id
|
224
295
|
end
|
296
|
+
end
|
225
297
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
payment_infos[0].amount.should be_nil
|
240
|
-
payment_infos[0].currency.should be_nil
|
241
|
-
payment_infos[0].status.should == status
|
242
|
-
payment_infos[0].gateway_error.should == msg
|
243
|
-
payment_infos[0].gateway_error_code.should == gateway_error_code
|
298
|
+
describe Killbill::PaypalExpress::PaymentPlugin do
|
299
|
+
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
300
|
+
include ::Killbill::PaypalExpress::BuildPluginHelpers
|
301
|
+
include ::Killbill::PaypalExpress::HppSpecHelpers
|
302
|
+
|
303
|
+
context 'hpp test with a single account' do
|
304
|
+
before(:all) do
|
305
|
+
@payment_processor_account_id = 'default'
|
306
|
+
@plugin = build_start_paypal_plugin
|
307
|
+
hpp_setup
|
308
|
+
end
|
309
|
+
|
310
|
+
include_examples 'hpp_spec_common'
|
244
311
|
end
|
245
312
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
payment_method.kb_payment_method_id.should == @pm.kb_payment_method_id
|
313
|
+
context 'hpp test with multiple accounts' do
|
314
|
+
before(:all) do
|
315
|
+
@payment_processor_account_id = 'paypal_test_account'
|
316
|
+
@plugin = build_start_paypal_plugin @payment_processor_account_id
|
317
|
+
hpp_setup
|
318
|
+
end
|
319
|
+
|
320
|
+
include_examples 'hpp_spec_common'
|
255
321
|
end
|
256
322
|
end
|