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(checkout): resolve unbalanced DOM wrapper causing collapsed QR workspace on macOS/iOS (Closes #90)
Harshc0587dff8379
diff --git a/apps/checkout-portal/src/__tests__/checkout-portal.test.js b/apps/checkout-portal/src/__tests__/checkout-portal.test.jsindex 283427e..3ecb4fe 100644--- a/apps/checkout-portal/src/__tests__/checkout-portal.test.js+++ b/apps/checkout-portal/src/__tests__/checkout-portal.test.js@@ -196,5 +196,25 @@ describe('Checkout Portal Integration Tests', () => {assert.ok(res.text.includes('STORAGE_KEY_IDENTITY'));assert.ok(res.text.includes('sanitizeRedirectUrl'));});++ test('GET /checkout/:id has balanced DOM structure so ypgStickyFooter stays inside ypg-pc-workspace (Issue #90)', async () => {+ const res = await get('/checkout/pay_test_uuid_12345');+ assert.equal(res.status, 200);++ // Must NOT have a duplicate <div class="ypg-body"> wrapper around <main class="ypg-body">+ assert.equal(res.text.includes('<div class="ypg-body">'), false, 'checkout.html must not wrap partials in a duplicate <div class="ypg-body">');+ assert.ok(res.text.includes('<main class="ypg-body">'), 'header partial must open <main class="ypg-body">');++ // Verify ypgStickyFooter is closed BEFORE END ypg-pc-workspace, and there are balanced <div> / </div> tags inside ypg-pc-workspace+ const wsStart = res.text.indexOf('<div class="ypg-pc-workspace">');+ const footerIdx = res.text.indexOf('id="ypgStickyFooter"');+ const wsEnd = res.text.indexOf('<!-- END ypg-pc-workspace -->');+ assert.ok(wsStart > 0 && footerIdx > wsStart && wsEnd > footerIdx, 'ypgStickyFooter must sit inside ypg-pc-workspace');++ const workspaceSlice = res.text.slice(wsStart, wsEnd);+ const openDivs = (workspaceSlice.match(/<div\b/g) || []).length;+ const closeDivs = (workspaceSlice.match(/<\/div>/g) || []).length;+ assert.equal(openDivs, closeDivs, `ypg-pc-workspace must have balanced <div> (${openDivs}) and </div> (${closeDivs}) tags so ypgStickyFooter is not ejected as a 3rd flex column on macOS/iOS`);+ });});});diff --git a/apps/checkout-portal/src/views/checkout.html b/apps/checkout-portal/src/views/checkout.htmlindex 0e40a14..aa27305 100644--- a/apps/checkout-portal/src/views/checkout.html+++ b/apps/checkout-portal/src/views/checkout.html@@ -19,11 +19,8 @@<!-- include:partials/header.html -->- <!-- 3. SCROLLABLE BODY -->- <div class="ypg-body">- <!-- include:partials/auth.html -->- <!-- include:partials/payment-methods.html -->- </div>+ <!-- include:partials/auth.html -->+ <!-- include:partials/payment-methods.html --><!-- include:partials/footer.html -->@@ -1999,6 +1996,9 @@if (window.isAutoBindingSession || !PAYMENT_ID || !token || !customerId) return;window.isAutoBindingSession = true;try {+ if (!DeviceIdentity.deviceId || !DeviceIdentity.deviceToken) {+ await DeviceIdentity.getOrRegister();+ }const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/bind-customer`, {method: 'POST',headers: getApiHeaders({@@ -2028,18 +2028,27 @@}// 3. Pre-Gateway Customer Authentication Gate (Preserves identity up to 1 week)+ const preserved = getPreservedIdentity();+ if (preserved && preserved.token && !activeToken) {+ activeToken = preserved.token;+ }if (data.customer) {activeCustomer = data.customer;- } else if (!activeCustomer) {- const preserved = getPreservedIdentity();- if (preserved && preserved.customer) {- activeCustomer = preserved.customer;- activeToken = preserved.token || activeToken;- }+ } else if (!activeCustomer && preserved && preserved.customer) {+ activeCustomer = preserved.customer;}- const hasCustomer = Boolean(data.customer || activeCustomer);+ const hasCustomer = Boolean(+ (data.customer || activeCustomer) &&+ (data.status !== 'INITIATED' || Boolean(activeToken))+ );if (!hasCustomer) {+ if (data.customer && data.customer.phone) {+ const mobInput = document.getElementById('authMobileInput');+ if (mobInput && !mobInput.value) {+ mobInput.value = String(data.customer.phone).replace(/\D/g, '').slice(-10);+ }+ }setGatewayAuthMode(true);const stepMob = document.getElementById('authStepMobile');const isAlreadyOnMobile = stepMob && !stepMob.hidden;@@ -2092,7 +2101,7 @@queuePollTimer = null;}- if (data.status === 'ACTIVE' || (data.status === 'INITIATED' && (data.timeRemainingSeconds > 0 || data.expiresAt))) {+ if (data.status === 'ACTIVE' || data.status === 'INITIATED') {renderMethodSelectorBar(data);hideAllContent();diff --git a/apps/checkout-portal/src/views/partials/payment-methods.html b/apps/checkout-portal/src/views/partials/payment-methods.htmlindex 7042778..32edc06 100644--- a/apps/checkout-portal/src/views/partials/payment-methods.html+++ b/apps/checkout-portal/src/views/partials/payment-methods.html@@ -523,4 +523,5 @@</div></div>+ </div></main>