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
feat(checkout-portal): allow universal iframe embedding and add compact mobile responsiveness
ArunGupta152688c35acbf2ad
diff --git a/apps/checkout-portal/package.json b/apps/checkout-portal/package.jsonindex 1e97a92..b46aaf9 100644--- a/apps/checkout-portal/package.json+++ b/apps/checkout-portal/package.json@@ -9,6 +9,7 @@"test": "node --test src/__tests__/**/*.test.js"},"dependencies": {- "@youpi/common": "*"+ "@youpi/common": "*",+ "@youpi/core": "*"}}diff --git a/apps/checkout-portal/public/css/checkout.css b/apps/checkout-portal/public/css/checkout.cssindex 857f4e7..7a33268 100644--- a/apps/checkout-portal/public/css/checkout.css+++ b/apps/checkout-portal/public/css/checkout.css@@ -3032,4 +3032,23 @@.ypg-btn-downtime-alt:hover {opacity: 0.9;+ }++ /* ULTRA-COMPACT MOBILE DEVICES (<= 360px) */+ @media (max-width: 360px) {+ .ypg-body {+ padding: 10px 10px 120px 10px !important;+ }+ .ypg-header {+ padding: 10px 12px !important;+ }+ .ypg-otp-control {+ font-size: 18px !important;+ letter-spacing: 6px !important;+ padding: 8px !important;+ }+ .ypg-qr-img {+ max-width: 170px !important;+ max-height: 170px !important;+ }}\ No newline at end of filediff --git a/apps/checkout-portal/src/sdk/youpi-checkout.js b/apps/checkout-portal/src/sdk/youpi-checkout.jsindex 2641b71..121471f 100644--- a/apps/checkout-portal/src/sdk/youpi-checkout.js+++ b/apps/checkout-portal/src/sdk/youpi-checkout.js@@ -253,14 +253,14 @@targetUrl = `${this.options.portalUrl}/checkout/demo`;}- // If running on localhost / 127.0.0.1 and targetUrl points to remote domain, normalize to localhost host+ // If running on localhost / 127.0.0.1 and targetUrl points to remote external origin, keep path and point to local hostif (isBrowser && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) {- if (targetUrl.includes('gauravtesting.online')) {- try {- const parsed = new URL(targetUrl);+ try {+ const parsed = new URL(targetUrl, window.location.origin);+ if (parsed.hostname !== 'localhost' && parsed.hostname !== '127.0.0.1' && !this.options.portalUrl) {targetUrl = `${window.location.protocol}//${window.location.host}${parsed.pathname}${parsed.search}`;- } catch {}- }+ }+ } catch {}}// Add embedded flag and custom paramsdiff --git a/apps/checkout-portal/src/sdk/youpi.js b/apps/checkout-portal/src/sdk/youpi.jsindex 9fbafb7..3e0fede 100644--- a/apps/checkout-portal/src/sdk/youpi.js+++ b/apps/checkout-portal/src/sdk/youpi.js@@ -253,14 +253,14 @@targetUrl = `${this.options.portalUrl}/checkout/demo`;}- // If running on localhost / 127.0.0.1 and targetUrl points to remote domain, normalize to localhost host+ // If running on localhost / 127.0.0.1 and targetUrl points to remote external origin, keep path and point to local hostif (isBrowser && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) {- if (targetUrl.includes('gauravtesting.online')) {- try {- const parsed = new URL(targetUrl);+ try {+ const parsed = new URL(targetUrl, window.location.origin);+ if (parsed.hostname !== 'localhost' && parsed.hostname !== '127.0.0.1' && !this.options.portalUrl) {targetUrl = `${window.location.protocol}//${window.location.host}${parsed.pathname}${parsed.search}`;- } catch {}- }+ }+ } catch {}}// Add embedded flag and custom paramsdiff --git a/apps/checkout-portal/src/server.js b/apps/checkout-portal/src/server.jsindex 563de9a..d1f7430 100644--- a/apps/checkout-portal/src/server.js+++ b/apps/checkout-portal/src/server.js@@ -2,7 +2,7 @@ import http from 'node:http';import fs from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';-import { generateQrSvg } from './qr.js';+import { generateQrSvg } from '@youpi/core';import { getInternalServiceToken } from '@youpi/common';const __filename = fileURLToPath(import.meta.url);@@ -16,6 +16,13 @@ const BASE_SECURITY_HEADERS = Object.freeze({'Content-Security-Policy': "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; frame-ancestors 'self'; base-uri 'none'; form-action 'self'; object-src 'none'"});+/** Security headers applied to embeddable checkout pages allowing universal merchant iframe integration. */+const CHECKOUT_FRAME_HEADERS = Object.freeze({+ 'X-Content-Type-Options': 'nosniff',+ 'Referrer-Policy': 'strict-origin-when-cross-origin',+ 'Content-Security-Policy': "default-src 'self' data: blob:; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; frame-ancestors *; base-uri 'none'; form-action 'self'; object-src 'none'"+});+/*** Escapes a value for interpolation into HTML text or attribute context.* Order ids, merchant names and branding fields are attacker-influenced, so they must@@ -314,7 +321,7 @@ export class CheckoutServer {'Pragma': 'no-cache','Expires': '0','Access-Control-Allow-Origin': '*',- ...BASE_SECURITY_HEADERS+ ...CHECKOUT_FRAME_HEADERS});res.end(svg);return;@@ -333,7 +340,7 @@ res.writeHead(200, {'Pragma': 'no-cache','Expires': '0','Access-Control-Allow-Origin': '*',- ...BASE_SECURITY_HEADERS+ ...CHECKOUT_FRAME_HEADERS});res.end(rendered);return;