INITIAL GUIDE
Libraries
COLLECTING PAYMENTS
WEB
CHARGES

Kushki Android

The Kushki library for Android allows you to collect payments easily and safely in your Android mobile application.

We make it easier!

Install and configure

Installing the Kushki Android library is simple, add the following code to your project’s build.gradle file, inside the dependencies section.

dependencies {
    // ...
    compile 'com.kushkipagos:kushki-android:1.3.8'
}

Usage

After you finished installing, create your Kushki, it will allow you to perform all the methods available in Android.

String publicMerchantId = "public-merchant-id";
Kushki kushki = new Kushki(publicMerchantId, "USD", KushkiEnvironment.testing,false);

Required

Property Type Description Default Possible Values
publicMerchantId String Kushki ID created for your merchant
currency String Code of currency useds USD USD, COP

Optional

Property Type Description Default Possible Values
environment Enum Value to define if you are in production or test environment KushkiEnvironment.production KushkiEnvironment.production , KushkiEnvironment.testing
regional Boolean Define if use a static IP to Kushki access false true,false

Reference

Find methods available in the chart. They allow you to make this operations:

  • Create Card token
  • Create a Subscription token
Android Methods
Name Parameters Returns Description
requestToken() card, totalAmount Object Returns a token
requestSubscriptionToken() card Object Returns a subscription token

requestToken()

To request a token you can use this method

package com.example.app;
import android.os.AsyncTask;
import com.kushkipagos.android.Card;
import com.kushkipagos.android.Kushki;
import com.kushkipagos.android.KushkiEnvironment;
import com.kushkipagos.android.KushkiException;
import com.kushkipagos.android.Transaction;
class TokenAsyncTask extends AsyncTask<Card, Void, Transaction> {
    @Override
    protected Transaction doInBackground(Card... args) {
        Card card = new Card(name, number, cvv, expiryMonth, expiryYear); //add card properties
        double totalAmount = 19.99;
        String publicMerchantId = "public-merchant-id";
        Kushki kushki = new Kushki(publicMerchantId, 
                                   "USD", 
                                   KushkiEnvironment.TESTING,
                                  false);//optional parameter regional
        try {
            return kushki.requestToken(card, totalAmount);
        } catch (KushkiException kushkiException) {
            kushkiException.printStackTrace();
            return null;
        }
    }
    @Override
    protected void onPostExecute(Transaction transaction) {
        if (transaction.isSuccessful()) {
            System.out.println(transaction.getToken());
        } else {
            System.out.println("ERROR: " + transaction.getCode() + " " + transaction.getMessage());
        }
    }
}

Required

Property Type Description
card Object The card data collected in an card object
totalAmount String The amount you are going to collect

requestSubscriptionToken()

To request a subscription token you can use this method

    // ...
    @Override
    protected Transaction doInBackground(Card... args) {
      	Card card = new Card(name, number, cvv, expiryMonth, expiryYear); //add card properties
        String publicMerchantId = "public-merchant-id";
        Kushki kushki = new Kushki(publicMerchantId,
                                   "USD",
                                   KushkiEnvironment.TESTING,
                                   false);//optional parameter regional
        try {
            return kushki.requestSubscriptionToken(card);
        } catch (KushkiException kushkiException) {
            kushkiException.printStackTrace();
            return null;
        }
    }
    // ...

Required

Property Type Description
card Object The card data collected in an card object

The onPostExecute method will recieve a Transaction object once the call to Kushki has completed, if this was successful the token will be available by invoking the getToken method of the transaction.

Next Steps

Remember that to continue with the payment flow you must send to your servers the token received.

To start the charge process please read find our backend integrations Kushki Libraries or Kushki API

Example Application

You can find an example application in GitHub android project repository.