Requesting a Payment

The following steps summarize an in-app payment request:

  • 3rd party backend uses the Scan to Pay API to create a transaction code (which contains the amount, references, etc.).
  • The 3rd party app invokes the intent passing in this newly created code.
  • The Scan to Pay in-app library will facilitate the payment and return a result and reference indicating the payment status to the calling activity.
      • The 3rd backend will then query the Scan to Pay system with the returned reference to guarantee the payment status. Alternatively, the 3rd backend will query itself to see if Scan to Pay has notified it of a new payment.

📘

Note

It is imperative that the 3rd party app does not trust the library's result as the final status. A backend API call must be done to verify the payment status.

Invoking the Payment Intent

The following snippet illustrates how to invoke the payment request Intent:

Intent intent = new Intent(context, LibLiteActivity.class);

intent.putExtra(LibLiteActivity.IN_CODE, "1234567890"); 
intent.putExtra(LibLiteActivity.IN_API_KEY, "APIKEY"); 
intent.putExtra(LibLiteActivity.IN_HASH, “HASH KEY"); 
intent.putExtra(LibLiteActivity.IN_SYSTEM, "LIVE"); context.startActivityForResult(intent, 10);

Values passed to the LibLiteActivity

NameTypeDescription
LibLiteActivity.IN_CODEStringThis is the code created by calling the Scan to Pay API representing the transaction.
LibLiteActivity.IN_API_KEYStringThis is the API key provided by Oltio/UKheshe that will enable the library to be used.
This can be found on the Scan to Pay Portal under the Lib Lite Tokens menu item
LibLiteActivity.IN_SYSTEMStringThis value can be “LIVE” or “TEST”, representing the
Scan to Pay backend system to connect to.
LibLiteActivity.IN_HASHStringThis allows capability for the app to read the SMS for registration.
Details on how to generate the HASH key can be found here.
LibLiteActivity.IN_SUGGESTED_MSISDNStringThis is an optional field if you know the clients
mobile number.

Handling the Payment Response

The following snippet illustrates how to handle the response from the LibLiteActivity:

SHARDUL TO PROVIDE
  
  
protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) {
case 10:
NameTypeDescription
LibLiteActivity.LIBLITE_ERRORReturned if an error has occurred before the payment– This indicates the type of error that occurred. See the error table below

LibLiteActivity.OUT_LOCATION
- This is the location of the error. This can be used to debug the error when requesting support from Oltio
LibLiteActivity.LIBLITE_PAYMENT_SUCCESSReturned on payment successLibLiteActivity.OUT_TX_REFERENCE
- This is the reference for the transaction. This reference will be used to tie up the transaction on the 3rd party backend system.
LibLiteActivity.LIBLITE_PAYMENT_FAILEDReturned if the payment failedLibLiteActivity.OUT_TX_REFERENCE
- This is the reference for the failed transaction in the event the 3rd party needs to request more information regarding the failure.
LibLiteActivity.LIBLITE_USER_CANCELLEDReturned if the user aborted the processLibLiteActivity.OUT_LOCATION
- This is the location where the user aborted. This can be used to determine where the user is dropping off.
LibLiteActivity.LIBLITE_INVALID_CODEReturned if the code that was passed to the LibLiteActivity is invalidNone.