killbill-litle 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/NEWS +3 -0
  2. data/VERSION +1 -1
  3. data/lib/litle/api.rb +10 -8
  4. data/pom.xml +1 -1
  5. metadata +2 -2
data/NEWS CHANGED
@@ -1,3 +1,6 @@
1
+ 1.9.3
2
+ Currency conversion bug fixes
3
+
1
4
  1.9.2
2
5
  Add ability currency conversion for payment/refunds
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.2
1
+ 1.9.3
data/lib/litle/api.rb CHANGED
@@ -34,12 +34,12 @@ module Killbill::Litle
34
34
  litle_pm = LitlePaymentMethod.from_kb_payment_method_id(kb_payment_method_id)
35
35
 
36
36
  # Check for currency conversion
37
- converted = convert_amount_currency_if_required(amount_in_cents, currency)
37
+ actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
38
38
 
39
39
  # Go to Litle
40
40
  gateway = Killbill::Litle.gateway_for_currency(converted[1])
41
- litle_response = gateway.purchase converted[0], litle_pm.to_litle_card_token, options
42
- response = save_response_and_transaction litle_response, :charge, kb_payment_id, converted[0], converted[1]
41
+ litle_response = gateway.purchase actual_amount, litle_pm.to_litle_card_token, options
42
+ response = save_response_and_transaction litle_response, :charge, kb_payment_id, actual_amount, actual_currency
43
43
 
44
44
  response.to_payment_response
45
45
  end
@@ -63,12 +63,12 @@ module Killbill::Litle
63
63
  options[:merchant] ||= report_group_for_currency(currency)
64
64
 
65
65
  # Check for currency conversion
66
- converted = convert_amount_currency_if_required(amount_in_cents, currency)
66
+ actual_amount, actual_currency = convert_amount_currency_if_required(amount_in_cents, currency, kb_payment_id)
67
67
 
68
68
  # Go to Litle
69
69
  gateway = Killbill::Litle.gateway_for_currency(converted[1])
70
- litle_response = gateway.credit converted[0], litle_transaction.litle_txn_id, options
71
- response = save_response_and_transaction litle_response, :refund, kb_payment_id, converted[0], converted[1]
70
+ litle_response = gateway.credit actual_amount, litle_transaction.litle_txn_id, options
71
+ response = save_response_and_transaction litle_response, :refund, kb_payment_id, actual_amount, actual_currency
72
72
  response.to_refund_response
73
73
  end
74
74
 
@@ -171,12 +171,14 @@ module Killbill::Litle
171
171
 
172
172
  private
173
173
 
174
- def convert_amount_currency_if_required(input_amount, input_currency, currency_conversion_date)
174
+ def convert_amount_currency_if_required(input_amount, input_currency, kb_payment_id)
175
175
 
176
176
  converted_currency = Killbill::Litle.converted_currency(input_currency)
177
177
  return [input_amount, input_currency] if converted_currency.nil?
178
178
 
179
- currency_conversion = @kb_apis.currency_conversion_api.get_currency_conversion(input_currency, currency_conversion_date)
179
+ kb_payment = @kb_apis.payment_api.get_payment(kb_payment_id, false, @kb_apis.create_context)
180
+
181
+ currency_conversion = @kb_apis.currency_conversion_api.get_currency_conversion(input_currency, kb_payment.effective_date)
180
182
  rates = currency_conversion.rates
181
183
  found = rates.select do |r|
182
184
  r.currency.to_s.upcase.to_sym == converted_currency.to_s.upcase.to_sym
data/pom.xml CHANGED
@@ -25,7 +25,7 @@
25
25
  <groupId>com.ning.killbill.ruby</groupId>
26
26
  <artifactId>litle-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>1.9.2</version>
28
+ <version>1.9.3</version>
29
29
  <name>litle-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-litle-plugin</url>
31
31
  <description>Plugin for accessing Litle as a payment gateway</description>
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: killbill-litle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.9.2
5
+ version: 1.9.3
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-29 00:00:00.000000000 Z
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: killbill