/killbill-adyen-plugin

Primary LanguageJavaApache License 2.0Apache-2.0

killbill-adyen-plugin

Plugin to use Adyen as a gateway.

Kill Bill compatibility

Plugin version Kill Bill version Adyen sdk version Checkout API Version
1.x.y 0.22.z 17.3.0 2022-04-07 Version 68

Requirements

The plugin needs a database. The latest version of the schema can be found (killbill-adyen-plugin\src\main\resources\ddl.sql).

Installation

Locally:

kpm install_java_plugin adyen --from-source-file target/adyen-plugin-*-SNAPSHOT.jar --destination /var/tmp/bundles

Configuration

Go to https://ca-test.adyen.com/ca/ca/config/api_credentials_new.shtml and copy your API key. Go to https://ca-test.adyen.com/ca/ca/config/showthirdparty.shtml and copy your HMAC Key and set your Return Url to http://127.0.0.1:8080/plugins/adyen-plugin/notification

Then, go to the Kaui plugin configuration page (/admin_tenants/1?active_tab=PluginConfig), and configure the adyen-plugin plugin with your key:

org.killbill.billing.plugin.adyen.apiKey=test_XXX
org.killbill.billing.plugin.adyen.returnUrl=test_XXX
org.killbill.billing.plugin.adyen.merchantAccount=test_XXX
org.killbill.billing.plugin.adyen.hcmaKey=test_XXX
org.killbill.billing.plugin.adyen.enviroment= (TEST/LIVE) default is TEST
org.killbill.billing.plugin.adyen.password= (KillBill password)
org.killbill.billing.plugin.adyen.username= (KillBill username)
org.killbill.billing.plugin.adyen.captureDelayHours=XX (Desire capture delay in hours after Authorize , number must be between 0 - 168 hr) 

Alternatively, you can upload the configuration directly:

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.adyen.apiKey=test_XXX
org.killbill.billing.plugin.adyen.returnUrl=test_XXX
org.killbill.billing.plugin.adyen.merchantAccount=test_XXX
org.killbill.billing.plugin.adyen.hcmaKey=test_XXX
org.killbill.billing.plugin.adyen.captureDelayHours=XX
org.killbill.billing.plugin.adyen.password=xxx
org.killbill.billing.plugin.adyen.username=xxx ' \
     http://127.0.0.1:8080/1.0/kb/tenants/uploadPluginConfig/adyen-plugin

Payment Method flow

The plugin create the first payment via servlet using /sessions here. If the payment is recurring, we store the token generated by Adyen then it can be used multiples times on /payments here. After generating the session, the component (UI Drop-in) will be used to send the payment. Adyen will process the received payment and through notification will inform the plugin/killbill the result of said payment. This link refers to the returnUrl discussed later.

Using Adyen Checkout

This plugin implementation is using Drop-in integration here or Web Components here

  1. Create a Kill Bill account and Kill Bill Payment (as a PluginProperty need to be sended enableRecurring = true if the payment is going to be recurring , if not can sent enableRecurring=false or simply ignore it ( by default is false)).
curl -v \
    -X POST \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "X-Killbill-CreatedBy: demo" \
    -H "X-Killbill-Reason: demo" \
    -H "X-Killbill-Comment: demo" \
    -d '{ "accountId": "2ad52f53-85ae-408a-9879-32a7e59dd03d", "pluginName": "adyen-plugin" ,"isDefault": true, "pluginInfo": { "isDefaultPaymentMethod": true, "properties": [ { "key": "enableRecurring", "value": "true", "isUpdatable": false } }' \
    "http://127.0.0.1:8080/1.0/kb/accounts/8785164f-b5d7-4da1-9495-33f5105e8d80/paymentMethods" 
  1. Call /plugins/adyen-plugin/checkout to generate a Session where the amount needs to have the decimals point if the currency have it:
curl -v \
     -X POST \
     -u admin:password \
     -H "X-Killbill-ApiKey: bob" \
     -H "X-Killbill-ApiSecret: lazar" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -H "X-Killbill-CreatedBy: demo" \
     -H "X-Killbill-Reason: demo" \
     -H "X-Killbill-Comment: demo" \
     "http://127.0.0.1:8080/plugins/adyen-plugin/checkout?kbAccountId=<KB_ACCOUNT_ID>&amount=<amount?&kbPaymentMethodId=<KB_PAYMENT_METHOD_ID>"
  1. Redirect the user to the Adyen checkout page. The sessionId and sessionData are returned as part of the formFields (id key):