INITIAL GUIDE
Libraries
WEB

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.20'
}

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, CLP, UF, PEN

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

Examples

Find the methods available in our Android library along with examples.

One-Time Payment Examples

requestToken()

To request a card 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;
      	Integer months = 3;
        String publicMerchantId = "public-merchant-id";
        Kushki kushki = new Kushki(publicMerchantId, 
                                   "USD", 
                                   KushkiEnvironment.TESTING,
                                  false);//optional parameter regional
        try {
            return kushki.requestToken(card, totalAmount, months);
        } 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 Double The amount you are going to collect

Optional

Property Type Description
months Integer Number of months. Only available in Chile for deferred transactions

getBinInfo()

Returns an object with the information related to the credit card bin (first six digits). For Chilean merchants, the response is helpfull to decide wheter to continue with the request of a card token (when cardType is CREDIT), or with the request of a card async token (when cardType is DEBIT):

Request

package com.android.example.app;

import android.os.AsyncTask;
import com.kushkipagos.android.BinInfo;
import com.kushkipagos.android.Kushki;
import com.kushkipagos.android.KushkiEnvironment;
import com.kushkipagos.android.KushkiException;

public class BinInfoTask extends AsyncTask<Void, Void, BinInfo> {
   @Override
   protected BinInfo doInBackground(Void... args) {
       String publicMerchantId = "publicMerchantId";
       String bin = "424242"; //example bin

       Kushki kushki = new Kushki(publicMerchantId,
               "USD",
               KushkiEnvironment.TESTING,
               false);//optional parameter regional

       try {
           return kushki.getBinInfo(bin);
       } catch (KushkiException kushkiException) {
           kushkiException.printStackTrace();
           return null;
       }
   }
   @Override
   protected void onPostExecute(BinInfo binInfo) {
       System.out.println(binInfo.getBrand());
       System.out.println(binInfo.getBank());
       System.out.println(binInfo.getCardType());
   }

}

Required

Property Type Description
bin String The first six digits of the credit card

Subscriptions Examples

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

Payouts Examples

requestCashOutToken()

To request a Cash Out token, you can use this method

import android.os.AsyncTask;
import com.kushkipagos.android.Kushki;
import com.kushkipagos.android.KushkiEnvironment;
import com.kushkipagos.android.KushkiException;
import com.kushkipagos.android.Transaction;

public class CashOutTask extends AsyncTask<Void, Void, Transaction> {
   @Override
   protected Transaction doInBackground(Void... args) {
       String publicMerchantId = "publicMerchantId";
       double totalAmount = 10000;
       String currency = "COP";
       String name = "Juan";
       String lastName = "Perez";
       String documentNumber = "1000000001";
       String documentType = "PP";
       String email = "[email protected]"; //optional parameter
       String description = "PayOut-Cash"; //optional parameter

       Kushki kushki = new Kushki(publicMerchantId,
               "COP",
               KushkiEnvironment.TESTING,
               false);//optional parameter regional

       try {
           return kushki.requestCashOutToken(name, lastName, documentNumber, documentType,
                   email,totalAmount, currency, description);
       } 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 Possible Values
name String Name of the client
lastName String Last name of the client
documentType String Type of document that the client is using to pay. CC, NIT, CE, TI, PP
identification String Document number that the client is using to pay
totalAmount Number The amount you are going to collect as a number
currency String Code of currency used COP

Optional

Property Type Description
email String Email address of the client
description String A description of the payment

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 go to our backend integrations: Kushki Libraries or Kushki API


Reference

Find the methods available in our Android library. You can perform the following operations:

One-time Payment:

  • Create a Card token
  • Get Bin Info
  • Create a Card Async Token
  • Create a Transfer In token
  • Create a Cash In token

Subscriptions

  • Create a Card Subscription token
  • Get an Async Card Subscription
  • Get a list of banks available for subscriptions With Wire Transfer Debit
  • Create a Transfer Subscription token
  • Start and answer a challenge to validate the account data in Transfer Subscriptions

Payouts

  • Create a Cash Out token

One-time Payment

Name Parameters Returns Description
requestToken() card, totalAmount, months Object Returns a token
getBinInfo() bin Object Returns an object with the information related to the credit card bin
requestCardAsyncToken() totalAmount, returnUrl, email, description Object Returns a card async token
requestTransferToken() amount, callbackUrl, documentType, documentNumber, email, paymentDescription, userType Object Returns a transfer in token
requestCashToken() totalAmount, currency, identification, documentType, name, lastName, email, description Object Returns a cash in token that can later be used to initialize a cash in transaction

Subscriptions

Name Parameters Returns Description
requestSubscriptionToken() card Object Returns a subscription token
requestCardSubscriptionAsyncToken currency, email, cardNumber, callbackUrl Object Returns an async card subscription token
getBankList() Object Returns a list of banks available for transfer subscriptions
requestTransferSubscriptionToken() documentNumber, bankCode, name, lastName, accountNumber, documentType, accountType, email, currency Object Returns a token along with a secureId, and secureService. The token can later be used to create a transfer subscription. Before that, you will need to confirm the account data by starting and asnwering a challenge with the secure validation method
requestSecureValidation() On first call: secureService, secureServiceId, cityCode, stateCode, phone, expeditionDocumentDate. On second call: secureService, secureServiceId, questionnaireCode, answers (JSON Object) Object On first call, returns a questionnaire for the challenge. On second call, returns a code and a message with the results of the account verification

Payouts

Name Parameters Returns Description
requestCashOutToken() totalAmount, currency, identification, documentType, name, lastName, email, description Object Returns a cash out token that can later be used to initialize a cash out transaction

Example Application

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