Search code examples
androidrazorpayrazorpay-andoid-sdk

Return navigation is not working in wallets for Razorpay payment gateway


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?


Solution

  • 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>