killbill-paypal-express 1.6.2 → 1.6.3

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 CHANGED
@@ -1,3 +1,6 @@
1
+ 1.6.3
2
+ Fix bugs for currency conversion during payment/refunds
3
+
1
4
  1.6.2
2
5
  Add implementation for currency conversion
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.2
1
+ 1.6.3
@@ -23,7 +23,10 @@ module Killbill::PaypalExpress
23
23
  paypal_express_transaction = PaypalExpressTransaction.from_kb_payment_id(kb_payment_id) rescue nil
24
24
  return paypal_express_transaction.paypal_express_response.to_payment_response unless paypal_express_transaction.nil?
25
25
 
26
- options[:currency] ||= currency.to_s
26
+ # Check for currency conversion
27
+ actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
28
+
29
+ options[:currency] ||= actual_currency.to_s
27
30
  options[:payment_type] ||= 'Any'
28
31
  options[:invoice_id] ||= kb_payment_id
29
32
  options[:description] ||= Killbill::PaypalExpress.paypal_payment_description || "Kill Bill payment for #{kb_payment_id}"
@@ -34,8 +37,6 @@ module Killbill::PaypalExpress
34
37
  options[:reference_id] = payment_method.paypal_express_baid
35
38
  end
36
39
 
37
- # Check for currency conversion
38
- actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
39
40
 
40
41
  # Go to Paypal (DoReferenceTransaction call)
41
42
  paypal_response = @gateway.reference_transaction actual_amount, options
@@ -55,15 +56,15 @@ module Killbill::PaypalExpress
55
56
  def process_refund(kb_account_id, kb_payment_id, amount, currency, call_context = nil, options = {})
56
57
  amount_in_cents = (amount * 100).to_i
57
58
 
58
- paypal_express_transaction = PaypalExpressTransaction.find_candidate_transaction_for_refund(kb_payment_id, amount_in_cents)
59
+ # Check for currency conversion
60
+ actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
59
61
 
60
- options[:currency] ||= currency.to_s
61
- options[:refund_type] ||= paypal_express_transaction.amount_in_cents != amount_in_cents ? 'Partial' : 'Full'
62
+ paypal_express_transaction = PaypalExpressTransaction.find_candidate_transaction_for_refund(kb_payment_id, actual_amount)
62
63
 
63
- identification = paypal_express_transaction.paypal_express_txn_id
64
+ options[:currency] ||= actual_currency.to_s
65
+ options[:refund_type] ||= paypal_express_transaction.amount_in_cents != actual_amount ? 'Partial' : 'Full'
64
66
 
65
- # Check for currency conversion
66
- actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
67
+ identification = paypal_express_transaction.paypal_express_txn_id
67
68
 
68
69
  # Go to Paypal
69
70
  paypal_response = @gateway.refund actual_amount, identification, options
@@ -185,15 +186,15 @@ module Killbill::PaypalExpress
185
186
 
186
187
  kb_payment = @kb_apis.payment_api.get_payment(kb_payment_id, false, @kb_apis.create_context)
187
188
 
188
- currency_conversion = @kb_apis.currency_conversion_api.get_currency_conversion(input_currency, kb_payment.effective_date)
189
+ currency_conversion = @kb_apis.currency_conversion_api.get_currency_conversion(converted_currency, kb_payment.effective_date)
189
190
  rates = currency_conversion.rates
190
191
  found = rates.select do |r|
191
- r.currency.to_s.upcase.to_sym == converted_currency.to_s.upcase.to_sym
192
+ r.currency.to_s.upcase.to_sym == input_currency.to_s.upcase.to_sym
192
193
  end
193
194
 
194
195
  if found.nil? || found.empty?
195
196
  @logger.warn "Failed to find converted currency #{converted_currency} for input currency #{input_currency}"
196
- return [input_amount, input_currency] if converted_currency.nil?
197
+ return [input_amount, input_currency]
197
198
  end
198
199
 
199
200
  # conversion rounding ?
@@ -131,7 +131,7 @@ module Killbill::PaypalExpress
131
131
  if paypal_express_transaction.nil?
132
132
  # payment_info_grossamount is e.g. "100.00" - we need to convert it in cents
133
133
  amount_in_cents = payment_info_grossamount ? (payment_info_grossamount.to_f * 100).to_i : nil
134
- currency = nill
134
+ currency = nil
135
135
  created_date = created_at
136
136
  first_payment_reference_id = nil
137
137
  second_payment_reference_id = nil
@@ -150,7 +150,7 @@ module Killbill::PaypalExpress
150
150
  if type == :payment
151
151
  p_info_plugin = Killbill::Plugin::Model::PaymentInfoPlugin.new
152
152
  p_info_plugin.amount = BigDecimal.new(amount_in_cents.to_s) / 100.0 if amount_in_cents
153
- p_info_plugin.amount = currency
153
+ p_info_plugin.currency = currency
154
154
  p_info_plugin.created_date = created_date
155
155
  p_info_plugin.effective_date = effective_date
156
156
  p_info_plugin.status = (success ? :PROCESSED : :ERROR)
@@ -162,7 +162,7 @@ module Killbill::PaypalExpress
162
162
  else
163
163
  r_info_plugin = Killbill::Plugin::Model::RefundInfoPlugin.new
164
164
  r_info_plugin.amount = BigDecimal.new(amount_in_cents.to_s) / 100.0 if amount_in_cents
165
- r_info_plugin.amount = currency
165
+ r_info_plugin.currency = currency
166
166
  r_info_plugin.created_date = created_date
167
167
  r_info_plugin.effective_date = effective_date
168
168
  r_info_plugin.status = (success ? :PROCESSED : :ERROR)
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.6.2</version>
28
+ <version>1.6.3</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>
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
5
4
  prerelease:
5
+ version: 1.6.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kill Bill core team
@@ -213,9 +213,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  segments:
215
215
  - 0
216
+ hash: 2
216
217
  version: !binary |-
217
218
  MA==
218
- hash: 2
219
219
  none: false
220
220
  requirements: []
221
221
  rubyforge_project: