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 in Android by Edureka
• 10,880 points
25 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
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 in Android by Edureka
• 10,880 points
38 views
0 votes
0 answers
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 in Android by Ashwini
• 2,760 points
18 views
0 votes
1 answer
0 votes
1 answer

How to set my Activity as main activity in android?

The "intent-filter" in "AndroidManifest.xml" allows you to ...READ MORE

answered Nov 8 in Android by Edureka
• 12,390 points
35 views
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,027 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,100 points
1,661 views
0 votes
1 answer

Is there a way to run Python on Android?

YES! An example via Matt Cutts via SL4A -- "here’s ...READ MORE

answered Sep 19, 2018 in Python by Priyaj
• 58,100 points
471 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,630 points
426 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