killbill-litle 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +55 -5
- data/VERSION +1 -1
- data/db/ddl.sql +12 -0
- data/db/schema.rb +12 -0
- data/lib/litle/api.rb +21 -2
- data/lib/litle/models/litle_payment_method.rb +43 -2
- data/pom.xml +1 -1
- data/spec/litle/integration_spec.rb +43 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Usage
|
|
16
16
|
|
17
17
|
Go to http://$HOST:8080/plugins/killbill-litle?kb_account_id=13d26090-b8d7-11e2-9e96-0800200c9a66 and enter your credit card information.
|
18
18
|
|
19
|
-
Then, save the token in Kill Bill:
|
19
|
+
Then, save the token in Kill Bill (only `paypageRegistrationId` is required in the properties):
|
20
20
|
|
21
21
|
```
|
22
22
|
curl -v \
|
@@ -27,10 +27,60 @@ curl -v \
|
|
27
27
|
--data-binary '{
|
28
28
|
"pluginName": "killbill-litle",
|
29
29
|
"pluginInfo": {
|
30
|
-
"properties": [
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
"properties": [
|
31
|
+
{
|
32
|
+
"key": "paypageRegistrationId",
|
33
|
+
"value": "t3GER3BP3JHLASZe"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"key": "ccFirstName",
|
37
|
+
"value": "John"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"key": "ccLastName",
|
41
|
+
"value": "Doe"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"key": "ccType",
|
45
|
+
"value": "VISA"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"key": "ccExpMonth",
|
49
|
+
"value": 12
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"key": "ccExpYear",
|
53
|
+
"value": 2015
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"key": "ccLast4",
|
57
|
+
"value": 1234
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"key": "address1",
|
61
|
+
"value": "5, oakriu road"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"key": "address2",
|
65
|
+
"value": "apt. 298"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"key": "city",
|
69
|
+
"value": "Gdio Foia"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"key": "state",
|
73
|
+
"value": "FL"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"key": "zip",
|
77
|
+
"value": "49302"
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"key": "country",
|
81
|
+
"value": "IFP"
|
82
|
+
}
|
83
|
+
]
|
34
84
|
}
|
35
85
|
}' \
|
36
86
|
"http://$HOST:8080/1.0/kb/accounts/13d26090-b8d7-11e2-9e96-0800200c9a66/paymentMethods?isDefault=true"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.12
|
data/db/ddl.sql
CHANGED
@@ -3,6 +3,18 @@ CREATE TABLE `litle_payment_methods` (
|
|
3
3
|
`kb_account_id` varchar(255) NOT NULL,
|
4
4
|
`kb_payment_method_id` varchar(255) DEFAULT NULL,
|
5
5
|
`litle_token` varchar(255) NOT NULL,
|
6
|
+
`cc_first_name` varchar(255) DEFAULT NULL,
|
7
|
+
`cc_last_name` varchar(255) DEFAULT NULL,
|
8
|
+
`cc_type` varchar(255) DEFAULT NULL,
|
9
|
+
`cc_exp_month` int(11) DEFAULT NULL,
|
10
|
+
`cc_exp_year` int(11) DEFAULT NULL,
|
11
|
+
`cc_last_4` int(11) DEFAULT NULL,
|
12
|
+
`address1` varchar(255) DEFAULT NULL,
|
13
|
+
`address2` varchar(255) DEFAULT NULL,
|
14
|
+
`city` varchar(255) DEFAULT NULL,
|
15
|
+
`state` varchar(255) DEFAULT NULL,
|
16
|
+
`zip` varchar(255) DEFAULT NULL,
|
17
|
+
`country` varchar(255) DEFAULT NULL,
|
6
18
|
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
7
19
|
`created_at` datetime NOT NULL,
|
8
20
|
`updated_at` datetime NOT NULL,
|
data/db/schema.rb
CHANGED
@@ -5,6 +5,18 @@ ActiveRecord::Schema.define(:version => 20130311153635) do
|
|
5
5
|
t.string "kb_account_id", :null => false
|
6
6
|
t.string "kb_payment_method_id" # NULL before Killbill knows about it
|
7
7
|
t.string "litle_token", :null => false
|
8
|
+
t.string "cc_first_name"
|
9
|
+
t.string "cc_last_name"
|
10
|
+
t.string "cc_type"
|
11
|
+
t.integer "cc_exp_month"
|
12
|
+
t.integer "cc_exp_year"
|
13
|
+
t.integer "cc_last_4"
|
14
|
+
t.string "address1"
|
15
|
+
t.string "address2"
|
16
|
+
t.string "city"
|
17
|
+
t.string "state"
|
18
|
+
t.string "zip"
|
19
|
+
t.string "country"
|
8
20
|
t.boolean "is_deleted", :null => false, :default => false
|
9
21
|
t.datetime "created_at", :null => false
|
10
22
|
t.datetime "updated_at", :null => false
|
data/lib/litle/api.rb
CHANGED
@@ -71,12 +71,26 @@ module Killbill::Litle
|
|
71
71
|
options[:merchant] ||= report_group_for_account(kb_account_id)
|
72
72
|
|
73
73
|
# TODO Add support for real credit cards
|
74
|
-
token =
|
74
|
+
token = find_value_from_payment_method_props payment_method_props, 'paypageRegistrationId'
|
75
75
|
litle_response = @gateway.store token, options
|
76
76
|
response = save_response_and_transaction litle_response, :add_payment_method
|
77
77
|
|
78
78
|
if response.success
|
79
|
-
LitlePaymentMethod.create :kb_account_id => kb_account_id.to_s,
|
79
|
+
LitlePaymentMethod.create :kb_account_id => kb_account_id.to_s,
|
80
|
+
:kb_payment_method_id => kb_payment_method_id.to_s,
|
81
|
+
:litle_token => response.litle_token,
|
82
|
+
:cc_first_name => find_value_from_payment_method_props(payment_method_props, 'ccFirstName'),
|
83
|
+
:cc_last_name => find_value_from_payment_method_props(payment_method_props, 'ccLastName'),
|
84
|
+
:cc_type => find_value_from_payment_method_props(payment_method_props, 'ccType'),
|
85
|
+
:cc_exp_month => find_value_from_payment_method_props(payment_method_props, 'ccExpMonth'),
|
86
|
+
:cc_exp_year => find_value_from_payment_method_props(payment_method_props, 'ccExpYear'),
|
87
|
+
:cc_last_4 => find_value_from_payment_method_props(payment_method_props, 'ccLast4'),
|
88
|
+
:address1 => find_value_from_payment_method_props(payment_method_props, 'address1'),
|
89
|
+
:address2 => find_value_from_payment_method_props(payment_method_props, 'address2'),
|
90
|
+
:city => find_value_from_payment_method_props(payment_method_props, 'city'),
|
91
|
+
:state => find_value_from_payment_method_props(payment_method_props, 'state'),
|
92
|
+
:zip => find_value_from_payment_method_props(payment_method_props, 'zip'),
|
93
|
+
:country => find_value_from_payment_method_props(payment_method_props, 'country')
|
80
94
|
else
|
81
95
|
raise response.message
|
82
96
|
end
|
@@ -104,6 +118,11 @@ module Killbill::Litle
|
|
104
118
|
|
105
119
|
private
|
106
120
|
|
121
|
+
def find_value_from_payment_method_props(payment_method_props, key)
|
122
|
+
prop = (payment_method_props.properties.find { |kv| kv.key == key })
|
123
|
+
prop.nil? ? nil : prop.value
|
124
|
+
end
|
125
|
+
|
107
126
|
def report_group_for_account(kb_account_id)
|
108
127
|
account = @kb_apis.get_account_by_id(kb_account_id)
|
109
128
|
currency = account.currency
|
@@ -1,6 +1,20 @@
|
|
1
1
|
module Killbill::Litle
|
2
2
|
class LitlePaymentMethod < ActiveRecord::Base
|
3
|
-
attr_accessible :kb_account_id,
|
3
|
+
attr_accessible :kb_account_id,
|
4
|
+
:kb_payment_method_id,
|
5
|
+
:litle_token,
|
6
|
+
:cc_first_name,
|
7
|
+
:cc_last_name,
|
8
|
+
:cc_type,
|
9
|
+
:cc_exp_month,
|
10
|
+
:cc_exp_year,
|
11
|
+
:cc_last_4,
|
12
|
+
:address1,
|
13
|
+
:address2,
|
14
|
+
:city,
|
15
|
+
:state,
|
16
|
+
:zip,
|
17
|
+
:country
|
4
18
|
|
5
19
|
def self.from_kb_account_id(kb_account_id)
|
6
20
|
find_all_by_kb_account_id_and_is_deleted(kb_account_id, false)
|
@@ -27,7 +41,22 @@ module Killbill::Litle
|
|
27
41
|
properties = []
|
28
42
|
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, "token", litle_token)
|
29
43
|
|
30
|
-
Killbill::Plugin::Model::PaymentMethodPlugin.new(external_payment_method_id,
|
44
|
+
Killbill::Plugin::Model::PaymentMethodPlugin.new(external_payment_method_id,
|
45
|
+
is_default,
|
46
|
+
properties,
|
47
|
+
nil,
|
48
|
+
'CreditCard',
|
49
|
+
cc_name,
|
50
|
+
cc_type,
|
51
|
+
cc_exp_month,
|
52
|
+
cc_exp_year,
|
53
|
+
cc_last_4,
|
54
|
+
address1,
|
55
|
+
address2,
|
56
|
+
city,
|
57
|
+
state,
|
58
|
+
zip,
|
59
|
+
country)
|
31
60
|
end
|
32
61
|
|
33
62
|
def to_payment_method_info_response
|
@@ -37,5 +66,17 @@ module Killbill::Litle
|
|
37
66
|
|
38
67
|
Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(kb_account_id, kb_payment_method_id, is_default, external_payment_method_id)
|
39
68
|
end
|
69
|
+
|
70
|
+
def cc_name
|
71
|
+
if cc_first_name and cc_last_name
|
72
|
+
"#{cc_first_name} #{cc_last_name}"
|
73
|
+
elsif cc_first_name
|
74
|
+
cc_first_name
|
75
|
+
elsif cc_last_name
|
76
|
+
cc_last_name
|
77
|
+
else
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
40
81
|
end
|
41
82
|
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.
|
28
|
+
<version>1.0.12</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>
|
@@ -111,13 +111,55 @@ describe Killbill::Litle::PaymentPlugin do
|
|
111
111
|
|
112
112
|
# Generate a token in Litle
|
113
113
|
paypage_registration_id = '123456789012345678901324567890abcdefghi'
|
114
|
-
|
114
|
+
cc_first_name = 'John'
|
115
|
+
cc_last_name = 'Doe'
|
116
|
+
cc_type = 'VISA'
|
117
|
+
cc_exp_month = 12
|
118
|
+
cc_exp_year = 2015
|
119
|
+
cc_last_4 = 1234
|
120
|
+
address1 = '5, oakriu road'
|
121
|
+
address2 = 'apt. 298'
|
122
|
+
city = 'Gdio Foia'
|
123
|
+
state = 'FL'
|
124
|
+
zip = 49302
|
125
|
+
country = 'IFP'
|
126
|
+
|
127
|
+
properties = []
|
128
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'paypageRegistrationId', paypage_registration_id)
|
129
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccFirstName', cc_first_name)
|
130
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccLastName', cc_last_name)
|
131
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccType', cc_type)
|
132
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccExpMonth', cc_exp_month)
|
133
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccExpYear', cc_exp_year)
|
134
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'ccLast4', cc_last_4)
|
135
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'address1', address1)
|
136
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'address2', address2)
|
137
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'city', city)
|
138
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'state', state)
|
139
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'zip', zip)
|
140
|
+
properties << Killbill::Plugin::Model::PaymentMethodKVInfo.new(false, 'country', country)
|
141
|
+
|
142
|
+
info = Killbill::Plugin::Model::PaymentMethodPlugin.new nil, nil, properties, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil
|
115
143
|
payment_method = @plugin.add_payment_method(kb_account_id, kb_payment_method_id, info, true, @call_context)
|
116
144
|
|
117
145
|
pm = Killbill::Litle::LitlePaymentMethod.from_kb_payment_method_id kb_payment_method_id
|
146
|
+
pm.should == payment_method
|
118
147
|
pm.kb_account_id.should == kb_account_id
|
119
148
|
pm.kb_payment_method_id.should == kb_payment_method_id
|
120
149
|
pm.litle_token.should_not be_nil
|
150
|
+
pm.cc_first_name.should == cc_first_name
|
151
|
+
pm.cc_last_name.should == cc_last_name
|
152
|
+
pm.cc_type.should == cc_type
|
153
|
+
pm.cc_exp_month.should == cc_exp_month
|
154
|
+
pm.cc_exp_year.should == cc_exp_year
|
155
|
+
pm.cc_last_4.should == cc_last_4
|
156
|
+
pm.address1.should == address1
|
157
|
+
pm.address2.should == address2
|
158
|
+
pm.city.should == city
|
159
|
+
pm.state.should == state
|
160
|
+
pm.zip.should == zip.to_s
|
161
|
+
pm.country.should == country
|
162
|
+
|
121
163
|
pm
|
122
164
|
end
|
123
165
|
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.0.
|
4
|
+
version: 1.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: killbill
|