5

GPay integration was working totally fine before 2 days but now its showing same error in gpay app. Intent calling for gpay payment is not working. I have completed transaction successfully days before. but now its not working. Any help would be appreciated! Thanks in Advance.

My Code

 uriapp = new Uri.Builder()
            .scheme("upi")
            .authority("pay")
            .appendQueryParameter("pa", getString(R.string.vpa))
            .appendQueryParameter("pn", getString(R.string.payee))
            .appendQueryParameter("tr", orderId)
            .appendQueryParameter("tn", description)
            .appendQueryParameter("am", String.valueOf(amount))
            .appendQueryParameter("cu", "INR")
            .build();

 Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(uriapp);
        intent.setPackage(model.getPackageName());
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(intent, GOOGLE_REQUEST_CODE);
        } else {
            Toast.makeText(this, "This payment mode is not available on your device.", Toast.LENGTH_LONG).show();
        }

I am using correct vpa business Id.

GPay Error:

this transaction may be risky. for your safety it cant be completed at this time
Bhoomika Brahmbhatt
  • 7,404
  • 3
  • 29
  • 44

2 Answers2

0

Curruntly this snippet is working in test app. Let me know if its not working in yours.

    private static final int TEZ_REQUEST_CODE = 123;

    private static final String GOOGLE_TEZ_PACKAGE_NAME = 
    "com.google.android.apps.nbu.paisa.user";

Uri uri =
    new Uri.Builder()
        .scheme("upi")
        .authority("pay")
        .appendQueryParameter("pa", "test@okbizaxis")
        .appendQueryParameter("pn", "Test")
        .appendQueryParameter("mc", "1234")
        .appendQueryParameter("tr", "1234")
        .appendQueryParameter("tn", "test")
        .appendQueryParameter("am", "10")
        .appendQueryParameter("cu", "INR")
        .appendQueryParameter("url", "")
        .build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.setPackage(GOOGLE_TEZ_PACKAGE_NAME);
startActivityForResult(intent, TEZ_REQUEST_CODE);
kiran
  • 3
  • 1
raj kavadia
  • 926
  • 1
  • 10
  • 30
0

https://web.archive.org/web/20200921110005/https://www.npci.org.in/sites/default/files/UPI%20Linking%20Specs_ver%201.6.pdf

go through this documentation and perform intent accordingly.

It clearly shows that the integration requires a signature attribute which is clearly absent in the google pay upi integration documentation.

A small Clarity why code given on the gpay upi documentation not working?

  • firstly, some of the parameters are missing which are important for the Upi intent deep linking, like mode, sign, orgID.
  • for mode, refer to the link.
  • sign is the signature value, which is similar to checksum value, which we create while using an sdk like paytm etc.
  • basically it is the rest of the string encrypted by SHA256 and RSA512. this encryption is done using the private key and public key provided by the PSP providers and the merchants bank.
  • after encryption, we perform a base64 encoding.
  • this is the sign value. refer documentation for more clarity.
  • orgid for the intent based transaction is 000000.

as those values are not present I think, the transaction is failing.

ok a trick way to perform intent based transaction (WORKS ONLY ON TRANSACTION THROUGH GOOGLE PAY APP)

in case of phone pe and paytm qr, get the rawstring from these qr using google lens.

add the parameters into string such as 'am' and 'tn' which represents the amount and transaction note respectively. apply Uri.parse(STRING VALUE) and send this as the intent to google pay.

you will see that the transaction is happening and we get result back to our app, SUCCESS or FAILURE.

zimmy9537
  • 103
  • 1
  • 5
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31294432) – Abhishek Dutt Mar 17 '22 at 15:22
  • 1
    @AbhishekDutt did as requested. – zimmy9537 Mar 20 '22 at 13:48