killbill-litle 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +8 -0
- data/VERSION +1 -1
- data/lib/litle/api.rb +7 -7
- data/lib/litle/models/litle_payment_method.rb +36 -1
- data/pom.xml +1 -1
- data/spec/litle/integration_spec.rb +4 -0
- data/spec/litle/litle_payment_method_spec.rb +56 -0
- metadata +35 -34
data/NEWS
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/lib/litle/api.rb
CHANGED
@@ -27,12 +27,12 @@ module Killbill::Litle
|
|
27
27
|
|
28
28
|
# Set a default report group
|
29
29
|
options[:merchant] ||= report_group_for_currency(currency)
|
30
|
-
# Retrieve the Litle
|
31
|
-
|
30
|
+
# Retrieve the Litle payment method
|
31
|
+
litle_pm = LitlePaymentMethod.from_kb_payment_method_id(kb_payment_method_id)
|
32
32
|
|
33
33
|
# Go to Litle
|
34
34
|
gateway = Killbill::Litle.gateway_for_currency(currency)
|
35
|
-
litle_response = gateway.purchase amount_in_cents,
|
35
|
+
litle_response = gateway.purchase amount_in_cents, litle_pm.to_litle_card_token, options
|
36
36
|
response = save_response_and_transaction litle_response, :charge, kb_payment_id, amount_in_cents
|
37
37
|
|
38
38
|
response.to_payment_response
|
@@ -156,6 +156,10 @@ module Killbill::Litle
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
def search(search_key, call_context = nil, options = {})
|
160
|
+
LitlePaymentMethod.search(search_key).map(&:to_payment_method_response)
|
161
|
+
end
|
162
|
+
|
159
163
|
private
|
160
164
|
|
161
165
|
def find_value_from_payment_method_props(payment_method_props, key)
|
@@ -179,10 +183,6 @@ module Killbill::Litle
|
|
179
183
|
"Report Group for #{currency.to_s}"
|
180
184
|
end
|
181
185
|
|
182
|
-
def get_token(kb_payment_method_id)
|
183
|
-
LitlePaymentMethod.from_kb_payment_method_id(kb_payment_method_id).litle_token
|
184
|
-
end
|
185
|
-
|
186
186
|
def save_response_and_transaction(litle_response, api_call, kb_payment_id=nil, amount_in_cents=0)
|
187
187
|
@logger.warn "Unsuccessful #{api_call}: #{litle_response.message}" unless litle_response.success?
|
188
188
|
|
@@ -35,9 +35,40 @@ module Killbill::Litle
|
|
35
35
|
payment_method.save!
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.search(search_key)
|
39
|
+
search_columns = [
|
40
|
+
:litle_token,
|
41
|
+
:cc_first_name,
|
42
|
+
:cc_last_name,
|
43
|
+
:cc_type,
|
44
|
+
:cc_exp_month,
|
45
|
+
:cc_exp_year,
|
46
|
+
:cc_last_4,
|
47
|
+
:address1,
|
48
|
+
:address2,
|
49
|
+
:city,
|
50
|
+
:state,
|
51
|
+
:zip,
|
52
|
+
:country
|
53
|
+
]
|
54
|
+
query = search_columns.map(&:to_s).join(' like ? or ') + ' like ?'
|
55
|
+
where(query, *search_columns.map { |e| "%#{search_key}%" })
|
56
|
+
end
|
57
|
+
|
38
58
|
def to_payment_method_response
|
39
59
|
properties = []
|
40
|
-
properties << create_pm_kv_info('token',
|
60
|
+
properties << create_pm_kv_info('token', external_payment_method_id)
|
61
|
+
properties << create_pm_kv_info('ccName', cc_name)
|
62
|
+
properties << create_pm_kv_info('ccType', cc_type)
|
63
|
+
properties << create_pm_kv_info('ccExpirationMonth', cc_exp_month)
|
64
|
+
properties << create_pm_kv_info('ccExpirationYear', cc_exp_year)
|
65
|
+
properties << create_pm_kv_info('ccLast4', cc_last_4)
|
66
|
+
properties << create_pm_kv_info('address1', address1)
|
67
|
+
properties << create_pm_kv_info('address2', address2)
|
68
|
+
properties << create_pm_kv_info('city', city)
|
69
|
+
properties << create_pm_kv_info('state', state)
|
70
|
+
properties << create_pm_kv_info('zip', zip)
|
71
|
+
properties << create_pm_kv_info('country', country)
|
41
72
|
|
42
73
|
pm_plugin = Killbill::Plugin::Model::PaymentMethodPlugin.new
|
43
74
|
pm_plugin.external_payment_method_id = external_payment_method_id
|
@@ -85,6 +116,10 @@ module Killbill::Litle
|
|
85
116
|
end
|
86
117
|
end
|
87
118
|
|
119
|
+
def to_litle_card_token
|
120
|
+
ActiveMerchant::Billing::LitleGateway::LitleCardToken.new(:token => litle_token, :month => cc_exp_month, :year => cc_exp_year)
|
121
|
+
end
|
122
|
+
|
88
123
|
private
|
89
124
|
|
90
125
|
def create_pm_kv_info(key, value)
|
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.
|
28
|
+
<version>1.5.0</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>
|
@@ -45,6 +45,10 @@ describe Killbill::Litle::PaymentPlugin do
|
|
45
45
|
pm_details = @plugin.get_payment_method_detail(pm.kb_account_id, pm.kb_payment_method_id)
|
46
46
|
pm_details.external_payment_method_id.should == pm.litle_token
|
47
47
|
|
48
|
+
pms_found = @plugin.search pm.cc_last_4
|
49
|
+
pms_found.size.should == 1
|
50
|
+
pms_found.first.external_payment_method_id.should == pm_details.external_payment_method_id
|
51
|
+
|
48
52
|
@plugin.delete_payment_method(pm.kb_account_id, pm.kb_payment_method_id)
|
49
53
|
|
50
54
|
@plugin.get_payment_methods(pm.kb_account_id).size.should == 0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Killbill::Litle::LitlePaymentMethod do
|
4
|
+
it 'should search all fields' do
|
5
|
+
Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
|
6
|
+
|
7
|
+
pm = Killbill::Litle::LitlePaymentMethod.create :kb_account_id => '11-22-33-44',
|
8
|
+
:kb_payment_method_id => '55-66-77-88',
|
9
|
+
:litle_token => 38102343,
|
10
|
+
:cc_first_name => 'ccFirstName',
|
11
|
+
:cc_last_name => 'ccLastName',
|
12
|
+
:cc_type => 'ccType',
|
13
|
+
:cc_exp_month => 10,
|
14
|
+
:cc_exp_year => 11,
|
15
|
+
:cc_last_4 => 1234,
|
16
|
+
:address1 => 'address1',
|
17
|
+
:address2 => 'address2',
|
18
|
+
:city => 'city',
|
19
|
+
:state => 'state',
|
20
|
+
:zip => 'zip',
|
21
|
+
:country => 'country'
|
22
|
+
|
23
|
+
Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
|
24
|
+
Killbill::Litle::LitlePaymentMethod.search(pm.litle_token).size.should == 1
|
25
|
+
Killbill::Litle::LitlePaymentMethod.search('cc').size.should == 1
|
26
|
+
Killbill::Litle::LitlePaymentMethod.search('address').size.should == 1
|
27
|
+
Killbill::Litle::LitlePaymentMethod.search(2343).size.should == 1
|
28
|
+
Killbill::Litle::LitlePaymentMethod.search('name').size.should == 1
|
29
|
+
Killbill::Litle::LitlePaymentMethod.search('Name').size.should == 1
|
30
|
+
|
31
|
+
pm2 = Killbill::Litle::LitlePaymentMethod.create :kb_account_id => '22-33-44-55',
|
32
|
+
:kb_payment_method_id => '66-77-88-99',
|
33
|
+
:litle_token => 49384029302,
|
34
|
+
:cc_first_name => 'ccFirstName',
|
35
|
+
:cc_last_name => 'ccLastName',
|
36
|
+
:cc_type => 'ccType',
|
37
|
+
:cc_exp_month => 10,
|
38
|
+
:cc_exp_year => 11,
|
39
|
+
:cc_last_4 => 1234,
|
40
|
+
:address1 => 'address1',
|
41
|
+
:address2 => 'address2',
|
42
|
+
:city => 'city',
|
43
|
+
:state => 'state',
|
44
|
+
:zip => 'zip',
|
45
|
+
:country => 'country'
|
46
|
+
|
47
|
+
Killbill::Litle::LitlePaymentMethod.search('foo').size.should == 0
|
48
|
+
Killbill::Litle::LitlePaymentMethod.search(pm.litle_token).size.should == 1
|
49
|
+
Killbill::Litle::LitlePaymentMethod.search(pm2.litle_token).size.should == 1
|
50
|
+
Killbill::Litle::LitlePaymentMethod.search('cc').size.should == 2
|
51
|
+
Killbill::Litle::LitlePaymentMethod.search('address').size.should == 2
|
52
|
+
Killbill::Litle::LitlePaymentMethod.search(2343).size.should == 1
|
53
|
+
Killbill::Litle::LitlePaymentMethod.search('name').size.should == 2
|
54
|
+
Killbill::Litle::LitlePaymentMethod.search('Name').size.should == 2
|
55
|
+
end
|
56
|
+
end
|
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.
|
4
|
+
version: 1.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: killbill
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.2.0
|
21
21
|
none: false
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.0
|
27
27
|
none: false
|
@@ -31,13 +31,13 @@ dependencies:
|
|
31
31
|
name: activemerchant
|
32
32
|
version_requirements: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ~>
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 2.0.0
|
37
37
|
none: false
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 2.0.0
|
43
43
|
none: false
|
@@ -47,13 +47,13 @@ dependencies:
|
|
47
47
|
name: activerecord
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- -
|
50
|
+
- - ~>
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 3.2.1
|
53
53
|
none: false
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ~>
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: 3.2.1
|
59
59
|
none: false
|
@@ -63,13 +63,13 @@ dependencies:
|
|
63
63
|
name: sinatra
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.3.4
|
69
69
|
none: false
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ~>
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 1.3.4
|
75
75
|
none: false
|
@@ -79,13 +79,13 @@ dependencies:
|
|
79
79
|
name: LitleOnline
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 8.16.0
|
85
85
|
none: false
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 8.16.0
|
91
91
|
none: false
|
@@ -95,13 +95,13 @@ dependencies:
|
|
95
95
|
name: xml-mapping
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - ~>
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 0.9.1
|
101
101
|
none: false
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ~>
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: 0.9.1
|
107
107
|
none: false
|
@@ -111,13 +111,13 @@ dependencies:
|
|
111
111
|
name: xml-object
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ~>
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 0.9.93
|
117
117
|
none: false
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ~>
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 0.9.93
|
123
123
|
none: false
|
@@ -127,13 +127,13 @@ dependencies:
|
|
127
127
|
name: activerecord-jdbcmysql-adapter
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ~>
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 1.2.9
|
133
133
|
none: false
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.2.9
|
139
139
|
none: false
|
@@ -143,13 +143,13 @@ dependencies:
|
|
143
143
|
name: jbundler
|
144
144
|
version_requirements: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
|
-
- -
|
146
|
+
- - ~>
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: 0.4.1
|
149
149
|
none: false
|
150
150
|
requirement: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - ~>
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: 0.4.1
|
155
155
|
none: false
|
@@ -159,13 +159,13 @@ dependencies:
|
|
159
159
|
name: rake
|
160
160
|
version_requirements: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
|
-
- -
|
162
|
+
- - '>='
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: 10.0.0
|
165
165
|
none: false
|
166
166
|
requirement: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - '>='
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: 10.0.0
|
171
171
|
none: false
|
@@ -175,13 +175,13 @@ dependencies:
|
|
175
175
|
name: rspec
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ~>
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 2.12.0
|
181
181
|
none: false
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- -
|
184
|
+
- - ~>
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: 2.12.0
|
187
187
|
none: false
|
@@ -191,13 +191,13 @@ dependencies:
|
|
191
191
|
name: activerecord-jdbcsqlite3-adapter
|
192
192
|
version_requirements: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- -
|
194
|
+
- - ~>
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: 1.2.6
|
197
197
|
none: false
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- -
|
200
|
+
- - ~>
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 1.2.6
|
203
203
|
none: false
|
@@ -209,8 +209,8 @@ executables: []
|
|
209
209
|
extensions: []
|
210
210
|
extra_rdoc_files: []
|
211
211
|
files:
|
212
|
-
-
|
213
|
-
-
|
212
|
+
- .gitignore
|
213
|
+
- .travis.yml
|
214
214
|
- Gemfile
|
215
215
|
- Jarfile
|
216
216
|
- NEWS
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- release.sh
|
239
239
|
- spec/litle/base_plugin_spec.rb
|
240
240
|
- spec/litle/integration_spec.rb
|
241
|
+
- spec/litle/litle_payment_method_spec.rb
|
241
242
|
- spec/litle/utils_spec.rb
|
242
243
|
- spec/spec_helper.rb
|
243
244
|
homepage: http://kill-bill.org
|
@@ -245,24 +246,23 @@ licenses:
|
|
245
246
|
- Apache License (2.0)
|
246
247
|
post_install_message:
|
247
248
|
rdoc_options:
|
248
|
-
-
|
249
|
-
-
|
249
|
+
- --exclude
|
250
|
+
- .
|
250
251
|
require_paths:
|
251
252
|
- lib
|
252
253
|
required_ruby_version: !ruby/object:Gem::Requirement
|
253
254
|
requirements:
|
254
|
-
- -
|
255
|
+
- - '>='
|
255
256
|
- !ruby/object:Gem::Version
|
256
257
|
version: 1.9.3
|
257
258
|
none: false
|
258
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
260
|
requirements:
|
260
|
-
- -
|
261
|
+
- - '>='
|
261
262
|
- !ruby/object:Gem::Version
|
262
263
|
segments:
|
263
264
|
- 0
|
264
|
-
version:
|
265
|
-
MA==
|
265
|
+
version: '0'
|
266
266
|
hash: 2
|
267
267
|
none: false
|
268
268
|
requirements: []
|
@@ -274,5 +274,6 @@ summary: Plugin to use Litle & Co. as a gateway.
|
|
274
274
|
test_files:
|
275
275
|
- spec/litle/base_plugin_spec.rb
|
276
276
|
- spec/litle/integration_spec.rb
|
277
|
+
- spec/litle/litle_payment_method_spec.rb
|
277
278
|
- spec/litle/utils_spec.rb
|
278
279
|
- spec/spec_helper.rb
|