killbill-paypal-express 1.0.8 → 1.0.9
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.9
|
data/lib/paypal_express/api.rb
CHANGED
@@ -39,6 +39,19 @@ module Killbill::PaypalExpress
|
|
39
39
|
response.to_payment_response
|
40
40
|
end
|
41
41
|
|
42
|
+
def get_payment_info(kb_account_id, kb_payment_id, tenant_context, options = {})
|
43
|
+
paypal_express_transaction = PaypalExpressTransaction.from_kb_payment_id(kb_payment_id.to_s)
|
44
|
+
|
45
|
+
begin
|
46
|
+
transaction_id = paypal_express_transaction.paypal_express_txn_id
|
47
|
+
response = @gateway.transaction_details transaction_id
|
48
|
+
PaypalExpressResponse.from_response(:transaction_details, kb_payment_id.to_s, response).to_payment_response
|
49
|
+
rescue => e
|
50
|
+
@logger.warn("Exception while retrieving Paypal Express transaction detail for payment #{kb_payment_id.to_s}, defaulting to cached response: #{e}")
|
51
|
+
paypal_express_transaction.paypal_express_response.to_payment_response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
def process_refund(kb_account_id, kb_payment_id, amount_in_cents, currency, call_context, options = {})
|
43
56
|
paypal_express_transaction = PaypalExpressTransaction.find_candidate_transaction_for_refund(kb_payment_id.to_s, amount_in_cents)
|
44
57
|
|
@@ -54,16 +67,16 @@ module Killbill::PaypalExpress
|
|
54
67
|
response.to_refund_response
|
55
68
|
end
|
56
69
|
|
57
|
-
def
|
58
|
-
paypal_express_transaction = PaypalExpressTransaction.
|
70
|
+
def get_refund_info(kb_account_id, kb_payment_id, tenant_context, options = {})
|
71
|
+
paypal_express_transaction = PaypalExpressTransaction.refund_from_kb_payment_id(kb_payment_id.to_s)
|
59
72
|
|
60
73
|
begin
|
61
74
|
transaction_id = paypal_express_transaction.paypal_express_txn_id
|
62
75
|
response = @gateway.transaction_details transaction_id
|
63
|
-
PaypalExpressResponse.from_response(:transaction_details, kb_payment_id.to_s, response).
|
76
|
+
PaypalExpressResponse.from_response(:transaction_details, kb_payment_id.to_s, response).to_refund_response
|
64
77
|
rescue => e
|
65
78
|
@logger.warn("Exception while retrieving Paypal Express transaction detail for payment #{kb_payment_id.to_s}, defaulting to cached response: #{e}")
|
66
|
-
paypal_express_transaction.paypal_express_response.
|
79
|
+
paypal_express_transaction.paypal_express_response.to_refund_response
|
67
80
|
end
|
68
81
|
end
|
69
82
|
|
@@ -107,10 +120,18 @@ module Killbill::PaypalExpress
|
|
107
120
|
PaypalExpressPaymentMethod.from_kb_payment_method_id(kb_payment_method_id.to_s).to_payment_method_response
|
108
121
|
end
|
109
122
|
|
123
|
+
def set_default_payment_method(kb_account_id, kb_payment_method_id, call_context, options = {})
|
124
|
+
# No-op
|
125
|
+
end
|
126
|
+
|
110
127
|
def get_payment_methods(kb_account_id, refresh_from_gateway, call_context, options = {})
|
111
128
|
PaypalExpressPaymentMethod.from_kb_account_id(kb_account_id.to_s).collect { |pm| pm.to_payment_method_response }
|
112
129
|
end
|
113
130
|
|
131
|
+
def reset_payment_methods(kb_account_id, payment_methods)
|
132
|
+
# No-op
|
133
|
+
end
|
134
|
+
|
114
135
|
private
|
115
136
|
|
116
137
|
def save_response_and_transaction(paypal_express_response, api_call, kb_payment_id=nil, amount_in_cents=0)
|
@@ -7,7 +7,15 @@ module Killbill::PaypalExpress
|
|
7
7
|
:paypal_express_txn_id
|
8
8
|
|
9
9
|
def self.from_kb_payment_id(kb_payment_id)
|
10
|
-
|
10
|
+
single_transaction_from_kb_payment_id :charge, kb_payment_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.refund_from_kb_payment_id(kb_payment_id)
|
14
|
+
single_transaction_from_kb_payment_id :refund, kb_payment_id
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.single_transaction_from_kb_payment_id(api_call, kb_payment_id)
|
18
|
+
paypal_express_transactions = find_all_by_api_call_and_kb_payment_id(api_call, kb_payment_id)
|
11
19
|
raise "Unable to find Paypal Express transaction id for payment #{kb_payment_id}" if paypal_express_transactions.empty?
|
12
20
|
raise "Killbill payment mapping to multiple Paypal Express transactions for payment #{kb_payment_id}" if paypal_express_transactions.size > 1
|
13
21
|
paypal_express_transactions[0]
|
@@ -30,4 +38,4 @@ module Killbill::PaypalExpress
|
|
30
38
|
paypal_express_transactions.first
|
31
39
|
end
|
32
40
|
end
|
33
|
-
end
|
41
|
+
end
|
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.0.
|
28
|
+
<version>1.0.9</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>
|
@@ -62,6 +62,11 @@ describe Killbill::PaypalExpress::PaymentPlugin do
|
|
62
62
|
response.test.should be_true
|
63
63
|
response.success.should be_true
|
64
64
|
|
65
|
+
# Check we can retrieve the refund
|
66
|
+
refund_response = @plugin.get_refund_info @pm.kb_account_id, kb_payment_id, @call_context
|
67
|
+
refund_response.amount.should == (-1 * amount_in_cents)
|
68
|
+
refund_response.status.should == Killbill::Plugin::Model::PaymentPluginStatus.new(:PROCESSED)
|
69
|
+
|
65
70
|
# Try another payment to verify the BAID
|
66
71
|
second_amount_in_cents = 9423
|
67
72
|
second_kb_payment_id = SecureRandom.uuid
|