I'm attempting to add Google Pay functionality to my Android app. I'm trying to implement the instructions in a tutorial, but I keep receiving the following error: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.myapp.sqill, PID: 12555 android.content.ActivityNotFoundException: No Activity found to handle Intent act=android.intent.action.VIEW dat=upi:/pay? pkg=com.google.android.apps.nbu.paisa.user pa=your-merchant-vpa@xxx&pn=your-merchant-name&mc=your-merchant-code&tr=your-transaction-ref-id&tn=your-transaction-note&am=your-order-amount&cu=INR
Here is my code so far. Thanks in advance
//PaymentPageActivity.java
Button pay_button;
final int UPI_PAYMENT=0;
Integer amount=5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment_page);
pay_button=findViewById(R.id.pay);
//startActivity
pay_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
payUsingUpi();
}
});
}
private void payUsingUpi() {
Uri uri =
new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "your-merchant-vpa@xxx")
.appendQueryParameter("pn", "your-merchant-name")
.appendQueryParameter("mc", "your-merchant-code")
.appendQueryParameter("tr", "your-transaction-ref-id")
.appendQueryParameter("tn", "your-transaction-note")
.appendQueryParameter("am","$5.00")
.appendQueryParameter("cu", "INR").build();
String GOOGLE_PAY_PACKAGE_NAME = "com.android";
int GOOGLE_PAY_REQUEST_CODE = 123;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.setPackage(GOOGLE_PAY_PACKAGE_NAME);
startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE);
}