Friday, December 2, 2016

Introducing WSO2 ESB Connector for Kill Bill

Kill Bill is an open source platform for subscription billing and payments integration.Kill Bill helps enterprises by scaling their billing and payment infrastructure. It provides analytics and financial reports to make sure the businesses remain compliant.Its plug-in architecture allows us to apply custom logic easily and to integrate with dozens of payment gateways like PayPal, ACH,...

Now WSO2 ESB supports connecting Kill Bill via its Kill Bill connector. Kill Bill connector allows you to access the Kill Bill through its REST API. Let’s see how to configure the Kill Bill connector.

Requirements 
  • WSO2 ESB
  • Kill Bill connector
  • Kill Bill platform

Setup the Kill Bill
  • Follow the steps in here to install the Kill Bill.
  • Once you installed use the following curl command to create a tenant in Kill Bill.

curl -v \
     -X POST \
     -u admin:password \
     -H 'Content-Type: application/json' \
     -H 'X-Killbill-CreatedBy: admin' \
     -d '{"apiKey": "bob", "apiSecret": "lazar"}' \
     "http://127.0.0.1:8080/1.0/kb/tenants"


Setup the WSO2 ESB with Kill Bill Connector
  • Download the ESB from here and start the server.
  • Download the Kill Bill connector from WSO2 Store.
  • Add and enable the connector via ESB Management Console.
  • Create Proxy service to retrieve prospects details from Kill Bill and invoke the proxy with the following request.

Proxy Service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="createAccount"
       transports="http https"
       startOnLoad="true">
   <description/>
   <target>
      <inSequence>
         <property name="apiUrl" expression="json-eval($.apiUrl)"/>
         <property name="username" expression="json-eval($.username)"/>
         <property name="password" expression="json-eval($.password)"/>
         <property name="apiKey" expression="json-eval($.apiKey)"/>
         <property name="apiVersion" expression="json-eval($.apiVersion)"/>
         <property name="apiSecret" expression="json-eval($.apiSecret)"/>
         <property name="blocking" expression="json-eval($.blocking)"/>
         <property name="externalKey" expression="json-eval($.externalKey)"/>
         <property name="name" expression="json-eval($.name)"/>
         <property name="email" expression="json-eval($.email)"/>
         <property name="currency" expression="json-eval($.currency)"/>
         <property name="createdBy" expression="json-eval($.createdBy)"/>
         <killbill.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <username>{$ctx:username}</username>
            <password>{$ctx:password}</password>
            <apiKey>{$ctx:apiKey}</apiKey>
            <apiVersion>{$ctx:apiVersion}</apiVersion>
            <apiSecret>{$ctx:apiSecret}</apiSecret>
            <blocking>{$ctx:blocking}</blocking>
         </killbill.init>
         <killbill.createAccount>
            <externalKey>{$ctx:externalKey}</externalKey>
            <name>{$ctx:name}</name>
            <email>{$ctx:email}</email>
            <currency>{$ctx:currency}</currency>
            <createdBy>{$ctx:createdBy}</createdBy>
         </killbill.createAccount>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
</proxy>

Request

{
    "apiUrl":"http://127.0.0.1:8080",
    "apiVersion":"1.0",
    "username":"admin",
    "password":"password",
    "apiKey":"bob",
    "apiSecret":"lazar",
    "externalKey": "myAccount",
    "currency":"USD",
    "name": "testAccount",
    "email": "johndoe@gmail.com",
    "createdBy":"demo"
}

References
  1. https://killbill.io/
  2. https://docs.wso2.com/display/ESBCONNECTORS/Kill+Bill+Connector