Kill Bill OSGI Bridge plugin

Kill Bill Bridge plugin

License

License

Categories

Categories

Java Languages
GroupId

GroupId

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

ArtifactId

bridge-plugin
Last Version

Last Version

0.2.5
Release Date

Release Date

Type

Type

bundle
Description

Description

Kill Bill OSGI Bridge plugin
Kill Bill Bridge plugin
Project URL

Project URL

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

Source Code Management

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

Download bridge-plugin

Dependencies

provided (4)

Group / Artifact Type Version
com.google.code.findbugs : jsr305 jar 3.0.2
javax.servlet : javax.servlet-api jar 3.1.0
org.kill-bill.billing : killbill-api jar 0.53.7
org.kill-bill.billing.plugin : killbill-plugin-api-payment jar 0.26.1

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 3.0.0
org.kill-bill.commons : killbill-embeddeddb-common jar 0.23.2
org.kill-bill.commons : killbill-embeddeddb-mysql jar 0.23.2
org.kill-bill.commons : killbill-embeddeddb-mysql test-jar 0.23.2
org.mockito : mockito-all jar 1.10.19
org.testng : testng jar 6.14.3

Project Modules

There are no modules declared in this project.

Bridge plugin

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

Kill Bill compatibility

Plugin version Kill Bill version
0.0.y 0.19.z
0.1.y 0.20.z
0.2.y 0.21.z

Overview

The killbill-bridge-plugin, or in short bridge, is intended to bridge two deployments of Kill Bill, one used as a subscription/invoice engine (KB Subscription or in short KB-S) , and the other one used as an internal payment gateway (KB Payment or in short KB-P):

alt text

The bridge really plays two different functions, one of which is to offer a payment control layer, by implementing the Kill Bill payment control plugin api, and the other is the payment plugin itself by implementing the Kill Bill payment plugin api. The payment control layer is used to modify incoming payment requests prior it reaches the payment plugin operation itself (e.g authorization).

The KB-S system will provide all the normal functionality, including payment operations, but those will be delegated to KB-P. There are numerous reasons why a company would want to adopt this model:

  • Keeping invoice/subscription engine separate from payment system fits well in a micro-services architecture model
  • Related to previous micro-services architecture point, this also allows to decouple the responsabilties -- different teams, deployment schedule,...
  • Allow to fully leverage the internal payment gateway to implement more advanced things like payment routing, payment optimization, ... while keeping all this aspect hidden from core subscription/invoice engine
  • Different compliance scopes (SOX, PII, PCI, ...)

Models

There are two main models that we can identify, called respectively proxy and proxy-routing models:

  1. proxy model: The KB-P is used as a simple internal payment gateway but does not do any dynamic payment routing: In this model, each paymentMethod associated with an Account in KB-S reflects the plugin that should be used (e.g stripe) on the KB-P side -- that is, the pluginName associated to each paymentMethod will correctly show killbill-stripe in this example. The KB-P is completely transparent and really works as a proxy. NOTE This has only been partially impletemented **

  2. proxy-routing model: In this second model, the KB-P is used as a dynamic payment gateway. It can route payments based on rules such as latency, errors, BIN-level optimization, business-level rules -- mimimum volume to meet contract terms, ... In this case, creating a paymentMethod associated with an Account in the KB-S will not create a matching paymentMethod on the KB-P side; instead, the bridge will initiate all the payment requests with a null paymentMethodId and rely on the control payment layer on the KB-P side to automatically do the payment routing.

Configuration

This plugin implements the Kill Bill payment plugin api and is intended to connect as a bridge between a Kill Bill system operating for handling billing components (Subscriptions, Invoices, ...) and another Kill Bill system operating for handling payments.

The plugin will need to have the default configuration parameter to connect to the remote Kill Bill (payment) system. In addition for each tenant, the details of the api_key and api_secret will be required.

Here's a configuration example:

!!org.killbill.billing.plugin.bridge.BridgeConfig
killbillClientConfig:
  serverUrl: http://127.0.0.1:8080
  username: admin
  password: password
  apiKey: bob
  apiSecret: lazar
  # All other properties are optional
  proxyUrl:
  connectTimeOut:
  readTimeOut:
  requestTimeout:
  strictSSL:
  SSLProtocol:
paymentConfig:
  proxyModel: proxy
  # Defaults to internalPaymentMethodId
  internalPaymentMethodIdName:
  controlPlugins:
  pluginProperties:

In case you have a multi-regions deployment:

local: !!org.killbill.billing.plugin.bridge.BridgeConfig
  killbillClientConfig:
    &killbillClientConfigDefault
    username: admin
    password: password
    apiKey: bob
    apiSecret: lazar
  paymentConfig:
    &paymentConfigDefault

eu-central-1: !!org.killbill.billing.plugin.bridge.BridgeConfig
  killbillClientConfig:
    <<: *killbillClientConfigDefault
    serverUrl: http://kb.eu:8080
  paymentConfig:
    <<: *paymentConfigDefault

ap-northeast-2: !!org.killbill.billing.plugin.bridge.BridgeConfig
  killbillClientConfig:
    <<: *killbillClientConfigDefault
    serverUrl: http://kb.apac:8080
  paymentConfig:
    <<: *paymentConfigDefault

Internals

ID Mappings

Each KB system, KB-S and KB-P manages different objects entities (e.g Account) and those will have different ids on the different systems. Therefore in the most generic use case, the bridge will be responsible to make the id translation (e.g mapping a KB-S Account id with its counterpart KB-P Account id). In order to avoid keeping state in the plugin (id mapping table), we will use the externalKey associated with each object to keep this mapping:

The externalKey for each object (Account, PaymentMethod, Payment, PaymentTransaction) will be the same on both system. Because the PaymentPluginApi uses ids to refer all these objects, we need some mapping function for all objects. A typical mapping function wwill be (e.g accountId): KB-S (accountId) -> KB-S (Account) -> accountExternalKey -> KB-P (Account) -> KB-P (accountId).

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.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
0.0.12
0.0.11
0.0.10
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1