Kill Bill platform guide

Overview

Kill Bill Platform

At its core, Kill Bill offers a flexible platform on which applications that require a high level of integrity, audit traces, and robustness can be developed. Currently there are two kind of applications that have been developed:

The Billing System relies on the Payment System to make payments but the Payment System also offers direct payment APIs and therefore can also be run as a standalone application.

Some of the features of the Kill Bill platform include:

Core Foundations

A plugin framework where custom plugins can be added to modify the behavior of the system, and/or interact with third party systems,

A robust persistent event bus, that is used both internally and externally (events are visible to plugins)

An auditing framework that keeps track of all the changes that occurred (who?, when?, what?)

Authentication and RBAC support

Core services (account management, invoicing, entitlement, dunning, …​) which are built and packaged as independent jars, each of which with its own APIs; those core services post a well defined set of events on the persistent bus which are then consumed by other core services or plugins.

Plugins

Contrary to most billing solutions, Kill Bill is not a batch oriented system, but instead, it is driven by events occurring in the system (for example, the creation of a new subscription will create a new event that the invoicing core service will process and as result a new invoice may be created along with a new event, which the payment core service will then process, …​).

Kill Bill is traditionally packaged as a war and is therefore executed within a web container (for example Tomcat). It offers REST APIs to manage the state associated with accounts, subscriptions, invoices, payments, …​ It also provides lower level (Java) APIs and can therefore be embedded as a library within a (Java) user application.

Documentation

Our documentation is targeted for different types of audience:

Kill Bill Visitors: technical or non-technical folks interested to know more about what Kill Bill is about.

Kill Bill Users: technical folks that are interested to evaluate the solution or are ready to deploy it.

Kill Bill Developers: technical folks that are interested to contribute to the open-source project (often to enhance the platform to suit their own specific needs).

For mode advanced usage, you can also use the source code and rely on the start-server script

Depending on your use case, you will need to configure your catalog, and develop/deploy plugins

Kill Bill Platform Features

Multi-Tenancy

Kill Bill supports multi-tenancy, meaning you can run multiple logical instances of Kill Bill with a single server and database. This is the default way to deploy Kill Bill.
We posted a blog post which illustrates some of the use cases for running Kill Bill in a multi-tenant fashion.

The call above will create the tenant and that tenant will be identified with its own tenantId. The supplied apiKey needs to be unique across all the tenants. The tenantId is immutable but the apiKey and apiSecret can be updated in the event they are compromised.

Each subsequent (REST) API call will require the following two headers (for Kill Bill to identity which tenant that call is targeted to, and verify the user has the right to access that tenant):

X-Killbill-ApiKey

X-Killbill-ApiSecret

RBAC

Kill Bill’s authentication and authorization relies on Apache Shiro.
In a nutshell, Shiro allows you to configure a set of Users, where each User is associated with a set of Roles, and each Role contains a set of Permissions.

Kill Bill (through Shiro) supports the following types of configuration:

File based configuration (shiro.ini). This is the default configuration embedded in Kill Bill, which provides you with one admin user having all the rights.

Database configuration: Kill Bill offers a set of endpoints to add users, roles, and permissions

LDAP: Kill Bill can also interact with a LDAP directory to retrieve the users, roles and permissions. The configuration happens through system properties.

Note that all those 3 mechanisms can coexist, and often need to coexist to solve the chicken and egg problem of requiring permissions to add new users, roles, …​ through APIs.

The following blog post gives an overview of how our admin UI interacts with Kill Bill and takes advantage of the RBAC features.

Plugins

Overview

Kill Bill supports a powerful plugin framework based on the OSGI standard.
The purpose of OSGI based plugins is to ensure that they are isolated from each other and from the core platform, allowing Kill Bill users to extend the system with minimal knowledge about the system.
Kill Bill supports writing plugins in various languages to address a wide audience of developers, and also leverage existing libraries in other languages than Java. In theory, plugins could be written in all JVM based languages. In practice, Kill Bill currently supports:

In order to achieve those goals, Kill Bill supports a mechanism for the plugin to register for any type of events occurring in the system.
In addition to that, plugins can also implement certain types of plugin APIs, and register/unregister in the system during the start/stop sequence.

The following set of plugin APIs is currently supported:

Payment plugin API: Those APIs are used by plugins interacting with third party payment gateways or payment processors.

Currency plugin API: By implementing this API, the plugin would provide the business logic for currency conversion, which is then available to payment plugins for real time currency conversion.

Invoice plugin API: Plugins implementing this API would be called during invoice generation when Kill Bill’s invoicing code computes the items but prior the invoice is persisted, to provide the ability for the plugin to modify the items (for example to add extra tax items).

Payment control plugin API: The purpose of this API is to intercept payments and as a result abort them (fraud use case) or reroute them to a different payment plugin (payment gateway downtime, or cost optimization scenario).

Catalog plugin API: If the XML-based catalog configuration doesn’t suit your needs, you can implement your own catalog engine through this API.

Entitlement plugin API: this API lets you intercept entitlement APIs (such as subscription creation or change) to inject your own subscription business logic (use-cases include coupons management or price overrides).

Lifecycle and Layout Internals

Kill Bill Plugins will be started and stopped during the Kill Bill lifecycle initialization stages.
Each plugin will need to provide an activator with a start and stop method.
During initialization and when all the foundation and core services have started, Kill Bill will automatically discover the existing plugins (based on the filesystem layout described below) and it will invoke the start method to initialize the plugins.
During shutdown sequence, each plugin will first be stopped and then the rest of the foundation and core services will be stopped.

Kill Bill looks for all plugins in a bundle directory, by default /var/tmp/bundles (you can override it via the system property org.killbill.osgi.bundle.install.dir).
The expected layout is the following:

The bundles/platform directory is used for non Kill Bill specific OSGI plugins. For example, you can drop in it the Apache Felix Web Console jar, and Kill Bill will automatically start it during its initialization sequence. Here is a recommended set of convenience plugins to run.
Note that in the case of Ruby plugins (see below), you need to copy the correct version of the org.kill-bill.billing:killbill-platform-osgi-bundles-jruby artifact and name it as bundles/platform/jruby.jar.

Also, in the case of Java based plugins, it is enough to just copy the jar under the correct directory entry, but in the case of the ruby plugins, the layout is a bit more complex: it expects a top level killbill.properties file describing the type of plugin and special libraries to load, as well as a gems directory containing all the dependencies.
Fortunately, if you are using one of the official Ruby plugins, you don’t need to worry about this. You can download tar.gz packages with the correct layout. Simply unpack them and restart Kill Bill.

Check our plugin development and management guides in our main documentation for more details.