Kill Bill OSGI Dwolla plugin

Kill Bill Dwolla plugin

License

License

Categories

Categories

Java Languages
GroupId

GroupId

org.kill-bill.billing.plugin.java
ArtifactId

ArtifactId

dwolla-plugin
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

bundle
Description

Description

Kill Bill OSGI Dwolla plugin
Kill Bill Dwolla plugin
Project URL

Project URL

http://github.com/killbill/killbill-dwolla-plugin
Source Code Management

Source Code Management

http://github.com/killbill/killbill-dwolla-plugin/tree/master

Download dwolla-plugin

Dependencies

provided (5)

Group / Artifact Type Version
com.google.code.findbugs : jsr305 jar 2.0.1
javax.servlet : javax.servlet-api jar 3.1.0
org.kill-bill.billing : killbill-api jar 0.50
org.kill-bill.billing.plugin : killbill-plugin-api-notification jar 0.23
org.kill-bill.billing.plugin : killbill-plugin-api-payment jar 0.23

test (10)

Group / Artifact Type Version
com.github.tomakehurst : wiremock jar 1.57
mysql : mysql-connector-java jar 5.1.33
mysql : mysql-connector-mxj jar 5.0.12
mysql : mysql-connector-mxj-db-files jar 5.0.12
org.kill-bill.billing.plugin.java : killbill-base-plugin test-jar 1.1.0
org.kill-bill.commons : killbill-embeddeddb-common jar 0.20
org.kill-bill.commons : killbill-embeddeddb-mysql jar 0.20
org.kill-bill.commons : killbill-embeddeddb-mysql test-jar 0.20
org.mockito : mockito-all jar 1.10.19
org.testng : testng jar 6.8.8

Project Modules

There are no modules declared in this project.

killbill-dwolla-plugin

Plugin to use Dwolla as a gateway. It supports both Dwolla Direct (co-branded product, easier to setup), as well as Dwolla White Label (for deeper integrations). Funding sources can be verified through both IAV (Instant Account Verification) and Micro-deposit verifications. You can even configure it to listen to webhooks, to get real-time notifications of the deposits status.

Release builds are available on Maven Central with coordinates org.kill-bill.billing.plugin.java:dwolla-plugin.

Kill Bill compatibility

Plugin version Kill Bill version
0.1.y 0.18.z

Requirements

The plugin needs a database. The latest version of the schema can be found here.

Merchants need to create a Dwolla application. The first time a token pair needs to be created from Dwolla Application page, and save into plugin database. The plugin offers two endpoints to creante and update this token pair.

// TO CREATE A NEW TOKEN PAIR
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 '{
           "accessToken": "<ACCESS-TOKEN>",
           "refreshToken": "<REFRESH-TOKEN>"
         }' \
     http://127.0.0.1:8080/plugins/killbill-dwolla

// TO UPDATE AN EXISTING TOKEN PAIR
curl -v \
     -X PUT \
     -u admin:password \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     -H 'X-Killbill-CreatedBy: admin' \
     -H 'Content-Type: text/plain' \
     -d '{
           "accessToken": "<ACCESS-TOKEN>",
           "refreshToken": "<REFRESH-TOKEN>"
         }' \
     http://127.0.0.1:8080/plugins/killbill-dwolla
    

A Webhook Subscription is needed to receive Dwolla notifications.

Build

To build the plugin locally, see https://github.com/Dwolla/dwolla-swagger-java/blob/master/README.md.

Configuration

The following properties are required:

  • org.killbill.billing.plugin.dwolla.baseUrl : REST Payment service url (i.e. https://api-uat.dwolla.com/ or https://api.dwolla.com/)
  • org.killbill.billing.plugin.dwolla.baseOAuthUrl : REST Auth service url (i.e. https://uat.dwolla.com/oauth/v2 or https://dwolla.com/oauth/v2)
  • org.killbill.billing.plugin.dwolla.scopes : The application scopes (i.e. Send|AccountInfoFull|Funding)
  • org.killbill.billing.plugin.dwolla.clientId : Your merchant application key.
  • org.killbill.billing.plugin.dwolla.clientSecret : Your merchant application secret.
  • org.killbill.billing.plugin.dwolla.accountId : Your merchant account id.

These properties can be specified globally via System Properties or on a per tenant basis:

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 'org.killbill.billing.plugin.dwolla.baseUrl=UUU
     org.killbill.billing.plugin.dwolla.baseOAuthUrl=VVV
     org.killbill.billing.plugin.dwolla.scopes=WWW
     org.killbill.billing.plugin.dwolla.clientId=XXX'
     org.killbill.billing.plugin.dwolla.clientSecret=YYY'
     org.killbill.billing.plugin.dwolla.accountId=ZZZ' \
     http://127.0.0.1:8080/1.0/kb/tenants/uploadPluginConfig/killbill-dwolla

Kill Bill

Usage

A full end-to-end integration demo is also available here.

Bank account

Add a payment method:

curl -v \
     -u admin:password \
     -H "X-Killbill-ApiKey: bob" \
     -H "X-Killbill-ApiSecret: lazar" \
     -H "Content-Type: application/json" \
     -H "X-Killbill-CreatedBy: demo" \
     -X POST \
     --data-binary '{
       "pluginName": "killbill-dwolla",
       "pluginInfo": {
         "properties": [
           {
             "key": "fundingSource",
             "value": "9ece9660-aa34-41eb-80d7-0125d53b45e8"
           },
           {
             "key": "customerId",
             "value": "ca32853c-48fa-40be-ae75-77b37504581b"
           }
         ]
       }
     }' \
     "http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/paymentMethods?isDefault=true"

Notes:

To trigger a payment:

curl -v \
     -u admin:password \
     -H "X-Killbill-ApiKey: bob" \
     -H "X-Killbill-ApiSecret: lazar" \
     -H "Content-Type: application/json" \
     -H "X-Killbill-CreatedBy: demo" \
     -X POST \
     --data-binary '{"transactionType":"PURCHASE","amount":"5","currency":"EUR","transactionExternalKey":"INV-'$(uuidgen)'-PURCHASE"}' \
    "http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/payments"

Notes:

  • Make sure to replace ACCOUNT_ID with the id of the Kill Bill account

At this point, the payment will be in PENDING state, until we receive a notification from Dwolla. You can verify the state of the transaction by listing the payments:

curl -v \
     -u admin:password \
     -H "X-Killbill-ApiKey: bob" \
     -H "X-Killbill-ApiSecret: lazar" \
     -H "Content-Type: application/json" \
     -H "X-Killbill-CreatedBy: demo" \
    "http://127.0.0.1:8080/1.0/kb/accounts/<ACCOUNT_ID>/payments?withPluginInfo=true"

You can simulate a notification from Dwolla as follows:

curl -v \
     -u admin:password \
     -H "X-Killbill-ApiKey: bob" \
     -H "X-Killbill-ApiSecret: lazar" \
     -H "Content-Type: application/json" \
     -H "X-Killbill-CreatedBy: demo" \
     -X POST \
     --data-binary '
     {
      "id": "80d8ff7d-7e5a-4975-ade8-9e97306d6c16",
      "topic": "customer_transfer_completed",
      "_links": {
        "self": {
          "href": "https://api-uat.dwolla.com/events/80d8ff7d-7e5a-4975-ade8-9e97306d6c16"
        },
        "account": {
          "href": "https://api-uat.dwolla.com/accounts/b3153e29-b25a-4ccd-9c1a-5b05b606e50c"
        },
        "resource": {
          "href": "https://api-uat.dwolla.com/transfers/7c8e7484-2184-e611-80e8-0aa34a9b2388"
        },
        "customer": {
          "href": "https://api-uat.dwolla.com/customers/b3153e29-b25a-4ccd-9c1a-5b05b606e50c"
        }
      }
    }' \
    "http://127.0.0.1:8080/1.0/kb/paymentGateways/notification/killbill-dwolla"

Notes:

  • Make sure to replace resource.href with the Dwolla transfer id reference of your payment (see the dwolla_responses table)
  • If topic is customer_transfer_completed, the payment transaction state will be SUCCESS and the payment state PROCESSED
  • If topic is customer_transfer_failed or customer_transfer_canceled, the payment transaction state will be PAYMENT_FAILURE and the payment state ERROR
org.kill-bill.billing.plugin.java

Kill Bill

Kill Bill has been the leading open-source platform for billing and payment since 2010.

Versions

Version
0.1.0