SDK Integration for Wallets

10. SDK Integration for Wallets

The integration workflow of an Android device with SDK for a wallet transaction depends on the wallet used for a transaction. This section provides an example of Google Pay wallet integration.

Before you start integrating a wallet, go through the list of prerequisites.

To integrate the SDK for a wallet payment, check for the following:

10.1 SDK Integration Checklist

Before you start the SDK integration process, ensure you have the following details:

10.2 Application Configurations

Make the following configurations in your mobile application before you start integrating the SDK for wallet transactions.

10.2.1 Organize the Setup

To organize the setup, complete the following steps:

  1. Add dependencies in build.gradle file.
implementation ''
implementation ''
  1. Update AndroidManifest.xml to enable Google Pay API.
    <!-- Enables the Google Pay API -->
        android:value="true" />

10.2.2 Create Request Object

The mPoint SDK provides mPoint class to create request object based on the client configuration details. The request object is required to initiate the payment process.

this._mpoint = mPoint(URL ("[CPD provided URL]"), 
        "password", [PASSWORD] 
        clientid, [CLIENT ID] 
        accountid, [ACCOUNT ID] 
        RecordMap<String, String> (),
 this._mpoint.mode = mPoint.OUTPUT_MODE.NONE)

10.3 Instantiate Payment

See Instantiate SDK for details.

10.4 Initialize Payment

To initialize a wallet payment, use the following code sample:

var mobile: Long = [MOBILE NUMBER];
var email: String = "[EMAIL ID]";
var countryId = CountryConfig.USA;   //[AMOUNT] for USA
var currencyId = [CURRENCY_ID]
var operatorId = countryId * 100;
var amount = [AMOUNT];
amount= amount*100;
var orderID : String = "[ORDER ID NUMBER]";
var mPointOrderInfo = [ORDER_INFO_AID_DATA]
var txnType: String = mPointTxnInfo.TXN_TYPES. MPOINT_SHOPPING_ONLINE; // Example of Search and Book Flow

mPointClientInfo  clientInfo = mPointClientInfo(appid, appversion, mPoint.LANGUAGES.da) 

mPointInitializePaymentInfo paymentInfo = mPointInitializePaymentInfo()
                        paymentInfo.amount = amount
               = CountryConfig.COUNTRIES.getValues().get(countryId)
                        paymentInfo.operator = operatorId
               = mobile
               = email
                        paymentInfo.language =
                       paymentInfo.clientinfo = clientInfo
 paymentInfo.txnType = txnType
       paymentInfo.setHmac(hmac) OR
                        paymentInfo.secretSalt = salt

   paymentInfo.order = mPointOrderInfo
   paymentInfo.authToken = authToken
   paymentInfo.sessionId = sessionId 

Note: Consider the following items:

  • The mPointOrderInfo is required only for order data.
  • The authToken can be made optional, depending on a merchant’s requirement.
  • The sessionId is required only for payment retries.

10.5 Presentment Currency

See Presentment Currency for details.

10.6 Initialize Payment

Call the following method to initialize the payment when a customer selects a third-party wallet for payment such as Google Pay.

var addressInfo = [mPointAddressInfo]   
var authToken = [AUTH_TOKEN] 


Note: The authToken parameter can be optional or required, depending on the merchant requirement.

10.7 Authorize Payment

After the authorize method is called, customers can see their Google Pay accounts and cards stored in the wallet. When they select a card for payment, you get response in the following method:

override fun displayPaymentConfirmation(txn: mPointTxnInfo?, code: Int, mpoint: mPoint?)

10.8 Handle Error

When using the split payment option, after getting callback in displayPaymentConfirmation you need to call getTxnStatus method to retrieve status of the transactions. When calling the getTxnStatus pass session ID (available in mPoint class) to retrieve all transactions from the current session. To call getTxnStatus, use the following code sample:

    	if(mpoint!!.sessionId != null && mpoint.sessionId.isNotEmpty()){
   		mPoint.delegate = this
              mPoint.getTxnStatus(-1, "", mpoint.sessionId, clientInfo)

To get transaction statuses response implement following delegate method:

override fun handleTxnStatus(arrListTxnStatusInfo: ArrayList<mPointTxnStatusInfo>?, paymentStatus: Int, arrListLinkedTransactions: ArrayList<mPointLinkedTransactions>?, mPoint: mPoint?) {
            runOnUiThread {
                var pendingAmount: Long = 0
                if(null != arrListTxnStatusInfo && arrListTxnStatusInfo.size > 0){
                    for (txnStatusInfo : mPointTxnStatusInfo in arrListTxnStatusInfo){
                        // Retrieve Pending Amount
                        pendingAmount = txnStatusInfo.pendingAmount
                when (paymentStatus) {
                    // Poll getTxnStatus()
           -> {
                        if(pendingAmount == 0L)
                            // Split Payment Successful
                            // Retry Payment with Pending Amount
           -> {
                        // Retry Payment with Pending Amount

The merchant front end reads the response received to know the payment status. Read the paymentStatus parameter to know the status of the payment. If a transaction status has payment status as:

  • Pending: call the getTxnStatus API again until you get the payment status either as Successful or Failed.
  • Complete: the payment is successful.
  • Failed: retry the payment.

To retry the payment, initialize the payment with the pending amount. This action helps a customer complete the payment using any option.

Send the pending amount you received from back end in the initialize request. After you initialize, a customer can complete the payment using any available payment option or can split the payment. This process repeats until the transaction is successful, fails, or maximum retries are attempted.

Note: If a customer decides not to retry a failed payment, call the Post-Status API as shown in the following code sample to notify that the session is complete:


Refer to Handle Error for details.

10.9 Handle status

The status codes are returned by the SDK in a call back to the handleStatus method. This method enables the application to handle the status appropriately by implementing the method as shown in the following code sample:

The handleStatus method shows an error in the CPD server.

override fun handleStatus(statusInfo: mPointStatusInfo, client: Client, mpoint: mPoint) {}