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

📘

Library File

Kindly send an email to Jenga support to request the library/sdk/aar file

Payment Parameters

Parameter

Meaning

Sample

Mandatory?

merchantCode

The merchant code provided at registration. Use the merchant code provided during token generation.

3126714002

YES

password

username, obtained after successful on-boarding on JengaHQ

vLcQDQwDYF1hOU9Xiq3O16DGtJgBlIcT

YES

API Key

password, obtained after successful on-boarding on JengaHQ

Basic QWEzY0dxRVpWOVo5dDFVSnhTR3BwZUF4WEZrcFFyYUk6cU5BYWs5YXcyVDNtSW1uMg==

YES

outletCode

This is generated with merchant code. It identifies the merchant outlet.

10 digits
0000000000

YES

amount

The value of the transaction. Convert to the lowest currency denomination e.g. KSH 100 will be 10000

10000

YES

currency

The currency types

KES, USD, UGX,TZS

YES

description

A brief summary of the transaction. max 200 characters

This is a test transaction

YES

Order Reference

The merchant order reference. This will be echoed back at the completion of a transaction

  • it has to be less 30 characters
  • It has to be alphanumeric

REF_0014678BN

YES

Customer Name

The customer's name / Merchant Name

Test Company

YES

Customer ID

Outlet Code

0000000000

YES

expiry

The date validity of the interaction. Should be future date

2030-02-17T19:00:00

YES

website

The merchants website

www.tester.co.ke

YES

payButton

An identifier for the button that will initiate the sdk launch

YES

How to Integrate pgw_sdk to your application

  • Copy the AAR file (pgw_sdk.aar) to desktop
    1. Go to File -> New -> Import Module...
    2. Import .JAR/.AAR Package
    3. Select the source directory of the Module you want to import and click Finish.
  • Then in your project gradle file:
allprojects {
    repositories {
      . . .
      flatDir {
         dirs 'libs'
      }
   }
}
  • Then in your application gradle file:
dependencies {
       . . .
    //needed for the pgw sdk

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-compat:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.leo.simplearcloader:simplearcloader:1.0.3'
implementation 'com.github.eralpyucel:CircleProgressView:v1.1'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.8.1'
implementation 'com.google.code.gson:gson:2.8.4'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'

implementation 'com.android.support:multidex:1.0.1'
implementation "com.android.support:support-core-utils:27.1.1"

implementation 'com.github.bumptech.glide:okhttp3-integration:4.5.0'
implementation 'com.hbb20:ccp:2.2.2'


   
implementation project(path: ':pgw_sdk')




}

in your AndroidManifest.xml file , under application add tools:replace="android:theme"

<application>
      . . .
        tools:replace="android:theme"
      . . .
</application>

❗️

Important

Go to File > Invalidate Caches /Restart... and click on Invalidate and Restart

Initialize the PgwSdk

This is achieved by calling: PgwSdk.getSDK as shown below

  • Initializing the SDK inside onCreate
//Initializing the SDK

String username = ''; //Merchant Code

String outletCode ='';                                 
String password = '';   //Password
String apikey = ' '; //API Key

AuthData authData = new AuthData(username, password, username, outletCode, apikey);  //they have to be passed in this order. 

PgwSdk.getSDK(authData, new SetUpResp() {
    @Override
    public void onConnected(PgwSdk pgwSdk) {
        sdk = pgwSdk; //am assuming you already declared this variable somewhere.
        //TODO: SDK is ready for you to consume.
    }

    @Override
    public void onError(ErrorResponse errorResponse) {
        //TODO: an error occurred. You have access to the message code and a message through ErrorResponse
    }

}, context);
  • authData: object required to perform authentication
  • SetUpResp: callback on which you will receive a reference to the pgwSdk, or an error
    incase there was a problem during authentication, or merchant set-up.

Execute

Your SDK is now set-up and ready to perform the following actions:

  • Checkout: involves creating an order. You will receive an invoice id among other things in response.
  • Query payment: query the status and details of a payment.
  • Query bill: query order details.
  • Checkout/Create order

The first step after setting up is to create an order. This is done by invoking sdk.createOrder. This will return an intent that you use to start the checkout process. Remember to listen for a response on the onActivityResult callback.

Create Order

//use sdk initialized in step 3. 
if(sdk.isConnected()){
      String merchantWebSite = "testcompany.com"; //merchant website
      String orderRef = "REF001BN"; //Random minimum 9 characters
      float orderAmount = 250f; // order reference
      String currency = "KES"; 
      String orderDescription = "This is an order. A test order";
      Calendar calendar = Calendar.getInstance();
      calendar.add(Calendar.DATE, 2);
      String customerName = "testCustomer"; //Merchant Name
      String outletCode = "0000000000" //Outlet Code
      Date orderExpiryDate = calendar.getTime();
      String customerFirstName = "John"; //your customer first name
      String customerlastName = "Doe"; //your customer last name
      String customerEmail = "[email protected]"; //your customer email
      String customerPostcodeZip = "00100"; //your customer postal code
      String customerCity = "Nairobi"; //your customer current city
      String customerAddress = "Test Address"; //your customer current address
      String customerSourceIP = ""; ////your customer IP. leave it blank if you are not sure

      Intent intent = sdk.createOrder(orderAmount, orderRef, customerWebSite, customerName, outletCode, orderExpiryDate, orderDescription, currency, customerlastName,customerEmail,customerPostcodeZip, customerCity,customerAddress,customerSourceIP)
   startActivityForResult(intent, PgwSdk.CREATE_ORDER);
}

Then listen for a response on the startActivityForResult callback as below.

Create Order response on startActivityForResult callback

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == PgwSdk.CREATE_ORDER){
        if(resultCode == RESULT_OK){
            //TODO: receive the response from the data
       Log.d("data","createbill transactionRef :" + data.getStringExtra("transactionRef"));
                Log.d("data"," Customer OrderRef :" + data.getStringExtra("billReference"));
        } else if (resultCode == RESULT_CANCELED){
            //TODO: request canceled by user. Handle it
        }
    } else
        super.onActivityResult(requestCode, resultCode, data);
}

Query Payment

This is used to query the status of a payment. A orderReference is required, optionally you can pass transactionReference, or mobileNumber. You are required to implement a call back method PGWPaymentQueryResponse from which you will easily receive a response, positive or otherwise. Remember to however always check if you have a valid sdk,
Query for a payment

sdk.queryPayment(orderRef, transactionReference, mobileNumber, new PGWPaymentQueryResponse() {
    @Override
    public void onPaymentQuery(PaymentQueryResp paymentQueryResp) {
        //TODO: payment response with status, order reference and amount
    }

    @Override
    public void onError(ErrorResponse errorResponse) {
        //TODO: receive error incase there was a problem with the request.
    }
});

Query Bill

This queries a previously created bill. Provide a order reference as an input and you get back details of the bill as the output. But as above remember to implement the call back PGWBillQueryResponse and you will get some useful data back.

sdk.queryBill(orderRef, new PGWBillQueryResponse() {

    @Override
    public void onError(ErrorResponse errorResponse) {
        //TODO: time to panic. You got an error.

    }

    @Override
    public void onBillQuery(BillQueryResp queryResp) {
        //TODO: see, I said you will get useful data.

        Log.d("retro","Bill Status :" + queryResp.getBillStatus());
        Log.d("retro","Bill amount :" + queryResp.getAmount());
    }
});

Updated about a year ago

Android


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.