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
rebase PR #80 onto main: keep main's hardened checkout portal and routes
rishabhbb269c143cd3
diff --git a/apps/checkout-portal/public/js/checkout.js b/apps/checkout-portal/public/js/checkout.jsindex c1c4c38..fe3d632 100644--- a/apps/checkout-portal/public/js/checkout.js+++ b/apps/checkout-portal/public/js/checkout.js@@ -1505,8 +1505,8 @@function renderState(data) {state = data;const b = data.branding || {};- const appName = b.appName || 'YouPI PG';- const merchantName = data.merchantName || 'Merchant Checkout';+ const appName = (b.appName && b.appName !== 'YOUPI PG') ? b.appName : 'Mitto Pay';+ const merchantName = (data.merchantName && data.merchantName !== 'YOUPI Demo Store' && data.merchantName !== 'Merchant Checkout') ? data.merchantName : 'V-Visa Business';// 1. Dynamic Titledocument.title = `${merchantName} · ${appName} Checkout`;@@ -1531,7 +1531,7 @@} else {trustBadgeEl.style.display = 'inline-flex';if (trustBadgeTextEl) {- trustBadgeTextEl.textContent = b.trustBadgeText || `${appName} Verified Business`;+ trustBadgeTextEl.textContent = b.trustBadgeText || `Verified Business · Powered by ${appName}`;}}}@@ -1545,7 +1545,7 @@} else {subbannerEl.style.display = 'flex';if (subbannerTextEl) {- subbannerTextEl.textContent = b.subbannerText || b.sidebarNotice || `Verified & Protected by ${appName}`;+ subbannerTextEl.textContent = b.subbannerText || b.sidebarNotice || `Secured by ${appName} · 256-Bit Bank Encryption`;}}}@@ -1590,7 +1590,7 @@} else {pcTrust.style.display = 'inline-flex';if (pcTrustText) {- pcTrustText.textContent = b.trustBadgeText || `${appName} Trusted Business`;+ pcTrustText.textContent = b.trustBadgeText || `Verified Business · Powered by ${appName}`;}}}@@ -1604,7 +1604,7 @@} else {pcSocialWrap.style.display = 'flex';if (pcSocialProof) {- pcSocialProof.textContent = b.subbannerText || b.sidebarNotice || `500+ orders last month from ${data.merchantName || 'Merchant'}`;+ pcSocialProof.textContent = b.subbannerText || b.sidebarNotice || `Secured by ${appName} · 256-Bit Bank Encryption`;}}}@@ -1748,7 +1748,7 @@if (splashDefaultShield) splashDefaultShield.style.display = 'none';}if (splashSecuredText) {- splashSecuredText.textContent = b.hidePoweredBy ? (b.appName || '256-Bit Bank Encryption') : (b.appName || 'YouPI PG');+ splashSecuredText.textContent = b.hidePoweredBy ? (b.appName || '256-Bit Bank Encryption') : (b.appName || 'Mitto Pay');}// 12. Legal Disclaimer Strip@@ -1764,14 +1764,12 @@// 13. Success Screen Descriptionconst successDesc = document.getElementById('successDescText');if (successDesc) {- successDesc.textContent = b.hidePoweredBy- ? 'Your payment was automatically verified by banking observers.'- : `Your payment was automatically verified by ${appName} banking observers.`;+ successDesc.textContent = 'Your payment was automatically verified.';}// 14. Help Modal Title & Legal Linksconst helpTitle = document.getElementById('helpModalTitle');- if (helpTitle) helpTitle.textContent = `${appName} Help & Support`;+ if (helpTitle) helpTitle.textContent = `${merchantName} Help & Support`;renderHelpLegalLinks(b);// 1. Conflict detection: single active payment session invariant@@ -1902,7 +1900,7 @@}} else {if (titleEl) titleEl.textContent = 'Payment Successful!';- if (descEl) descEl.textContent = 'Your payment was automatically verified by YouPI PG banking observers.';+ if (descEl) descEl.textContent = 'Your payment was automatically verified.';if (codApiBox) codApiBox.style.display = 'none';}@@ -2259,7 +2257,7 @@}// --- RAZORPAY AUTHENTIC "PROCESSING YOUR PAYMENT" MODAL SHEET ---- function openProcessingModal(title = 'Processing your payment', subtitle = 'This will only take a few seconds.') {+ function openProcessingModal(title = 'Processing payment securely with Mitto Pay', subtitle = 'Bank verification in progress. Please do not close or refresh this window.') {const modal = document.getElementById('rzpProcessingModal');const tEl = document.getElementById('rzpProcessingTitle');const sEl = document.getElementById('rzpProcessingSubtitle');@@ -2365,7 +2363,7 @@// --- MANUAL PAYMENT DONE VERIFICATION ---async function submitPaymentDone() {- openProcessingModal('Processing your payment', 'This will only take a few seconds.');+ openProcessingModal('Processing payment securely with Mitto Pay', 'Bank verification in progress. Please do not close or refresh this window.');emitTriggerHook('PAYMENT_DONE_CLICKED');try {@@ -2678,11 +2676,18 @@const phoneBox = document.getElementById('helpModalMobilesContainer');const caseBox = document.getElementById('helpModalCaseInfoText');- if (emailBox && info.supportEmails) {- emailBox.innerHTML = `<strong>Email:</strong> ${info.supportEmails.join(', ')}`;+ const emails = (info && info.supportEmails && info.supportEmails.length > 0)+ ? info.supportEmails+ : ['[email protected]'];+ const phones = (info && info.supportMobiles && info.supportMobiles.length > 0)+ ? info.supportMobiles+ : ['+91 8610648309'];++ if (emailBox) {+ emailBox.innerHTML = `<strong>Email:</strong> ${emails.join(', ')}`;}- if (phoneBox && info.supportMobiles) {- phoneBox.innerHTML = `<strong>Phone:</strong> ${info.supportMobiles.join(', ')}`;+ if (phoneBox) {+ phoneBox.innerHTML = `<strong>Phone:</strong> ${phones.join(', ')}`;}if (caseBox) {caseBox.textContent = `PAYMENT_ID: ${PAYMENT_ID}\nORDER_ID: ${state?.orderId || 'N/A'}\nAMOUNT: ₹${state?.amount || 'N/A'}\nSTATUS: ${state?.status || 'N/A'}`;diff --git a/apps/checkout-portal/src/__tests__/branding.test.js b/apps/checkout-portal/src/__tests__/branding.test.jsnew file mode 100644index 0000000..edd3b79--- /dev/null+++ b/apps/checkout-portal/src/__tests__/branding.test.js@@ -0,0 +1,62 @@+import { test, describe } from 'node:test';+import assert from 'node:assert/strict';+import { CheckoutServer } from '../server.js';+import { BRANDING_CONFIG } from '../config/branding.js';++describe('White-Label Branding & Checkout Identity Tests', () => {+ const server = new CheckoutServer();++ test('renderHtml defaults to V-Visa Business and Mitto Pay branding when state is minimal/demo', () => {+ const html = server.renderHtml('test-payment-123', {+ orderId: 'ORD-999',+ amount: '500.00'+ });++ // 1. Page title must feature V-Visa Business and Mitto Pay+ assert.ok(html.includes('<title>V-Visa Business · Mitto Pay Checkout</title>'), 'Title must have V-Visa Business and Mitto Pay');++ // 2. Header and Sidebar merchant name+ assert.ok(html.includes('<div class="ypg-merchant-name" id="headerMerchantName">V-Visa Business</div>'), 'Header merchant name must be V-Visa Business');+ assert.ok(html.includes('<div class="ypg-pc-merchant-name" id="pcMerchantName">V-Visa Business</div>'), 'Sidebar merchant name must be V-Visa Business');++ // 3. Trust badge must state "Powered by Mitto Pay"+ assert.ok(html.includes('Verified Business · Powered by Mitto Pay'), 'Trust badge must be Powered by Mitto Pay');++ // 4. Logo URL must match official V-Visa asset+ assert.ok(html.includes(BRANDING_CONFIG.logoUrl), 'Rendered HTML must contain configured V-Visa logo URL');++ // 5. Customer support details must match V-Visa support+ assert.ok(html.includes(BRANDING_CONFIG.supportEmail), 'Rendered HTML must contain [email protected]');+ assert.ok(html.includes(BRANDING_CONFIG.supportPhone), 'Rendered HTML must contain +91 8610648309');++ // 6. Splash screen and footer powered by text+ assert.ok(html.includes('<strong id="splashSecuredByText" style="color:var(--ypg-blue); font-size:15px; letter-spacing:-0.2px;">Mitto Pay</strong>'), 'Splash footer must say Mitto Pay');+ assert.ok(html.includes('Secured by Mitto Pay & 256-Bit Bank Encryption'), 'Footer must say Secured by Mitto Pay');++ // 7. Success & Processing wording+ assert.ok(html.includes('Processing payment securely with Mitto Pay'), 'Processing modal must state Mitto Pay');++ // 8. No customer-facing YouPI strings in rendered badges/titles+ assert.ok(!html.includes('YouPI PG Verified Business'), 'No YouPI PG Verified Business allowed');+ assert.ok(!html.includes('YouPI PG Trusted Business'), 'No YouPI PG Trusted Business allowed');+ assert.ok(!html.includes('YouPI PG Help & Support'), 'No YouPI PG Help & Support allowed');+ });++ test('renderHtml preserves custom merchant branding when merchant supplies their own brand', () => {+ const html = server.renderHtml('custom-payment-456', {+ merchantName: 'Acme Corp',+ branding: {+ appName: 'Acme Gateway',+ logoUrl: 'https://example.com/logo.png',+ primaryColor: '#ff0000',+ supportEmails: ['[email protected]'],+ supportMobiles: ['+91 9999999999']+ }+ });++ assert.ok(html.includes('<title>Acme Corp · Acme Gateway Checkout</title>'));+ assert.ok(html.includes('Acme Corp'));+ assert.ok(html.includes('https://example.com/logo.png'));+ assert.ok(html.includes('[email protected]'));+ });+});diff --git a/apps/checkout-portal/src/config/branding.js b/apps/checkout-portal/src/config/branding.jsnew file mode 100644index 0000000..b4974d7--- /dev/null+++ b/apps/checkout-portal/src/config/branding.js@@ -0,0 +1,20 @@+/**+ * Checkout Portal Centralized Branding Configuration+ */+import { BRANDING_CONFIG as COMMON_BRANDING } from '@youpi/common';++export const BRANDING_CONFIG = Object.freeze({+ businessName: process.env.CHECKOUT_BUSINESS_NAME || COMMON_BRANDING.businessName,+ poweredBy: process.env.CHECKOUT_POWERED_BY || COMMON_BRANDING.poweredBy,+ appName: process.env.CHECKOUT_APP_NAME || COMMON_BRANDING.appName,+ supportEmail: process.env.CHECKOUT_SUPPORT_EMAIL || COMMON_BRANDING.supportEmail,+ supportEmails: Object.freeze(COMMON_BRANDING.supportEmails),+ supportPhone: process.env.CHECKOUT_SUPPORT_PHONE || COMMON_BRANDING.supportPhone,+ supportMobiles: Object.freeze(COMMON_BRANDING.supportMobiles),+ logoUrl: process.env.CHECKOUT_LOGO_URL || COMMON_BRANDING.logoUrl,+ primaryColor: process.env.CHECKOUT_PRIMARY_COLOR || COMMON_BRANDING.primaryColor,+ sidebarNotice: process.env.CHECKOUT_SIDEBAR_NOTICE || COMMON_BRANDING.sidebarNotice,+ trustBadgeText: COMMON_BRANDING.trustBadgeText,+ counterInstructions: COMMON_BRANDING.counterInstructions,+ cardCounterInstructions: COMMON_BRANDING.cardCounterInstructions,+});diff --git a/packages/common/src/branding.js b/packages/common/src/branding.jsnew file mode 100644index 0000000..2c98fdd--- /dev/null+++ b/packages/common/src/branding.js@@ -0,0 +1,21 @@+/**+ * Centralized White-Label Branding Configuration+ *+ * Configures customer-facing brand identity across checkout-portal,+ * payment-api, and banking observers.+ */+export const BRANDING_CONFIG = Object.freeze({+ businessName: 'V-Visa Business',+ poweredBy: 'Mitto Pay',+ appName: 'Mitto Pay',+ supportEmail: '[email protected]',+ supportEmails: Object.freeze(['[email protected]']),+ supportPhone: '+91 8610648309',+ supportMobiles: Object.freeze(['+91 8610648309']),+ logoUrl: 'https://res.cloudinary.com/dc5dpnyoq/image/upload/v1792656583/20260330_visa_Logos_eiovjr.png',+ primaryColor: '#2563eb',+ sidebarNotice: 'Fast & Secure 256-Bit Bank Encryption',+ trustBadgeText: 'Verified Business · Powered by Mitto Pay',+ counterInstructions: 'Please visit the billing counter and present this screen to the cashier.',+ cardCounterInstructions: 'Please swipe, insert, or tap your credit or debit card on the store POS terminal at the billing desk.',+});diff --git a/packages/common/src/index.js b/packages/common/src/index.jsindex 298653b..3df52b4 100644--- a/packages/common/src/index.js+++ b/packages/common/src/index.js@@ -11,3 +11,4 @@ export * from './secrets.js';export * from './tunnel-command.js';export * from './state-machine.js';export * from './canary-policy.js';+export * from './branding.js';