Guides & Tutorials
Jenga PGW
Checkout SDK
Android

Payment Gateway SDK - Android

This document is intended to help understand the integration process of your Native Android App with Jenga Payment Gateway Android SDK.

Pre-requisites

  1. Sign up for an account on Jenga HQ (opens in a new tab)
  2. Make sure you have at least one wallet added under Settings -> Wallets in the left navigation menu.
  3. Navigate to Settings -> Subscriptions under the left navigation menu and add subscriptions for the payment
    methods you want to provide on the checkout screen.
  4. Navigate to Settings -> Api Keys under left navigation menu and click on Generate New Keys, if the keys
    have not been generated yet.
  5. On the above Settings -> Api Keys screen, click on View inside Your Public Key section, if the window which opens does not contains your public key, please generate and paste it there, and then click on the Update button to update the same on Jenga HQ.

Integration Steps

Follow the below steps to integrate Checkout Android SDK with your Android application:

  1. Open your project-level build.gradle file and declare mavenCentral() repository inside repositories block inside buildscript block, if it does not already exists.
build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
}
  1. Open your app-level build.gradle file and add Jenga Checkout’s gradle dependency inside the dependencies block. Always use the latest version of the Android Library. For the latest version, please refer the Releases and Versions section on Maven Central (opens in a new tab).
build.gradle
dependencies {
    implementation 'io.jengaapi:pgw-sdk-android:1.0.0.5'
}
  1. If you have not generated a token, follow the steps in the prerequisites page to get one.

  2. Import the required packages as shown below

Kotlin
import io.jengapgw.Checkout
import io.jengapgw.CheckoutResultListener
import io.jengapgw.models.CheckoutResult
import io.jengapgw.models.Order
import io.jengapgw.models.Authentication
  1. Create an Authentication Object

Before creating the order, create an Authentication object, which is essential for setting the environment and bearer token for the SDK.

The request body for the Authentication object is as follows:

FieldTypeDescriptionRequired
environmentStringThe environment to be used. Options are "sandbox" for testing and "live" for production transactions.Yes
accessTokenStringBearer token used to authenticate API requests. This token can be obtained from Jenga HQ under API Keys.Yes
val authentication = Authentication(
    environment: String,
    accessToken: String
)

Environment can either be sandbox or live

sandbox: Use this environment for testing your integration without processing real transactions. It simulates the payment process.

live: Use this environment when you are ready to go live and process real transactions in the production environment.

  1. Create an order in your system and then create an order for the Jenga Android SDK by creating an object of the Order class.
Kotlin
val order = Order(
    merchantCode: String,
    amount: String,
    orderReference: String,
    productType: String,
    productDescription: String,
    extraInformation: String,
    currency: String,
    callbackUrl: String,
    signature: String,
    customerFirstName: String,
    customerLastName: String,
    customerEmail: String,
    customerPhone: String,
    customerAddressLine1: String,
    customerZipCode: String,
    customerCountry: String
)

Order class’s fields and their description are as follows:

ParameterTypeMeaningMandatory
merchantCodeStringA unique string identifier for a merchant. You can obtain your merchantCode from under **Settings -> Api **Keys in the left navigation menu on Jenga HQ.Y
amountStringOrder amount, which you want to transact.Y
orderReferenceStringA unique id identifying your order, this you may get from the order you have created in your system.Y
productTypeStringType of the product which the order contains.N
productDescriptionStringDescription of the product which the order contains.Y
extraInfoStringAny extra information you may want to set for the order.N
paymentTimeLimitIntegerTime limit in seconds, to complete the transaction.N
currencyStringCurrency code for the order amount currency.Y
callbackUrlStringA callback url to post back the checkout data.Y
signatureStringSignature to verify if secureMode is enabled.N
countryCodeStringCustomer’s country code.N
customerFirstNameStringCustomer’s first name.N
customerLastNameStringCustomer’s last name.N
customerZipCodeStringCustomer’s zipcode.N
customerAddressStringCustomer’s address.N
  1. Authenticate and Launch Checkout screen to initiate payment by calling start() method of the Checkout class and passing the order object created in the previous step and the FragmentManager class’s instance.
Kotlin
val checkout = Checkout()
checkout.authenticate(authentication)
checkout.start(order, supportFragmentManager)
  1. Implement CheckoutResultListener interface and override its onResult method in the class where you are launching the checkout from, to receive a callback from the SDK once the checkouts gets successful or failed. Here you can show a relevant message to the customer, based on the checkout status.
Kotlin
class CheckoutActivity : AppCompatActivity(), CheckoutResultListener {
 
    override fun onResult(result: CheckoutResult) {
        Toast.makeText(this, result.message, Toast.LENGTH_SHORT).show()
        Log.i("Response Result", result.toString())
    }
}

CheckoutResult class’s fields and their description is as below:

ParameterTypeMeaning
successBooleanTrue if the checkout was successful else false.
orderReferenceStringOrder reference you passed earlier.
transactionReferenceStringA unique transaction reference generated by Jenga.
transactionDateStringDate of the transaction, formatted as “YYYY-MM-ddThh:mm:ssZ”.
transactionAmountStringOrder transaction amount.
transactionCurrencyStringOrder transaction currency.
paymentChannelStringPayment Channel Id used by the customer.
messageStringCheckout success or failure message.