killbill-litle 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
data/lib/litle/api.rb CHANGED
@@ -36,6 +36,15 @@ module Killbill::Litle
36
36
  response.to_payment_response
37
37
  end
38
38
 
39
+ def get_payment_info(kb_account_id, kb_payment_id, tenant_context, options = {})
40
+ # We assume the payment is immutable in Litle and only look at our tables since there
41
+ # doesn't seem to be a Litle API to fetch details for a given transaction.
42
+ # TODO How can we support Authorization/Sale Recycling?
43
+ litle_transaction = LitleTransaction.from_kb_payment_id(kb_payment_id.to_s)
44
+
45
+ litle_transaction.litle_response.to_payment_response
46
+ end
47
+
39
48
  def process_refund(kb_account_id, kb_payment_id, amount_in_cents, currency, call_context, options = {})
40
49
  litle_transaction = LitleTransaction.find_candidate_transaction_for_refund(kb_payment_id.to_s, amount_in_cents)
41
50
 
@@ -49,13 +58,12 @@ module Killbill::Litle
49
58
  response.to_refund_response
50
59
  end
51
60
 
52
- def get_payment_info(kb_account_id, kb_payment_id, tenant_context, options = {})
53
- # We assume the payment is immutable in Litle and only look at our tables since there
61
+ def get_refund_info(kb_account_id, kb_payment_id, tenant_context, options = {})
62
+ # We assume the refund is immutable in Litle and only look at our tables since there
54
63
  # doesn't seem to be a Litle API to fetch details for a given transaction.
55
- # TODO How can we support Authorization/Sale Recycling?
56
- litle_transaction = LitleTransaction.from_kb_payment_id(kb_payment_id.to_s)
64
+ litle_transaction = LitleTransaction.refund_from_kb_payment_id(kb_payment_id.to_s)
57
65
 
58
- litle_transaction.litle_response.to_payment_response
66
+ litle_transaction.litle_response.to_refund_response
59
67
  end
60
68
 
61
69
  def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, call_context, options = {})
@@ -82,10 +90,18 @@ module Killbill::Litle
82
90
  LitlePaymentMethod.from_kb_payment_method_id(kb_payment_method_id.to_s).to_payment_method_response
83
91
  end
84
92
 
93
+ def set_default_payment_method(kb_account_id, kb_payment_method_id, call_context, options = {})
94
+ # No-op
95
+ end
96
+
85
97
  def get_payment_methods(kb_account_id, refresh_from_gateway, call_context, options = {})
86
98
  LitlePaymentMethod.from_kb_account_id(kb_account_id.to_s).collect { |pm| pm.to_payment_method_response }
87
99
  end
88
100
 
101
+ def reset_payment_methods(kb_account_id, payment_methods)
102
+ # No-op
103
+ end
104
+
89
105
  private
90
106
 
91
107
  def report_group_for_account(kb_account_id)
@@ -4,7 +4,15 @@ module Killbill::Litle
4
4
  attr_accessible :amount_in_cents, :api_call, :kb_payment_id, :litle_txn_id
5
5
 
6
6
  def self.from_kb_payment_id(kb_payment_id)
7
- litle_transactions = find_all_by_api_call_and_kb_payment_id(:charge, kb_payment_id)
7
+ single_transaction_from_kb_payment_id :charge, kb_payment_id
8
+ end
9
+
10
+ def self.refund_from_kb_payment_id(kb_payment_id)
11
+ single_transaction_from_kb_payment_id :refund, kb_payment_id
12
+ end
13
+
14
+ def self.single_transaction_from_kb_payment_id(api_call, kb_payment_id)
15
+ litle_transactions = find_all_by_api_call_and_kb_payment_id(api_call, kb_payment_id)
8
16
  raise "Unable to find Litle transaction id for payment #{kb_payment_id}" if litle_transactions.empty?
9
17
  raise "Killbill payment mapping to multiple Litle transactions for payment #{kb_payment_id}" if litle_transactions.size > 1
10
18
  litle_transactions[0]
@@ -27,4 +35,4 @@ module Killbill::Litle
27
35
  litle_transactions.first
28
36
  end
29
37
  end
30
- end
38
+ end
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.0.8</version>
28
+ <version>1.0.9</version>
29
29
  <name>litle-plugin</name>
30
30
  <scm>
31
31
  <connection>scm:git:git://github.com/killbill/killbill-litle-plugin.git</connection>
@@ -88,6 +88,12 @@ describe Killbill::Litle::PaymentPlugin do
88
88
  response.test.should be_true
89
89
  response.success.should be_true
90
90
 
91
+ # Check we can retrieve the refund
92
+ refund_response = @plugin.get_refund_info pm.kb_account_id, kb_payment_id, @call_context
93
+ # Apparently, Litle returns positive amounts for refunds
94
+ refund_response.amount.should == amount_in_cents
95
+ refund_response.status.should == Killbill::Plugin::Model::PaymentPluginStatus.new(:PROCESSED)
96
+
91
97
  # Make sure we can charge again the same payment method
92
98
  second_amount_in_cents = 29471
93
99
  second_kb_payment_id = SecureRandom.uuid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-litle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: