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.
build.gradle
buildscript {
repositories {
mavenCentral()
}
}
- Open your app-level build.gradle file and add Jenga Checkout’s gradle dependency inside the dependencies
block. For the latest version, please refer the Releases and Versions section.
build.gradle
dependencies {
implementation 'io.jengapgw:jengapgw-android:1.0.2'
}
-
If you have not generated a token, follow the steps in the prerequisites page to get one.
-
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
- 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, walletId, amount, orderReference, productType,
productDescription, extraInfo, paymentTimeLimit, currency,
callbackUrl, signature, countryCode, customerFirstName,
customerLastName, customerZipCode, customerAddress, environment,
token
)
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 |
environment | String | The environment being utilized. It should either be live or sandbox | Y |
token | String | The bearer authorization token | Y |
- 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.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.
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:
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. |