Return navigation is not working in wallets for Razorpay payment gateway

970 Views Asked by At

I have used RazorPay Android SDK as a payment gateway for my product. I have implemented the proper code as they have described which is working fine in live mode for Card payments. But the issue is coming for wallets like PhonePe and GPay.

The issue is when the user is choosing any wallet its navigating the wallet with proper amount. Then user can able to pay the amount from the wallet which is populating in the RazorPay dashboard. But after paying the amount from the wallet the flow shold auto navigate to my app's payment page where I have implemented RazorPay onSuccess and onFailour method instead the payment flow is staying in the wallet itself, so I can't able to update my server with the payment details and also not able to update the payment UI as well.

I have added the code below which I have implemented for the payment.

chackout = new Checkout();
    chackout.setKeyID(razorpayKey);
    try {
        JSONObject options = new JSONObject();
        options.put("name", "Company");
        options.put("description", "Advance for "+mBookings.getPartyName());
        options.put("currency", "INR");
        options.put("amount", finalAdvAmount);
        options.put("send_sms_hash",true);

        JSONObject preFill = new JSONObject();
        preFill.put("email", ud.getUserMailId());
        preFill.put("contact", mBookings.getBookingPersonPhoneNumber());
        options.put("prefill", preFill);

        chackout.open(this, options);
    } catch (Exception e) {
        AppUtils.showSnackBar(this, "There is some issues when starting payment. Please try 
         after sometimes");

    }

I also implemented PaymentResultWithDataListener through which I am handling onSuccess and onFailour methods as well.

Did anyone faced the same issue ever?

2

There are 2 best solutions below

0
On BEST ANSWER

After struggling a long I got the answer which is working fine. To use any wallets likes phonePe or GPay we need to use <queries> in manifest with their packages and use the appropriate intent for navigation. Just like below:

<queries>
    <!--google pay-->
    <package android:name="com.google.android.apps.nbu.paisa.user"/>
    <!--phonePe-->
    <package android:name="com.phonepe.app"/>
    <intent>
        <action android:name="android.intent.action.SEND"/>

    </intent>
    <intent>
        <action android:name="com.google.android.youtube.api.service.START" />
    </intent>
</queries>
0
On

The code you've provided is irrelevant; the callback listeners are what matters. When registering these callbacks in the Activity (which you haven't provided either) it doesn't matter which Fragment is currently being displayed. All you need is a handle to NavController within that Activity - so that it can navigate upon callback. Eventually you would need to check which Fragment is being displayed - and then just fire the according NavAction - as not every NavAction is not available to every Fragment (unless global).