A self-hosted UPI & COD payment gateway with zero per-transaction platform fees, universal JavaScript checkout integration, dynamic QR payments, WhatsApp OTP authentication, and automated payment verification.
JavaScript
fix(sdk): bind delayed cleanup to its checkout modal
generaltony007fe4175db5c49
diff --git a/packages/merchant-sdk/src/youpi-checkout.js b/packages/merchant-sdk/src/youpi-checkout.jsindex c5250a4..0c3f10a 100644--- a/packages/merchant-sdk/src/youpi-checkout.js+++ b/packages/merchant-sdk/src/youpi-checkout.js@@ -324,13 +324,17 @@this.backdrop.classList.remove('active');}+ // The closing modal may no longer be the current one when its animation ends.+ const closingBackdrop = this.backdrop;setTimeout(() => {- if (this.backdrop && this.backdrop.parentNode) {- this.backdrop.parentNode.removeChild(this.backdrop);+ if (closingBackdrop && closingBackdrop.parentNode) {+ closingBackdrop.parentNode.removeChild(closingBackdrop);+ }+ if (this.backdrop === closingBackdrop) {+ this.backdrop = null;+ this.container = null;+ this.iframe = null;}- this.backdrop = null;- this.container = null;- this.iframe = null;if (typeof this.options.onClose === 'function') {this.options.onClose();@@ -444,6 +448,7 @@ _isSafeRedirect(url) {const rawData = e.data.data || e.data;if (event === 'youpi.payment_success') {+ const successBackdrop = this.backdrop;const payload = e.data.data || {};const result = {status: 'SUCCESS',@@ -467,6 +472,7 @@ _isSafeRedirect(url) {}setTimeout(() => {+ if (!this.isOpen || this.backdrop !== successBackdrop) return;this.close(() => {if (this.options.successUrl) {const delim = this.options.successUrl.includes('?') ? '&' : '?';