I am using this library (Library link) to create a UPI intent. This library supports both payment intent and QR code generation. Now, payment through PhonePe succeeds but payment through GooglePay sometimes succeeds and sometimes fails (when done through intent). Payment through PhonePe always succeeds (both using Intent and QR).
This is what I am trying to do.
MainActivity.java
btn1.setOnClickListener(view -> {
try {
UPI upi = UPI.getInstance();
Intent payIntent = upi.getPaymentIntent(UPI_ID, NAME, "1", "INR", "Test", "", MERCHANT_CODE, UPI.ALL_APPS);
launcher.launch(payIntent);
}
catch (Exception e) {
Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();
}
});
btn2.setOnClickListener(view -> {
getSupportFragmentManager().beginTransaction().add(new QRFragment(), "QR").commit();
});
QRFragment.java
UPI upi = UPI.getInstance();
try {
Bitmap bitmap = upi.getQR(UPI_ID, NAME, "1", "INR", "Test", "", MERCHANT_CODE, 512);
img = view.findViewById(R.id.img);
img.setImageBitmap(bitmap);
}
catch (Exception e) {
e.printStackTrace();
}
Note: The recipient UPI ID is a business UPI ID.
Edited: The merchant has only PhonePe and PayTM merchant ID (no Google Pay). Can it be a problem?