androidupi

UPI Deep Link - Unable to complete the transaction


enter image description here

Trying to connect the UPI payment using deeplink for my Android application, but every-time it fails at the last step.

The code fragment for the UPI payment call is below:

 button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            URI_URL = getUPIString("xxx@upi", "xxx xxx", "test_101", "Test Transaction", "10", "INR");

            //Creating an intent for the UPI APP
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(URI_URL));
            Intent chooser = Intent.createChooser(intent, "Pay the MSME by");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                startActivityForResult(chooser, 1, null);
            }
        }
    });

To frame the UPI String using this function:

       private String getUPIString(String payeeAddress, String payeeName, String trxnRefId,
                            String trxnNote, String payeeAmount, String currencyCode) {
    String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
            + "&tr=" + trxnRefId
            + "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode;
    return UPI.replace(" ", "+");
}

What could be the possible reasons of failure? Any suggestion or help is welcome.


Solution

  • The error is T04 meaning the refId should be alphanumeric with minlength 1 and maxlength 35. instead of test_101 use test101.