Android Checkout Library


v1.0.0 (Feb 23, 2017)
Jul 28, 2014
Jan 26, 2024
Sergey Solovyev (serso)
Sergey Solovyev (serso)
Artem Chepurnyi (AChep)
Joan Pujol (lujop)
Atiq Ur Rehman (TheMaxCoder)
Manik Sejwal (maniksejwal)
Robert (aquaflamingo)
Source code


[Deprecated] Checkout (Android In-App Billing Library)

The libary is not actively maintained and no new verions are planned in the future. Use the official billing libary instead.


Checkout is an implementation of Android In-App Billing API (v3+). Its main goal is to make integration of in-app products as simple and straightforward as possible: developers should not spend much time on implementing boring In-App Billing API but should focus on more important things - their apps. With this in mind, the library was designed to be fast, flexible and secure.

Current version: 1.3.2


Checkout solves common problems that developers face while working with billing on Android, such as:

  • How to cancel all billing requests when Activity is destroyed?
  • How to query purchase information in the background? See also Querying for Items Available for Purchase
  • How to verify a purchase? See also Security And Design
  • How to load all the purchases using continuationToken or SKU details (one request is limited by 20 items)?
  • How to add billing with a minimum amount of boilerplate code?

Checkout can be used with any dependency injection framework or without it. It has a clear distinction of a functionality available in different contexts: purchase can be done only from Activity while SKU information can be loaded in Service or Application. Moreover, it has a good test coverage and is continuously build on Travis CI:

Getting started


  • Gradle/Android Studio in build.gradle:
implementation ''

Note: if you get the following warning

Conflict with dependency ''. Resolved versions for app (a.b.c) and test app (x.y.z) differ.

you should change the dependencies of to

androidTestImplementation('', {
    // use version of jsr305 provided by Checkout
    exclude group: '', module: 'jsr305'

See Android Studio and Gradle documentation for details.

  • Maven in pom.xml:
  • Download sources from github and either copy them to your project or import them as a project dependency
  • Download artifacts from the repository


A tutorial for the sample app is available on Medium. Take a look if you prefer step-by-step guides over documentation.


Say there is an app that contains one in-app product with "sku_01" id. Then Application class might look like this:

public class MyApplication extends Application {

    private static MyApplication sInstance;

    private final Billing mBilling = new Billing(this, new Billing.DefaultConfiguration() {
        public String getPublicKey() {
            return "Your public key, don't forget about encryption";

    public MyApplication() {
        sInstance = this;

    public static MyApplication get() {
        return sInstance;

    public Billing getBilling() {
        return mBilling;

And Activity class like this:

public class MyActivity extends Activity implements View.OnClickListener {

    private class PurchaseListener extends EmptyRequestListener<Purchase> {
        public void onSuccess(Purchase purchase) {
           // here you can process the loaded purchase
        public void onError(int response, Exception e) {
            // handle errors here

    private class InventoryCallback implements Inventory.Callback {
        public void onLoaded(Inventory.Products products) {
            // your code here

    private final ActivityCheckout mCheckout = Checkout.forActivity(this, MyApplication.get().getBilling());
    private Inventory mInventory;

    protected void onCreate(Bundle savedInstanceState) {

        mCheckout.createPurchaseFlow(new PurchaseListener());

        mInventory = mCheckout.makeInventory();
                .loadSkus(ProductTypes.IN_APP, "sku_01"), new InventoryCallback());

    protected void onDestroy() {

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mCheckout.onActivityResult(requestCode, resultCode, data);

    public void onClick(View v) {
        mCheckout.whenReady(new Checkout.EmptyListener() {
            public void onReady(BillingRequests requests) {
                requests.purchase(ProductTypes.IN_APP, "sku_01", null, mCheckout.getPurchaseFlow());

Advanced usage


A sample app is available on Google Play (source code). There is also a tutorial for it on Medium.

Building from the sources

Checkout is built by Gradle. The project structure and build procedure are standard for Android libraries. An environmental variable ANDROID_HOME must be set before building and should point to Android SDK installation folder (f.e. /opt/android/sdk). Please refer to Gradle User Guide for more information about the building.

Classes overview

Checkout contains three main classes: Billing, Checkout and Inventory.

Billing is a core class of Checkout's implementation of the billing API. It is responsible for:

Only one instance of Billing should be used in the app in order to avoid multiple connections to the billing service. Though this class might be used directly it's easier to work with Checkout instead.

Checkout is a middle tier of the library. It uses Billing in a certain context, e.g. in Application, Activity or Service, checks whether billing is supported and executes the requests. ActivityCheckout is a subclass capable of purchasing items.

Inventory loads information about products, SKUs and purchases. Its lifecycle is bound to the lifecycle of Checkout in which it was created.

Purchase verification

By default, Checkout uses simple purchase verification algorithm (see DefaultPurchaseVerifier). As explained in Android documentation it's better to verify purchases on a remote server. Checkout allows you to provide your own PurchaseVerifier via Billing.Configuration#getPurchaseVerifier. BasePurchaseVerifier can be used as a base class for purchase verifiers that should be executed on a background thread.


Library's proguard rules are automatically added to the app project by Gradle. You can declare them explicitly by copying the contents of proguard-rules.txt to your proguard configuration.


Copyright 2016 serso aka se.solovyev

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.