Trying to integrate google pay to my android app

0 votes

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);
    }
Nov 16, 2022 in Android by Edureka
• 12,690 points
698 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Android

0 votes
1 answer

How to open the Google Play Store directly from my Android application?

If you want to link to your ...READ MORE

answered Nov 7, 2022 in Android by Edureka
• 12,690 points
4,384 views
0 votes
0 answers

Android: why the ICICI iMobile Pay App shows the "rooted/jailbroken" device with my app?

The ICICI iMobile Pay app displays the ...READ MORE

Nov 9, 2022 in Android by Edureka
• 12,690 points
1,088 views
0 votes
0 answers

Android app rejected by Google Play Console due to "Provide instructions for app access"

I'm creating an app whose login process ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
568 views
0 votes
0 answers

How to open the Google Play Store directly from my Android application?

I have open the Google Play store ...READ MORE

Nov 23, 2022 in Android by Ashwini
• 5,430 points
733 views
0 votes
1 answer

Opt out or How to stop google bot accounts from my app?

It sounds like you are experiencing an ...READ MORE

answered Mar 18, 2023 in Android by pooja
612 views
0 votes
1 answer
0 votes
1 answer

Running docker on Android

According to the documentation, the Android kernel is ...READ MORE

answered Aug 1, 2018 in Docker by Kalgi
• 52,350 points
3,796 views
0 votes
1 answer

Task Canceled Exception while invoking AWS Lambda

I'm guessing either the TaskCanceledException instance is ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,020 points
2,481 views
0 votes
1 answer

Is there a way to run Python on Android?

YES! here’s a barcode scanner written in six ...READ MORE

answered Sep 19, 2018 in Python by Priyaj
• 58,020 points
1,038 views
0 votes
1 answer

How can we get the current location in Android?

First you need to define a LocationListener to handle ...READ MORE

answered Sep 25, 2018 in Java by Parth
• 4,640 points
938 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP