Skip to content

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(merchant-admin): update admin dashboard branding placeholders and title dynamically

ArunGupta1526bfea9a53bc4f
diff --git a/apps/merchant-admin/src/__tests__/merchant-admin.test.js b/apps/merchant-admin/src/__tests__/merchant-admin.test.js
index a8efb3b..c5765cd 100644
--- a/apps/merchant-admin/src/__tests__/merchant-admin.test.js
+++ b/apps/merchant-admin/src/__tests__/merchant-admin.test.js
@@ -4,6 +4,7 @@ import http from 'node:http';
import { Database } from '@youpi/db';
import { getAdminToken } from '@youpi/common';
import { startAdminServer } from '../index.js';
+import { AdminServer } from '../server.js';
describe('Merchant Admin Integration Tests', () => {
let serverInstance;
@@ -78,4 +79,18 @@ describe('Merchant Admin Integration Tests', () => {
const wrongQueryLogs = await get('/api/logs/stream?token=wrong-token');
assert.equal(wrongQueryLogs.status, 401);
});
+
+ test('renderHtml injects dynamic DEFAULT_APP_NAME into title and brand header', () => {
+ const origEnv = { ...process.env };
+ process.env.DEFAULT_APP_NAME = 'ApexMerchant Suite';
+
+ const adminServer = new AdminServer({ db: testDb });
+ const html = adminServer.renderHtml();
+
+ assert.ok(html.includes('<title>Merchant &amp; Supervisor Hub - ApexMerchant Suite</title>') || html.includes('<title>Merchant & Supervisor Hub - ApexMerchant Suite</title>'));
+ assert.ok(html.includes('<span>🛡️ ApexMerchant Suite</span>'));
+ assert.ok(html.includes('Security Engine v2 &bull; ApexMerchant Suite'));
+
+ process.env = { ...origEnv };
+ });
});
diff --git a/apps/merchant-admin/src/server.js b/apps/merchant-admin/src/server.js
index 66e1b18..78f6cd7 100644
--- a/apps/merchant-admin/src/server.js
+++ b/apps/merchant-admin/src/server.js
@@ -74,11 +74,16 @@ export class AdminServer {
this.template = fs.readFileSync(this.htmlTemplatePath, 'utf8');
} catch {}
+ const appName = (process.env.DEFAULT_APP_NAME || '').trim() || 'YOUPI PG';
+ const primaryColor = (process.env.DEFAULT_PRIMARY_COLOR || '').trim() || '#2563eb';
+
let html = this.template;
// Always use empty string '' so client fetch calls hit the merchant admin's own /api proxy!
// This completely eliminates CORS errors, tunnel downtime 530s, and cross-origin failures.
const clientApiBase = '';
html = html.replaceAll('{{API_BASE_URL}}', clientApiBase);
+ html = html.replaceAll('{{APP_NAME}}', appName);
+ html = html.replaceAll('{{DEFAULT_PRIMARY_COLOR}}', primaryColor);
return html;
}
diff --git a/apps/merchant-admin/src/views/admin.html b/apps/merchant-admin/src/views/admin.html
index 981401d..a56ebc7 100644
--- a/apps/merchant-admin/src/views/admin.html
+++ b/apps/merchant-admin/src/views/admin.html
@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Merchant & Supervisor Hub - YOUPI PG</title>
+ <title>Merchant & Supervisor Hub - {{APP_NAME}}</title>
<script>
/* Apply saved theme pref (system | light | dark) before first paint to avoid a flash. */
(function () {
@@ -1200,7 +1200,7 @@
<header>
<div class="brand-group">
<div class="brand-title">
- <span>🛡️ YOUPI PG</span>
+ <span>🛡️ {{APP_NAME}}</span>
</div>
<span class="brand-badge">Merchant &amp; Supervisor Hub</span>
</div>
@@ -1569,7 +1569,7 @@
<div>
<label style="display:block; font-size:0.82rem; font-weight:700; margin-bottom:0.35rem;">Gateway
Title / App Name</label>
- <input id="settingAppName" type="text" value="YOUPI PG" placeholder="e.g. YOUPI Pay"
+ <input id="settingAppName" type="text" value="{{APP_NAME}}" placeholder="e.g. {{APP_NAME}}"
style="width:100%;" oninput="updateLiveWhiteLabelPreview()" />
</div>
</div>
@@ -1778,7 +1778,7 @@
<span>🛒</span>
<span id="mockupSubbannerText"
style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">Verified &amp; Protected by
- YOUPI PG</span>
+ {{APP_NAME}}</span>
</div>
</div>
@@ -1822,11 +1822,11 @@
<div
style="display:flex; align-items:center; justify-content:center; gap:5px; font-size:10px; font-weight:700; color:#0b63e5; margin-bottom:5px;">
<span>🛡️</span>
- <span id="mockupFooterGuarantee">100% Payment Protection by YOUPI PG</span>
+ <span id="mockupFooterGuarantee">100% Payment Protection by {{APP_NAME}}</span>
</div>
<div id="mockupLegalDisclaimer"
style="font-size:9px; color:#64748b; text-align:center; margin-bottom:8px;">
- Secured by YOUPI PG &amp; 256-Bit Bank Encryption &bull; Privacy Notice
+ Secured by {{APP_NAME}} &amp; 256-Bit Bank Encryption &bull; Privacy Notice
</div>
<div
style="display:flex; justify-content:space-between; align-items:center; background:#0f172a; border-radius:8px; padding:8px 12px; color:#ffffff;">
@@ -3472,7 +3472,7 @@
<div
style="margin-top:1.5rem; display:flex; justify-content:space-between; align-items:center; border-top:1px solid #1e293b; padding-top:1rem;">
- <div style="font-size:0.75rem; color:#64748b;">Security Engine v2 &bull; YOUPI PG</div>
+ <div style="font-size:0.75rem; color:#64748b;">Security Engine v2 &bull; {{APP_NAME}}</div>
<div style="display:flex; gap:0.75rem;">
<button class="btn btn-secondary" onclick="closeBanDetailsModal()">Close</button>
<button id="btnModalUnbanTrigger" class="btn btn-success"
@@ -4699,7 +4699,7 @@
function updateLiveWhiteLabelPreview() {
const bName = document.getElementById('settingBusinessName')?.value.trim() || 'Merchant Checkout';
- const appName = document.getElementById('settingAppName')?.value.trim() || 'YOUPI PG';
+ const appName = document.getElementById('settingAppName')?.value.trim() || '{{APP_NAME}}' || 'YOUPI PG';
const logoUrl = document.getElementById('settingLogoUrl')?.value.trim() || '';
const primaryColor = document.getElementById('settingPrimaryColor')?.value.trim() || '#0b63e5';
const headerTheme = document.getElementById('settingHeaderTheme')?.value || 'gradient';
@@ -4805,7 +4805,7 @@
setVal('settingWebhookUrl', mData.webhookUrl);
setVal('settingWebhookSecret', mData.webhookSecret);
- setVal('settingAppName', branding.appName || 'YOUPI PG');
+ setVal('settingAppName', branding.appName || '{{APP_NAME}}' || 'YOUPI PG');
setVal('settingLogoUrl', branding.logoUrl);
setVal('settingSidebarNotice', branding.sidebarNotice);
setVal('settingFooterGuarantee', branding.footerGuarantee);
@@ -4983,7 +4983,7 @@
async function saveMerchantBrandingAndToggles() {
settingsLoaded = true;
const businessName = document.getElementById('settingBusinessName')?.value.trim() || '';
- const appName = document.getElementById('settingAppName')?.value.trim() || 'YOUPI PG';
+ const appName = document.getElementById('settingAppName')?.value.trim() || '{{APP_NAME}}' || 'YOUPI PG';
const logoUrl = document.getElementById('settingLogoUrl')?.value.trim() || '';
const primaryColor = document.getElementById('settingPrimaryColor')?.value.trim() || '#0b63e5';
const sidebarNotice = document.getElementById('settingSidebarNotice')?.value.trim() || (currentMerchantBranding?.sidebarNotice || '');