The aim of this document is to assist you in initiating bank transfer payment from your custom application running on the Nomba Android terminal. If you encounter any difficulties with this process, feel free to reach out for support.

Trigger bank transfer payments - available since NombaX Application v1.6.2

This following code snippet serves as a foundation for triggering bank transfer payment events on the Nomba terminal. Adjustments to the amount, transaction reference, and other parameters can be easily made based on specific application requirements.

const val PAY_BY_TRANSFER_INTENT = "com.nomba.pro.feature.pay_by_transfer.ACTION_VIEW"
const val AMOUNT_DATA = "amount"
const val TXN_RESULT = "txnResultData"
const val RECEIPT_OPTIONS = "receiptOptions"

val resultString = mutableStateOf("")

//setup a launcher that would help launch the intent
var payByTransferLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
    val data: Intent? = result.data
    if (result.resultCode == Activity.RESULT_OK) {
        resultString.value = data?.getStringExtra(TXN_RESULT) ?: "null"
    }
}

//setup an intent to be triggered
val intent = Intent(PAY_BY_TRANSFER_INTENT)

//put the amount to be charged
intent.putExtra(AMOUNT_DATA, "300")

//handle receipt medium
val receiptOptionsMap = hashMapOf(
    "print" to true,
    "sms" to false,
    "email" to false
)
val receiptOptionsString = Json.encodeToString(serializer<HashMap<String, Boolean>>(), receiptOptionsMap)
intent.putExtra(RECEIPT_OPTIONS, receiptOptionsString)

//launch the intent
payByTransferLauncher.launch(intent)

Please note that the following details will make reference to the kotlin code snippet

Constants

Description
PAY_BY_TRANSFER_INTENTDefines the action string for the intent, indicating the type of action to be performed.
AMOUNT_DATARepresents the key for passing the amount to be charged during the payment process.
TXN_RESULTRepresents the key for extracting transaction result data from the intent.

State Variable

Description
resultStringA mutable state variable initialized as an empty string, which is intended to store the transaction result received from the launched intent.

Intent Setup

Description
val intent = Intent(PAY_BY_TRANSFER_INTENT)Creates an instance of Intent with the specified action PAY_BY_TRANSFER_INTENT.
intent.putExtra(AMOUNT_DATA, "300")Adds extra data to the intent, including the amount to be charged AMOUNT_DATA.

Launching the intent

Description
payByTransferLauncher.launch(intent)Initiates the intent, triggering the Android system to display the payment options to the user.

Result Handling

Inside the result callback, the code retrieves the transaction result from the received intent and updates the resultString variable.