killbill-braintree_blue 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -19
- data/NEWS +6 -0
- data/README.md +219 -4
- data/VERSION +1 -1
- data/db/ddl.sql +1 -1
- data/lib/braintree_blue/api.rb +20 -18
- data/lib/braintree_blue/application.rb +18 -0
- data/lib/braintree_blue/ext/active_merchant/active_merchant.rb +40 -0
- data/lib/braintree_blue.rb +2 -0
- data/pom.xml +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f67df308d6753a2d7dbe3b4835d61afeb8a90bd5
|
|
4
|
+
data.tar.gz: 32e19fb2d8eb1f89f92e8d05dad9f8540716e67a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca5546f90c37178613b3b8a9dd0284980f38e3025160532ac04258266d2c3f3e5d9c2f62a2549af39b35925816c1a8591d95e4564306afe5b110dce03d45be8f
|
|
7
|
+
data.tar.gz: 57b16ad999435a2e71c71de1feda3f315613db5387843817130b5b6cd754dbf3cfcdd5049b5e35c036694732c960acbb3a5137bf7698be6d1d734e8ff41dfa3b
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
killbill-braintree_blue (0.2.
|
|
4
|
+
killbill-braintree_blue (0.2.1)
|
|
5
5
|
actionpack (~> 4.1.0)
|
|
6
6
|
actionview (~> 4.1.0)
|
|
7
7
|
activemerchant (~> 1.55.0)
|
|
@@ -20,13 +20,13 @@ PATH
|
|
|
20
20
|
GEM
|
|
21
21
|
remote: https://rubygems.org/
|
|
22
22
|
specs:
|
|
23
|
-
actionpack (4.1.
|
|
24
|
-
actionview (= 4.1.
|
|
25
|
-
activesupport (= 4.1.
|
|
23
|
+
actionpack (4.1.15)
|
|
24
|
+
actionview (= 4.1.15)
|
|
25
|
+
activesupport (= 4.1.15)
|
|
26
26
|
rack (~> 1.5.2)
|
|
27
27
|
rack-test (~> 0.6.2)
|
|
28
|
-
actionview (4.1.
|
|
29
|
-
activesupport (= 4.1.
|
|
28
|
+
actionview (4.1.15)
|
|
29
|
+
activesupport (= 4.1.15)
|
|
30
30
|
builder (~> 3.1)
|
|
31
31
|
erubis (~> 2.7.0)
|
|
32
32
|
active_utils (3.0.0)
|
|
@@ -37,17 +37,17 @@ GEM
|
|
|
37
37
|
builder (>= 2.1.2, < 4.0.0)
|
|
38
38
|
i18n (>= 0.6.9)
|
|
39
39
|
nokogiri (~> 1.4)
|
|
40
|
-
activemodel (4.1.
|
|
41
|
-
activesupport (= 4.1.
|
|
40
|
+
activemodel (4.1.15)
|
|
41
|
+
activesupport (= 4.1.15)
|
|
42
42
|
builder (~> 3.1)
|
|
43
|
-
activerecord (4.1.
|
|
44
|
-
activemodel (= 4.1.
|
|
45
|
-
activesupport (= 4.1.
|
|
43
|
+
activerecord (4.1.15)
|
|
44
|
+
activemodel (= 4.1.15)
|
|
45
|
+
activesupport (= 4.1.15)
|
|
46
46
|
arel (~> 5.0.0)
|
|
47
47
|
activerecord-bogacs (0.4.1)
|
|
48
|
-
activerecord-jdbc-adapter (1.3.
|
|
48
|
+
activerecord-jdbc-adapter (1.3.20)
|
|
49
49
|
activerecord (>= 2.2)
|
|
50
|
-
activesupport (4.1.
|
|
50
|
+
activesupport (4.1.15)
|
|
51
51
|
i18n (~> 0.6, >= 0.6.9)
|
|
52
52
|
json (~> 1.7, >= 1.7.7)
|
|
53
53
|
minitest (~> 5.1)
|
|
@@ -68,7 +68,7 @@ GEM
|
|
|
68
68
|
diff-lcs (1.1.3)
|
|
69
69
|
equalizer (0.0.11)
|
|
70
70
|
erubis (2.7.0)
|
|
71
|
-
ethon (0.8.
|
|
71
|
+
ethon (0.8.1)
|
|
72
72
|
ffi (>= 1.3.0)
|
|
73
73
|
ffi (1.9.10-java)
|
|
74
74
|
i18n (0.7.0)
|
|
@@ -81,21 +81,21 @@ GEM
|
|
|
81
81
|
ruby-maven (~> 3.3, >= 3.3.3)
|
|
82
82
|
jdbc-mariadb (1.2.3)
|
|
83
83
|
jdbc-sqlite3 (3.8.11.2)
|
|
84
|
-
jruby-openssl (0.9.
|
|
84
|
+
jruby-openssl (0.9.16-java)
|
|
85
85
|
json (1.8.3-java)
|
|
86
|
-
killbill (7.0.
|
|
86
|
+
killbill (7.0.3)
|
|
87
87
|
rack (>= 1.5.2)
|
|
88
88
|
sinatra (~> 1.3.4)
|
|
89
89
|
typhoeus (~> 0.6.9)
|
|
90
90
|
tzinfo (~> 1.2.0)
|
|
91
91
|
maven-tools (1.0.13)
|
|
92
92
|
virtus (~> 1.0)
|
|
93
|
-
minitest (5.8.
|
|
93
|
+
minitest (5.8.4)
|
|
94
94
|
monetize (1.1.0)
|
|
95
95
|
money (~> 6.5.0)
|
|
96
96
|
money (6.5.1)
|
|
97
97
|
i18n (>= 0.6.4, <= 0.7.0)
|
|
98
|
-
nokogiri (1.6.7.
|
|
98
|
+
nokogiri (1.6.7.2-java)
|
|
99
99
|
offsite_payments (2.1.0)
|
|
100
100
|
actionpack (>= 3.2.20, < 5.0.0)
|
|
101
101
|
active_utils (~> 3.0.0)
|
|
@@ -149,4 +149,4 @@ DEPENDENCIES
|
|
|
149
149
|
rspec (~> 2.12.0)
|
|
150
150
|
|
|
151
151
|
BUNDLED WITH
|
|
152
|
-
1.
|
|
152
|
+
1.11.2
|
data/NEWS
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
0.2.1
|
|
2
|
+
Fix merchant_id look-up in multi-tenancy configuration
|
|
3
|
+
Increase default message field length to 510
|
|
4
|
+
Add endpoint to generate token
|
|
5
|
+
Add ability to add additional cards on existing customer using nonce
|
|
6
|
+
|
|
1
7
|
0.2.0
|
|
2
8
|
Initial release for Kill Bill 0.16.x
|
|
3
9
|
|
data/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
killbill-braintree-plugin
|
|
2
2
|
=========================
|
|
3
3
|
|
|
4
|
-
Plugin
|
|
5
|
-
See original repo https://bitbucket.org/safekiddo/killbill-braintree-blue-plugin.git
|
|
4
|
+
Plugin to use [Braintree](https://www.braintreepayments.com/) as a gateway.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Release builds are available on [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.kill-bill.billing.plugin.ruby%22%20AND%20a%3A%22braintree_blue-plugin%22) with coordinates `org.kill-bill.billing.plugin.ruby:braintree_blue-plugin`.
|
|
7
|
+
|
|
8
|
+
This plugin was originally developed by [Ardura sp. z o.o.](https://bitbucket.org/safekiddo/killbill-braintree-blue-plugin.git).
|
|
9
9
|
|
|
10
10
|
Kill Bill compatibility
|
|
11
11
|
-----------------------
|
|
@@ -46,3 +46,218 @@ To go to production, create a `braintree_blue.yml` configuration file under `/va
|
|
|
46
46
|
:test: false
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Usage
|
|
50
|
+
-----
|
|
51
|
+
|
|
52
|
+
To create a customer and tokenize a credit card:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
curl -v \
|
|
56
|
+
-X POST \
|
|
57
|
+
-u admin:password \
|
|
58
|
+
-H 'X-Killbill-ApiKey: bob' \
|
|
59
|
+
-H 'X-Killbill-ApiSecret: lazar' \
|
|
60
|
+
-H 'X-Killbill-CreatedBy: admin' \
|
|
61
|
+
-H 'Content-Type: application/json' \
|
|
62
|
+
-d '{
|
|
63
|
+
"pluginName": "killbill-braintree_blue",
|
|
64
|
+
"pluginInfo": {
|
|
65
|
+
"properties": [
|
|
66
|
+
{
|
|
67
|
+
"key": "ccFirstName",
|
|
68
|
+
"value": "John"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"key": "ccLastName",
|
|
72
|
+
"value": "Doe"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"key": "address1",
|
|
76
|
+
"value": "5th Street"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"key": "city",
|
|
80
|
+
"value": "San Francisco"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"key": "zip",
|
|
84
|
+
"value": "94111"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"key": "state",
|
|
88
|
+
"value": "CA"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"key": "country",
|
|
92
|
+
"value": "US"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"key": "ccExpirationMonth",
|
|
96
|
+
"value": 12
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"key": "ccExpirationYear",
|
|
100
|
+
"value": 2017
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"key": "ccNumber",
|
|
104
|
+
"value": "4111111111111111"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}' \
|
|
109
|
+
"http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/paymentMethods?isDefault=true"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The token can then be used for payments:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
curl -v \
|
|
116
|
+
-X POST \
|
|
117
|
+
-u admin:password \
|
|
118
|
+
-H 'X-Killbill-ApiKey: bob' \
|
|
119
|
+
-H 'X-Killbill-ApiSecret: lazar' \
|
|
120
|
+
-H 'X-Killbill-CreatedBy: admin' \
|
|
121
|
+
-H 'Content-Type: application/json' \
|
|
122
|
+
-d '{
|
|
123
|
+
"transactionType": "AUTHORIZE",
|
|
124
|
+
"amount": 5
|
|
125
|
+
}' \
|
|
126
|
+
http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/payments
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Alternatively, if you are using the JS v2 SDK, generate a nonce as follows:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
<!DOCTYPE html>
|
|
133
|
+
<html>
|
|
134
|
+
<head>
|
|
135
|
+
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
|
|
136
|
+
</head>
|
|
137
|
+
<body>
|
|
138
|
+
<script>
|
|
139
|
+
var client = new braintree.api.Client({clientToken: token});
|
|
140
|
+
|
|
141
|
+
client.tokenizeCard({
|
|
142
|
+
number: "4111111111111111",
|
|
143
|
+
expirationDate: "10/20"
|
|
144
|
+
}, function (err, nonce) {
|
|
145
|
+
console.log(nonce);
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
</body>
|
|
149
|
+
</html>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
where `token` is the server-side generated client token. For convenience, the plugin provides an endpoint to generate it:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
curl http://127.0.0.1:8080/plugins/killbill-braintree_blue/token?kb_tenant_id=<TENANT_ID>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You can then create the customer with the nonce:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
curl -v \
|
|
162
|
+
-X POST \
|
|
163
|
+
-u admin:password \
|
|
164
|
+
-H 'X-Killbill-ApiKey: bob' \
|
|
165
|
+
-H 'X-Killbill-ApiSecret: lazar' \
|
|
166
|
+
-H 'X-Killbill-CreatedBy: admin' \
|
|
167
|
+
-H 'Content-Type: application/json' \
|
|
168
|
+
-d '{
|
|
169
|
+
"pluginName": "killbill-braintree_blue",
|
|
170
|
+
"pluginInfo": {
|
|
171
|
+
"properties": [
|
|
172
|
+
{
|
|
173
|
+
"key": "ccFirstName",
|
|
174
|
+
"value": "John"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"key": "ccLastName",
|
|
178
|
+
"value": "Doe"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"key": "address1",
|
|
182
|
+
"value": "5th Street"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"key": "city",
|
|
186
|
+
"value": "San Francisco"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"key": "zip",
|
|
190
|
+
"value": "94111"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"key": "state",
|
|
194
|
+
"value": "CA"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"key": "country",
|
|
198
|
+
"value": "US"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"key": "token",
|
|
202
|
+
"value": "<NONCE>"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
}' \
|
|
207
|
+
"http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/paymentMethods?isDefault=true"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
To add a second card on an existing customer using a nonce:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
curl -v \
|
|
214
|
+
-X POST \
|
|
215
|
+
-u admin:password \
|
|
216
|
+
-H 'X-Killbill-ApiKey: bob' \
|
|
217
|
+
-H 'X-Killbill-ApiSecret: lazar' \
|
|
218
|
+
-H 'X-Killbill-CreatedBy: admin' \
|
|
219
|
+
-H 'Content-Type: application/json' \
|
|
220
|
+
-d '{
|
|
221
|
+
"pluginName": "killbill-braintree_blue",
|
|
222
|
+
"pluginInfo": {
|
|
223
|
+
"properties": [
|
|
224
|
+
{
|
|
225
|
+
"key": "token",
|
|
226
|
+
"value": "<NONCE>"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
}' \
|
|
231
|
+
"http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/paymentMethods?isDefault=true"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Plugin properties
|
|
235
|
+
-----------------
|
|
236
|
+
|
|
237
|
+
| Key | Description |
|
|
238
|
+
| ---------------------------: | ----------------------------------------------------------------- |
|
|
239
|
+
| skip_gw | If true, skip the call to Braintree |
|
|
240
|
+
| payment_processor_account_id | Config entry name of the merchant account to use |
|
|
241
|
+
| external_key_as_order_id | If true, set the payment external key as the Braintree order id |
|
|
242
|
+
| customer | Braintree customer id |
|
|
243
|
+
| payment_method_nonce | Payment method nonce |
|
|
244
|
+
| token | Braintree token |
|
|
245
|
+
| cc_first_name | Credit card holder first name |
|
|
246
|
+
| cc_last_name | Credit card holder last name |
|
|
247
|
+
| cc_type | Credit card brand |
|
|
248
|
+
| cc_expiration_month | Credit card expiration month |
|
|
249
|
+
| cc_expiration_year | Credit card expiration year |
|
|
250
|
+
| cc_verification_value | CVC/CVV/CVN |
|
|
251
|
+
| email | Purchaser email |
|
|
252
|
+
| address1 | Billing address first line |
|
|
253
|
+
| address2 | Billing address second line |
|
|
254
|
+
| city | Billing address city |
|
|
255
|
+
| zip | Billing address zip code |
|
|
256
|
+
| state | Billing address state |
|
|
257
|
+
| country | Billing address country |
|
|
258
|
+
| eci | Network tokenization attribute |
|
|
259
|
+
| payment_cryptogram | Network tokenization attribute |
|
|
260
|
+
| transaction_id | Network tokenization attribute |
|
|
261
|
+
| payment_instrument_name | ApplePay tokenization attribute |
|
|
262
|
+
| payment_network | ApplePay tokenization attribute |
|
|
263
|
+
| transaction_identifier | ApplePay tokenization attribute |
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.1
|
data/db/ddl.sql
CHANGED
|
@@ -57,7 +57,7 @@ CREATE TABLE `braintree_blue_responses` (
|
|
|
57
57
|
`kb_payment_transaction_id` varchar(255) DEFAULT NULL,
|
|
58
58
|
`transaction_type` varchar(255) DEFAULT NULL,
|
|
59
59
|
`payment_processor_account_id` varchar(255) DEFAULT NULL,
|
|
60
|
-
`message` varchar(
|
|
60
|
+
`message` varchar(510) DEFAULT NULL,
|
|
61
61
|
`authorization` varchar(255) DEFAULT NULL,
|
|
62
62
|
`fraud_review` tinyint(1) DEFAULT NULL,
|
|
63
63
|
`test` tinyint(1) DEFAULT NULL,
|
data/lib/braintree_blue/api.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Killbill #:nodoc:
|
|
|
4
4
|
|
|
5
5
|
def initialize
|
|
6
6
|
gateway_builder = Proc.new do |config|
|
|
7
|
-
|
|
7
|
+
::ActiveMerchant::Billing::BraintreeBlueGateway.application_id = config[:channel] || 'killbill_SP'
|
|
8
8
|
::ActiveMerchant::Billing::BraintreeBlueGateway.new :merchant_id => config[:merchant_id],
|
|
9
9
|
:public_key => config[:public_key],
|
|
10
10
|
:private_key => config[:private_key]
|
|
@@ -30,7 +30,7 @@ module Killbill #:nodoc:
|
|
|
30
30
|
:payment_method_token => true
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
options.merge(get_merchant_id(currency))
|
|
33
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
34
34
|
|
|
35
35
|
properties = merge_properties(properties, options)
|
|
36
36
|
super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
@@ -39,7 +39,7 @@ module Killbill #:nodoc:
|
|
|
39
39
|
def capture_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
40
40
|
# Pass extra parameters for the gateway here
|
|
41
41
|
options = {}
|
|
42
|
-
options.merge(get_merchant_id(currency))
|
|
42
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
43
43
|
properties = merge_properties(properties, options)
|
|
44
44
|
super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
45
45
|
end
|
|
@@ -48,7 +48,7 @@ module Killbill #:nodoc:
|
|
|
48
48
|
options = {
|
|
49
49
|
:payment_method_token => true
|
|
50
50
|
}
|
|
51
|
-
options.merge(get_merchant_id(currency))
|
|
51
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
52
52
|
properties = merge_properties(properties, options)
|
|
53
53
|
super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
54
54
|
end
|
|
@@ -64,7 +64,7 @@ module Killbill #:nodoc:
|
|
|
64
64
|
options = {
|
|
65
65
|
:payment_method_token => true
|
|
66
66
|
}
|
|
67
|
-
options.merge(get_merchant_id(currency))
|
|
67
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
68
68
|
properties = merge_properties(properties, options)
|
|
69
69
|
super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
70
70
|
end
|
|
@@ -72,7 +72,7 @@ module Killbill #:nodoc:
|
|
|
72
72
|
def refund_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
73
73
|
# Pass extra parameters for the gateway here
|
|
74
74
|
options = {}
|
|
75
|
-
options.merge(get_merchant_id(currency))
|
|
75
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
76
76
|
properties = merge_properties(properties, options)
|
|
77
77
|
super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
|
|
78
78
|
end
|
|
@@ -88,7 +88,7 @@ module Killbill #:nodoc:
|
|
|
88
88
|
def search_payments(search_key, offset, limit, properties, context)
|
|
89
89
|
# Pass extra parameters for the gateway here
|
|
90
90
|
options = {}
|
|
91
|
-
options.merge(get_merchant_id(currency))
|
|
91
|
+
options.merge(get_merchant_id(currency, context.tenant_id))
|
|
92
92
|
properties = merge_properties(properties, options)
|
|
93
93
|
super(search_key, offset, limit, properties, context)
|
|
94
94
|
end
|
|
@@ -110,7 +110,7 @@ module Killbill #:nodoc:
|
|
|
110
110
|
!find_value_from_properties(payment_method_props.properties, :token).blank?
|
|
111
111
|
pm_props_hsh = properties_to_hash(payment_method_props.properties)
|
|
112
112
|
|
|
113
|
-
# Pass '
|
|
113
|
+
# Pass 'token' (along with CC details) or 'payment_method_nonce'
|
|
114
114
|
# For convenience, we translate 'token' into 'payment_method_nonce'
|
|
115
115
|
# Note: we remove the token because the Braintree AM implementation always requires a CreditCard object
|
|
116
116
|
options[:payment_method_nonce] = pm_props_hsh.delete(:token)
|
|
@@ -191,17 +191,19 @@ module Killbill #:nodoc:
|
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
-
def get_merchant_id(currency)
|
|
194
|
+
def get_merchant_id(currency, kb_tenant_id=nil)
|
|
195
|
+
config = ::Killbill::Plugin::ActiveMerchant.config(kb_tenant_id)
|
|
195
196
|
options = {}
|
|
196
|
-
if
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
197
|
+
if config[:braintree_blue][:multicurrency]
|
|
198
|
+
multicurrency = config[:multicurrency] || {}
|
|
199
|
+
case currency
|
|
200
|
+
when "USD"
|
|
201
|
+
options = {:merchant_account_id => multicurrency[:USD]}
|
|
202
|
+
when "EUR"
|
|
203
|
+
options = {:merchant_account_id => multicurrency[:EUR]}
|
|
204
|
+
when "PLN"
|
|
205
|
+
options = {:merchant_account_id => multicurrency[:PLN]}
|
|
206
|
+
end
|
|
205
207
|
end
|
|
206
208
|
options
|
|
207
209
|
end
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
set :views, File.expand_path(File.dirname(__FILE__) + '/views')
|
|
4
4
|
|
|
5
|
+
require 'braintree'
|
|
6
|
+
|
|
5
7
|
include Killbill::Plugin::ActiveMerchant::Sinatra
|
|
6
8
|
|
|
7
9
|
configure do
|
|
@@ -22,6 +24,22 @@ helpers do
|
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
|
|
27
|
+
# curl -v http://127.0.0.1:9292/plugins/killbill-braintree_blue/token
|
|
28
|
+
get '/plugins/killbill-braintree_blue/token', :provides => 'json' do
|
|
29
|
+
kb_tenant_id = request.GET['kb_tenant_id']
|
|
30
|
+
environment = request.GET['environment'] || 'sandbox'
|
|
31
|
+
customer_id = request.GET['customer_id']
|
|
32
|
+
|
|
33
|
+
bconfig = (config(kb_tenant_id) || {})[:braintree_blue] || {}
|
|
34
|
+
|
|
35
|
+
Braintree::Configuration.environment = environment.to_sym
|
|
36
|
+
Braintree::Configuration.merchant_id = bconfig[:merchant_id]
|
|
37
|
+
Braintree::Configuration.private_key = bconfig[:private_key]
|
|
38
|
+
Braintree::Configuration.public_key = bconfig[:public_key]
|
|
39
|
+
|
|
40
|
+
Braintree::ClientToken.generate(:customer_id => customer_id)
|
|
41
|
+
end
|
|
42
|
+
|
|
25
43
|
# curl -v http://127.0.0.1:9292/plugins/killbill-braintree_blue/form
|
|
26
44
|
get '/plugins/killbill-braintree_blue/form', :provides => 'html' do
|
|
27
45
|
order_id = request.GET['order_id']
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module ActiveMerchant
|
|
2
|
+
module Billing
|
|
3
|
+
class BraintreeBlueGateway
|
|
4
|
+
|
|
5
|
+
def add_credit_card_to_customer(credit_card, options)
|
|
6
|
+
commit do
|
|
7
|
+
if options[:payment_method_nonce]
|
|
8
|
+
credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
|
|
9
|
+
else
|
|
10
|
+
credit_card_params = {
|
|
11
|
+
token: options[:credit_card_token],
|
|
12
|
+
cardholder_name: credit_card.name,
|
|
13
|
+
number: credit_card.number,
|
|
14
|
+
cvv: credit_card.verification_value,
|
|
15
|
+
expiration_month: credit_card.month.to_s.rjust(2, "0"),
|
|
16
|
+
expiration_year: credit_card.year.to_s,
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
parameters = {
|
|
20
|
+
customer_id: options[:customer],
|
|
21
|
+
}.merge credit_card_params
|
|
22
|
+
|
|
23
|
+
options[:billing_address].compact!
|
|
24
|
+
parameters[:billing_address] = map_address(options[:billing_address]) unless options[:billing_address].empty?
|
|
25
|
+
|
|
26
|
+
result = @braintree_gateway.credit_card.create(parameters)
|
|
27
|
+
ActiveMerchant::Billing::Response.new(
|
|
28
|
+
result.success?,
|
|
29
|
+
message_from_result(result),
|
|
30
|
+
{
|
|
31
|
+
customer_vault_id: (result.credit_card.customer_id if result.success?),
|
|
32
|
+
credit_card_token: (result.credit_card.token if result.success?)
|
|
33
|
+
},
|
|
34
|
+
authorization: (result.credit_card.customer_id if result.success?)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/braintree_blue.rb
CHANGED
data/pom.xml
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<groupId>org.kill-bill.billing.plugin.ruby</groupId>
|
|
26
26
|
<artifactId>braintree_blue-plugin</artifactId>
|
|
27
27
|
<packaging>pom</packaging>
|
|
28
|
-
<version>0.2.
|
|
28
|
+
<version>0.2.1</version>
|
|
29
29
|
<name>braintree_blue-plugin</name>
|
|
30
30
|
<url>http://github.com/killbill/killbill-braintree_blue-plugin</url>
|
|
31
31
|
<description>Plugin for accessing BraintreeBlue as a payment gateway</description>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: killbill-braintree_blue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kill Bill core team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: killbill
|
|
@@ -303,6 +303,7 @@ files:
|
|
|
303
303
|
- lib/braintree_blue.rb
|
|
304
304
|
- lib/braintree_blue/api.rb
|
|
305
305
|
- lib/braintree_blue/application.rb
|
|
306
|
+
- lib/braintree_blue/ext/active_merchant/active_merchant.rb
|
|
306
307
|
- lib/braintree_blue/models/payment_method.rb
|
|
307
308
|
- lib/braintree_blue/models/response.rb
|
|
308
309
|
- lib/braintree_blue/models/transaction.rb
|
|
@@ -337,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
337
338
|
version: '0'
|
|
338
339
|
requirements: []
|
|
339
340
|
rubyforge_project:
|
|
340
|
-
rubygems_version: 2.
|
|
341
|
+
rubygems_version: 2.4.6
|
|
341
342
|
signing_key:
|
|
342
343
|
specification_version: 4
|
|
343
344
|
summary: Plugin to use BraintreeBlue as a gateway.
|