killbill-braintree-plugin ========================= Plugin to use [Braintree](https://www.braintreepayments.com/) as a gateway. 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`. This plugin was originally developed by [Ardura sp. z o.o.](https://bitbucket.org/safekiddo/killbill-braintree-blue-plugin.git). Kill Bill compatibility ----------------------- | Plugin version | Kill Bill version | | -------------: | ----------------: | | 0.0.y | 0.14.z | | 0.2.y | 0.16.z | | 0.3.y | 0.18.z | Requirements ------------ The plugin needs a database. The latest version of the schema can be found [here](https://github.com/killbill/killbill-braintree-blue-plugin/blob/master/db/ddl.sql). Configuration ------------- ``` curl -v \ -X POST \ -u admin:password \ -H 'X-Killbill-ApiKey: bob' \ -H 'X-Killbill-ApiSecret: lazar' \ -H 'X-Killbill-CreatedBy: admin' \ -H 'Content-Type: text/plain' \ -d ':braintree_blue: :merchant_id: ABC :public_key: DEF :private_key: GHI' \ http://127.0.0.1:8080/1.0/kb/tenants/uploadPluginConfig/killbill-braintree_blue ``` To go to production, create a `braintree_blue.yml` configuration file under `/var/tmp/bundles/plugins/ruby/killbill-braintree-blue/x.y.z/` containing the following: ``` :braintree_blue: :test: false ``` Usage ----- To create a customer and tokenize a credit card: ``` curl -v \ -X POST \ -u admin:password \ -H 'X-Killbill-ApiKey: bob' \ -H 'X-Killbill-ApiSecret: lazar' \ -H 'X-Killbill-CreatedBy: admin' \ -H 'Content-Type: application/json' \ -d '{ "pluginName": "killbill-braintree_blue", "pluginInfo": { "properties": [ { "key": "ccFirstName", "value": "John" }, { "key": "ccLastName", "value": "Doe" }, { "key": "address1", "value": "5th Street" }, { "key": "city", "value": "San Francisco" }, { "key": "zip", "value": "94111" }, { "key": "state", "value": "CA" }, { "key": "country", "value": "US" }, { "key": "ccExpirationMonth", "value": 12 }, { "key": "ccExpirationYear", "value": 2017 }, { "key": "ccNumber", "value": "4111111111111111" } ] } }' \ "http://127.0.0.1:8080/1.0/kb/accounts//paymentMethods?isDefault=true" ``` The token can then be used for payments: ``` curl -v \ -X POST \ -u admin:password \ -H 'X-Killbill-ApiKey: bob' \ -H 'X-Killbill-ApiSecret: lazar' \ -H 'X-Killbill-CreatedBy: admin' \ -H 'Content-Type: application/json' \ -d '{ "transactionType": "AUTHORIZE", "amount": 5 }' \ http://127.0.0.1:8080/1.0/kb/accounts//payments ``` Alternatively, if you are using the JS v2 SDK, generate a nonce as follows: ``` ``` where `token` is the server-side generated client token. For convenience, the plugin provides an endpoint to generate it: ``` curl http://127.0.0.1:8080/plugins/killbill-braintree_blue/token?kb_tenant_id= ``` You can then create the customer with the nonce: ``` curl -v \ -X POST \ -u admin:password \ -H 'X-Killbill-ApiKey: bob' \ -H 'X-Killbill-ApiSecret: lazar' \ -H 'X-Killbill-CreatedBy: admin' \ -H 'Content-Type: application/json' \ -d '{ "pluginName": "killbill-braintree_blue", "pluginInfo": { "properties": [ { "key": "ccFirstName", "value": "John" }, { "key": "ccLastName", "value": "Doe" }, { "key": "address1", "value": "5th Street" }, { "key": "city", "value": "San Francisco" }, { "key": "zip", "value": "94111" }, { "key": "state", "value": "CA" }, { "key": "country", "value": "US" }, { "key": "token", "value": "" } ] } }' \ "http://127.0.0.1:8080/1.0/kb/accounts//paymentMethods?isDefault=true" ``` To add a second card on an existing customer using a nonce: ``` curl -v \ -X POST \ -u admin:password \ -H 'X-Killbill-ApiKey: bob' \ -H 'X-Killbill-ApiSecret: lazar' \ -H 'X-Killbill-CreatedBy: admin' \ -H 'Content-Type: application/json' \ -d '{ "pluginName": "killbill-braintree_blue", "pluginInfo": { "properties": [ { "key": "token", "value": "" } ] } }' \ "http://127.0.0.1:8080/1.0/kb/accounts//paymentMethods?isDefault=true" ``` A full end-to-end integration demo is also available [here](https://github.com/killbill/killbill-braintree-demo). Plugin properties ----------------- | Key | Description | | ---------------------------: | ----------------------------------------------------------------- | | skip_gw | If true, skip the call to Braintree | | payment_processor_account_id | Config entry name of the merchant account to use | | external_key_as_order_id | If true, set the payment external key as the Braintree order id | | customer | Braintree customer id | | payment_method_nonce | Payment method nonce | | token | Braintree token | | cc_first_name | Credit card holder first name | | cc_last_name | Credit card holder last name | | cc_type | Credit card brand | | cc_expiration_month | Credit card expiration month | | cc_expiration_year | Credit card expiration year | | cc_verification_value | CVC/CVV/CVN | | email | Purchaser email | | address1 | Billing address first line | | address2 | Billing address second line | | city | Billing address city | | zip | Billing address zip code | | state | Billing address state | | country | Billing address country | | eci | Network tokenization attribute | | payment_cryptogram | Network tokenization attribute | | transaction_id | Network tokenization attribute | | payment_instrument_name | ApplePay tokenization attribute | | payment_network | ApplePay tokenization attribute | | transaction_identifier | ApplePay tokenization attribute |