killbill-paypal-express 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS +4 -1
- data/VERSION +1 -1
- data/lib/paypal_express/api.rb +8 -1
- data/pom.xml +1 -1
- data/spec/paypal_express/remote/integration_spec.rb +40 -5
- metadata +3 -3
data/NEWS
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.4
|
data/lib/paypal_express/api.rb
CHANGED
@@ -31,7 +31,7 @@ module Killbill::PaypalExpress
|
|
31
31
|
|
32
32
|
if options[:reference_id].blank?
|
33
33
|
payment_method = PaypalExpressPaymentMethod.from_kb_payment_method_id(kb_payment_method_id)
|
34
|
-
options[:reference_id] = payment_method.paypal_express_baid
|
34
|
+
options[:reference_id] = payment_method.paypal_express_baid
|
35
35
|
end
|
36
36
|
|
37
37
|
# Go to Paypal (DoReferenceTransaction call)
|
@@ -93,6 +93,13 @@ module Killbill::PaypalExpress
|
|
93
93
|
response = save_response_and_transaction paypal_express_baid_response, :create_billing_agreement
|
94
94
|
return false unless response.success?
|
95
95
|
|
96
|
+
if response.billing_agreement_id.blank?
|
97
|
+
# If the baid isn't specified (invalid token, maybe expired?), we won't be able to charge that payment method
|
98
|
+
# See https://github.com/killbill/killbill-paypal-express-plugin/issues/1
|
99
|
+
logger.warn "No BAID returned by the CreateBillingAgreement call for token #{token} (account #{kb_account_id})"
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
|
96
103
|
payment_method.kb_payment_method_id = kb_payment_method_id
|
97
104
|
payment_method.paypal_express_payer_id = payer_id
|
98
105
|
payment_method.paypal_express_baid = response.billing_agreement_id
|
data/pom.xml
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
<groupId>com.ning.killbill.ruby</groupId>
|
26
26
|
<artifactId>paypal-express-plugin</artifactId>
|
27
27
|
<packaging>pom</packaging>
|
28
|
-
<version>1.5.
|
28
|
+
<version>1.5.4</version>
|
29
29
|
<name>paypal-express-plugin</name>
|
30
30
|
<url>http://github.com/killbill/killbill-paypal-express-plugin</url>
|
31
31
|
<description>Plugin for accessing paypal as a payment gateway</description>
|
@@ -13,15 +13,45 @@ describe Killbill::PaypalExpress::PaymentPlugin do
|
|
13
13
|
@plugin.logger = logger
|
14
14
|
|
15
15
|
@plugin.start_plugin
|
16
|
-
|
17
|
-
@pm = create_payment_method
|
18
16
|
end
|
19
17
|
|
20
18
|
after(:each) do
|
21
19
|
@plugin.stop_plugin
|
22
20
|
end
|
23
21
|
|
22
|
+
it 'should be able to handle bad payment methods' do
|
23
|
+
amount = BigDecimal.new("100")
|
24
|
+
currency = 'USD'
|
25
|
+
kb_account_id = SecureRandom.uuid
|
26
|
+
kb_payment_id = SecureRandom.uuid
|
27
|
+
kb_payment_method_id = SecureRandom.uuid
|
28
|
+
|
29
|
+
# Create a dummy token (but never go to PayPal to validate it). This will create a dummy payment method, with no baid
|
30
|
+
token = create_token(kb_account_id).token
|
31
|
+
|
32
|
+
# Verify the add payment method call fails
|
33
|
+
pm_kv_info = Killbill::Plugin::Model::PaymentMethodKVInfo.new
|
34
|
+
pm_kv_info.key = 'token'
|
35
|
+
pm_kv_info.value = token
|
36
|
+
info = Killbill::Plugin::Model::PaymentMethodPlugin.new
|
37
|
+
info.properties = [pm_kv_info]
|
38
|
+
# Note: the call will fail because the payer_id is nil
|
39
|
+
# There is another failure scenario described by https://github.com/killbill/killbill-paypal-express-plugin/issues/1 when
|
40
|
+
# the CreateBillingAgreement fails. We cannot easily reproduce it though unfortunately
|
41
|
+
@plugin.add_payment_method(kb_account_id, kb_payment_method_id, info).should be_false
|
42
|
+
|
43
|
+
# Update the payment method (still without a baid) with a dummy kb_payment_method_id
|
44
|
+
# This should never happen though
|
45
|
+
payment_method = Killbill::PaypalExpress::PaypalExpressPaymentMethod.from_kb_account_id_and_token(kb_account_id, token).update_attribute(:kb_payment_method_id, kb_payment_method_id)
|
46
|
+
|
47
|
+
# Attempt a payment - verify the call goes through, without throwing an exception (invalid state, but we still want PAYMENT_FAILURE, not PLUGIN_FAILURE)
|
48
|
+
payment_response = @plugin.process_payment kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency
|
49
|
+
payment_response.status.should == :ERROR
|
50
|
+
end
|
51
|
+
|
24
52
|
it 'should be able to charge and refund' do
|
53
|
+
@pm = create_payment_method
|
54
|
+
|
25
55
|
amount = BigDecimal.new("100")
|
26
56
|
currency = 'USD'
|
27
57
|
kb_payment_id = SecureRandom.uuid
|
@@ -93,13 +123,18 @@ describe Killbill::PaypalExpress::PaymentPlugin do
|
|
93
123
|
|
94
124
|
private
|
95
125
|
|
126
|
+
def create_token(kb_account_id)
|
127
|
+
private_plugin = Killbill::PaypalExpress::PrivatePaymentPlugin.instance
|
128
|
+
response = private_plugin.initiate_express_checkout kb_account_id
|
129
|
+
response.success.should be_true
|
130
|
+
response
|
131
|
+
end
|
132
|
+
|
96
133
|
def create_payment_method
|
97
134
|
kb_account_id = SecureRandom.uuid
|
98
|
-
private_plugin = Killbill::PaypalExpress::PrivatePaymentPlugin.instance
|
99
135
|
|
100
136
|
# Initiate the setup process
|
101
|
-
response =
|
102
|
-
response.success.should be_true
|
137
|
+
response = create_token(kb_account_id)
|
103
138
|
token = response.token
|
104
139
|
|
105
140
|
print "\nPlease go to #{response.to_express_checkout_url} to proceed and press any key to continue...
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: killbill-paypal-express
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.3
|
5
4
|
prerelease:
|
5
|
+
version: 1.5.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kill Bill core team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: killbill
|
@@ -212,9 +212,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
- !ruby/object:Gem::Version
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
+
hash: 2
|
215
216
|
version: !binary |-
|
216
217
|
MA==
|
217
|
-
hash: 2
|
218
218
|
none: false
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|