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.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

Reference

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

  • Create Card token
  • Get Bin Info
  • Create a Subscription token
  • 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 acoount data in transfer subscriptions
  • Create a Card Async Token
Android Methods
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
requestSubscriptionToken() card Object Returns a subscription token
bankListSubscriptionTransfer() Object Returns a Bank List
transferSubscriptionTokens() documentNumber, bankCode, name, lastName, accountNumber, documentType, accountType, totalAmount, 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
transferSubscriptionSecure() 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
requestCardAsyncToken() totalAmount, returnUrl, email, description Object Returns a card async 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;
      	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

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

Example Application

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