UPI Payment Gateway using Android Deep Link

前端 未结 2 1687
慢半拍i
慢半拍i 2021-01-06 04:26

Is there any working sample to integrate UPI payment gateway using Android Deep Link. I went through NPCI specifications and implemented it with no success. Transaction is n

2条回答
  •  生来不讨喜
    2021-01-06 04:38

    You can the list of all UPI apps on the device and use any app to initiate the transaction.

    This is the function that you can use to fetch all the UPI apps.

    private fun upiApps(context: Context): MutableList {
    
        val upiOptions = mutableListOf()
    
        // Set Parameters for UPI
        val payUri = Uri.Builder()
    
        payUri.scheme("upi").authority("pay")
        payUri.appendQueryParameter("pa", "")
        payUri.appendQueryParameter("pn", "")
        payUri.appendQueryParameter("tid", "")
        payUri.appendQueryParameter("mc", "")
        payUri.appendQueryParameter("tr", "")
        payUri.appendQueryParameter("tn", "")
        payUri.appendQueryParameter("am", "")
        payUri.appendQueryParameter("cu", "")
    
        val paymentIntent = Intent(Intent.ACTION_VIEW)
        paymentIntent.data = payUri.build()
    
        val appList = context.packageManager.queryIntentActivities(paymentIntent, 0)
        for (i in appList) {
            // this is a custom model class
            val paymentUpiOption = PaymentUpiOption(
                i.loadLabel(context.packageManager).toString(),
                i.activityInfo.packageName,
                i.loadIcon(context.packageManager),
                "upiTxn",
                "UPI"
            )
            upiOptions.add(paymentUpiOption)
        }
        return upiOptions
    }
    

提交回复
热议问题