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
- Sign up for an account on Jenga HQ (opens in a new tab)
- Make sure you have at least one wallet added under Settings -> Wallets in the left navigation menu.
- Navigate to Settings -> Subscriptions under the left navigation menu and add subscriptions for the payment
methods you want to provide on the checkout screen. - Navigate to Settings -> Api Keys under left navigation menu and click on Generate New Keys, if the keys
have not been generated yet. - 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:
- Open your project-level build.gradle file and declare mavenCentral() repository inside repositories block inside buildscript block, if it does not already exists.
buildscript {
repositories {
mavenCentral()
}
}
- 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).
dependencies {
implementation 'io.jengaapi:pgw-sdk-android:1.0.0.5'
}
-
If you have not generated a token, follow the steps in the prerequisites page to get one.
-
Import the required packages as shown below
import io.jengapgw.Checkout
import io.jengapgw.CheckoutResultListener
import io.jengapgw.models.CheckoutResult
import io.jengapgw.models.Order
import io.jengapgw.models.Authentication
- 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:
Field | Type | Description | Required |
---|---|---|---|
environment | String | The environment to be used. Options are "sandbox" for testing and "live" for production transactions. | Yes |
accessToken | String | Bearer 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.
- Create an order in your system and then create an order for the Jenga Android SDK by creating an object of the Order class.
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:
Parameter | Type | Meaning | Mandatory |
---|---|---|---|
merchantCode | String | A 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 |
amount | String | Order amount, which you want to transact. | Y |
orderReference | String | A unique id identifying your order, this you may get from the order you have created in your system. | Y |
productType | String | Type of the product which the order contains. | N |
productDescription | String | Description of the product which the order contains. | Y |
extraInfo | String | Any extra information you may want to set for the order. | N |
paymentTimeLimit | Integer | Time limit in seconds, to complete the transaction. | N |
currency | String | Currency code for the order amount currency. | Y |
callbackUrl | String | A callback url to post back the checkout data. | Y |
signature | String | Signature to verify if secureMode is enabled. | N |
countryCode | String | Customer’s country code. | N |
customerFirstName | String | Customer’s first name. | N |
customerLastName | String | Customer’s last name. | N |
customerZipCode | String | Customer’s zipcode. | N |
customerAddress | String | Customer’s address. | N |
- 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.
val checkout = Checkout()
checkout.authenticate(authentication)
checkout.start(order, supportFragmentManager)
- 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.
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:
Parameter | Type | Meaning |
---|---|---|
success | Boolean | True if the checkout was successful else false. |
orderReference | String | Order reference you passed earlier. |
transactionReference | String | A unique transaction reference generated by Jenga. |
transactionDate | String | Date of the transaction, formatted as “YYYY-MM-ddThh:mm:ssZ”. |
transactionAmount | String | Order transaction amount. |
transactionCurrency | String | Order transaction currency. |
paymentChannel | String | Payment Channel Id used by the customer. |
message | String | Checkout success or failure message. |