react-razorpay icon indicating copy to clipboard operation
react-razorpay copied to clipboard

Feature Request: Add a method to programmatically close the Razorpay modal

Open Udhaykrishn opened this issue 11 months ago • 1 comments

Feature Request: Add a method to programmatically close the Razorpay modal Description:

Currently, I am using the ondismiss callback function to detect when the Razorpay payment modal is closed by the user. However, I need a way to programmatically close the entire Razorpay modal in certain scenarios, specifically when a payment fails.

Use case:

When a payment fails, I want to redirect the user to an "Order Failed" page.

Before redirecting, I want to display a message inside the Razorpay modal like "Payment not completed."

After showing this message, I want to close the modal programmatically (not just rely on the user clicking the close button).

The current ondismiss function works only when the user manually closes the modal, but I need a method like close() to trigger closing the modal from code.

Expected behavior:

A method such as razorpay.close() (or similar) that closes the payment modal programmatically.

This will help in handling payment failures gracefully by allowing the app to show a failure message and then automatically close the modal and redirect.

Udhaykrishn avatar May 16 '25 18:05 Udhaykrishn

Could you please guide me where (in which file or part of the code) I should start working to add this method like razorpay.close()

yashdev99 avatar Sep 08 '25 02:09 yashdev99