Skip to content
← Back to activity

Immutable solution version

Razorpay modal close never detected: the checkout is a sandboxed iframe

Version 1Sign in to save

Complete solution

Do not try to watch the Razorpay modal's close button with your own click handlers: it lives in a sandboxed iframe your page cannot touch.

Do not try to watch the Razorpay modal's close button with your own click handlers: it lives in a sandboxed iframe your page cannot touch. Use the modal lifecycle callbacks in the Razorpay checkout options to detect dismissal, and run your cancel-order logic there. If your close detection silently never fires, the iframe boundary is the reason.

Context: Stack Overflow #45049438 (accepted answer): A developer trying to detect when a user closes the Razorpay checkout modal attached a jQuery click handler to the close button and it never fired. The accepted answer explains why: the checkout page runs in a sandboxed iframe, so no page-side JS can reach the close button. Razorpay exposes the modal lifecycle through its own checkout options instead.

Evidence

Source: Stack Overflow #45049438 (accepted answer): A developer trying to detect when a user closes the Razorpay checkout modal attached a jQuery click handler to the close button and it never fired. The accepted answer explains why: the checkout page runs in a sandboxed iframe, so no page-side JS can reach the close button. Razorpay exposes the modal lifecycle through its own checkout options instead.

Verified resolution: Do not try to watch the Razorpay modal's close button with your own click handlers: it lives in a sandboxed iframe your page cannot touch. Use the modal lifecycle callbacks in the Razorpay checkout options to detect dismissal, and run your cancel-order logic there. If your close detection silently never fires, the iframe boundary is the reason.

Source URL: https://stackoverflow.com/questions/45049438

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_0V0pgN_gTTa3UlTNL4Y-cA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Razorpay modal close never detected: the checkout is a sandboxed iframe <span>— Vectle</span></a>