Android Card Tokenization Guide


  • Android sdk version 21+
  • Omni Webpayments Token



To install,

  1. Add the JitPack repository to your build file

    allprojects {
        repositories {
            maven { url '' }
  2. Add the following line to your build.gradle file

    implementation 'com.github.fattmerchantorg:fattmerchant-android-sdk:v1.0.4'

Create a PaymentMethod

To accept a payment, you’ll need to collect information from the customer and tokenize it to create an Omni PaymentMethod. You will then be able to use this PaymentMethod with Fattmerchant’s Omni API to run the transaction.


You’ll first need to setup the FattmerchantClient for usage. All you have to do here is set the webPaymentsToken field on the shared FattmerchantConfiguration. FattmerchantClient will then use that configuration by default.

class MyApplication: Application() {
    override fun onCreate() {
		FattmerchantConfiguration.shared.webPaymentsToken = "mywebpaymentstoken"

Alternatively, you may create a configuration object and pass it to the new FattmerchantApi instance as you need it.

val config = FattmerchantConfiguration("", "fattwars")
val client = FattmerchantClient(config)

Collect payment information

You first want to collect credit card information and populate a CreditCard object.

val creditCard = CreditCard(personName = "Joan Parsnip",
	cardNumber = "4111111111111111",
	cardExp = "1230",
	addressZip = "32822")

### Create the PaymentMethod
Once you have a `CreditCard` object, call the `tokenize(:)` method on  `FattmerchantClient` object and pass a listener to be notified once tokenization is complete.

var fattClient = FattmerchantClient(config)
fattClient.tokenize(card) { (response) in
  client.tokenize(card, object : FattmerchantClient.TokenizationListener {
            override fun onPaymentMethodCreated(paymentMethod: PaymentMethod) {
              // Success! You can now run a transaction with Fattmerchant using paymentToken as the PaymentMethod

            override fun onPaymentMethodCreateError(errors: String) {


If you’d like to try tokenization without real payment information, you can use the CreditCard.testCreditCard() method to get a test credit card .

val creditCard = CreditCard.testCreditCard()

If you want to test failures, you can use the following methods

val failingCreditCard = CreditCard.failingTestCreditCard()

Or you can create the CreditCard object with the following testing payment information:

Credit card numbers

Card Type Good Card Bad Card
VISA 4111111111111111 4012888888881881
Mastercard 5555555555554444 5105105105105100
Amex 378282246310005 371449635398431
Discover 6011111111111117 6011000990139424
JCB 3569990010030400 3528327757705979
Diners Club 30569309025904 30207712915383

Use any CVV number for the above

Taking a Payment

Now that you have the token representing the payment method, you can use the /charge resource on the Omni API. this will allow you to create a transaction with the payment method. payment_method_id is a required field, where you will need to pass in the id of the payment method that you received from the tokenize(:) method.