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(checkout-portal): modularize checkout.html into 7 partials and extract static CSS/JS assets

ArunGupta152673f861b810ca
diff --git a/apps/checkout-portal/public/css/checkout.css b/apps/checkout-portal/public/css/checkout.css
new file mode 100644
index 0000000..857f4e7
--- /dev/null
+++ b/apps/checkout-portal/public/css/checkout.css
@@ -0,0 +1,3035 @@
+ :root {
+ --ypg-blue: #0b63e5;
+ --ypg-blue-dark: #0957cb;
+ --ypg-navy: #0b1526;
+ --ypg-header-gradient: linear-gradient(180deg, #0b63e5 0%, #0957cb 100%);
+ --ypg-bg: #f8fafc;
+ --ypg-card: #ffffff;
+ --ypg-text-dark: #0f172a;
+ --ypg-text-muted: #64748b;
+ --ypg-border: #e2e8f0;
+ --ypg-border-light: #eef2f6;
+ --ypg-green: #0d9f67;
+ --ypg-green-bg: #e6f9f0;
+ --ypg-offer-bg: #eff6ff;
+ --ypg-offer-border: #dbeafe;
+ --ypg-danger: #ef4444;
+ --ypg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
+ }
+
+ * {
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0;
+ font-family: var(--ypg-font);
+ -webkit-tap-highlight-color: transparent;
+ }
+
+ [hidden],
+ #paymentGatewayInterface[hidden],
+ #preGatewayAuthView[hidden] {
+ display: none !important;
+ }
+
+ html,
+ body {
+ touch-action: pan-y;
+ -webkit-overflow-scrolling: touch;
+ height: 100%;
+ height: 100dvh;
+ margin: 0;
+ padding: 0;
+ }
+
+ body {
+ background-color: #0b0f19;
+ color: var(--ypg-text-dark);
+ min-height: 100vh;
+ min-height: 100dvh;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 0;
+ margin: 0;
+ overflow-x: hidden;
+ font-size: 14px;
+ }
+
+ body.is-embedded {
+ background: transparent;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ height: 100%;
+ height: 100dvh;
+ min-height: 100%;
+ overflow: hidden;
+ }
+
+ /* --- YOUPI PG CARD / DRAWER CONTAINER --- */
+ .ypg-wrapper {
+ width: 100%;
+ max-width: 440px;
+ min-height: 100vh;
+ background: #ffffff;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 25px 65px rgba(0, 0, 0, 0.45);
+ position: relative;
+ overflow: hidden;
+ }
+
+ @media (min-width: 601px) {
+ body:not(.is-embedded) {
+ padding: 24px;
+ }
+
+ body:not(.is-embedded) .ypg-wrapper {
+ min-height: 640px;
+ max-height: 92vh;
+ border-radius: 16px;
+ }
+
+ body.is-embedded .ypg-wrapper {
+ min-height: 100vh;
+ height: 100%;
+ max-width: 100%;
+ border-radius: 0;
+ }
+ }
+
+ @media (max-width: 600px) {
+ .ypg-wrapper {
+ max-width: 100vw;
+ border-top-left-radius: 20px;
+ border-top-right-radius: 20px;
+ }
+ }
+
+ /* --- MOBILE TOP DRAG HANDLE --- */
+ .ypg-drag-handle-bar {
+ display: none;
+ width: 36px;
+ height: 4px;
+ background: rgba(255, 255, 255, 0.45);
+ border-radius: 9999px;
+ margin: 8px auto 6px auto;
+ }
+
+ @media (max-width: 600px) {
+ .ypg-drag-handle-bar {
+ display: block;
+ }
+ }
+
+ /* --- 1. INITIAL LOADING SPLASH SCREEN (YOUPI PG EMBLEM) --- */
+ .ypg-splash-screen {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: #f4f5f7;
+ z-index: 100;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ transition: opacity 0.4s ease, visibility 0.4s ease;
+ }
+
+ .ypg-splash-screen.fade-out {
+ opacity: 0;
+ visibility: hidden;
+ pointer-events: none;
+ }
+
+ .ypg-splash-center {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ margin-bottom: 70px;
+ }
+
+ .ypg-shield-orbit-box {
+ position: relative;
+ width: 110px;
+ height: 110px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .ypg-shield-icon-svg {
+ width: 82px;
+ height: 94px;
+ filter: drop-shadow(0 8px 18px rgba(11, 99, 229, 0.3));
+ animation: ypgPulseShield 2s infinite ease-in-out;
+ }
+
+ @keyframes ypgPulseShield {
+
+ 0%,
+ 100% {
+ transform: scale(1);
+ }
+
+ 50% {
+ transform: scale(1.04);
+ }
+ }
+
+ .ypg-orbit-dot {
+ position: absolute;
+ width: 12px;
+ height: 12px;
+ background: #0b63e5;
+ border: 2px solid #ffffff;
+ border-radius: 50%;
+ top: 8px;
+ left: 20px;
+ box-shadow: 0 0 8px rgba(11, 99, 229, 0.6);
+ animation: ypgOrbitAnimation 1.5s infinite linear;
+ }
+
+ @keyframes ypgOrbitAnimation {
+ 0% {
+ transform: rotate(0deg) translateX(46px) rotate(0deg);
+ }
+
+ 100% {
+ transform: rotate(360deg) translateX(46px) rotate(-360deg);
+ }
+ }
+
+ .ypg-splash-footer {
+ position: absolute;
+ bottom: 24px;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 13px;
+ font-weight: 700;
+ color: #64748b;
+ }
+
+ /* --- 2. AUTHENTIC YOUPI PG HEADER --- */
+ .ypg-header {
+ background: var(--ypg-header-gradient);
+ color: #ffffff;
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ flex-shrink: 0;
+ }
+
+ .ypg-header-main-row {
+ padding: 12px 16px 10px 16px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ }
+
+ body.is-embedded .ypg-header-main-row {
+ padding-right: 56px;
+ /* Avoid collision with parent modal close button at top-right 14px */
+ }
+
+ .ypg-header-left-group {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex: 1;
+ overflow: hidden;
+ }
+
+ .ypg-btn-back {
+ background: none;
+ border: none;
+ color: #ffffff;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 4px;
+ border-radius: 6px;
+ transition: background 0.15s;
+ }
+
+ .ypg-btn-back:hover {
+ background: rgba(255, 255, 255, 0.15);
+ }
+
+ /* Teal Merchant Avatar with Initial */
+ .ypg-merchant-avatar {
+ width: 38px;
+ height: 38px;
+ border-radius: 10px;
+ background: #14b8a6;
+ border: 1.5px solid rgba(255, 255, 255, 0.85);
+ color: #ffffff;
+ font-size: 19px;
+ font-weight: 800;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
+ flex-shrink: 0;
+ overflow: hidden;
+ }
+
+ .ypg-merchant-avatar img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+
+ .ypg-merchant-text-group {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ }
+
+ .ypg-merchant-name {
+ font-size: 16px;
+ font-weight: 700;
+ color: #ffffff;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ line-height: 1.25;
+ }
+
+ /* YouPI PG Verified Business Badge */
+ .ypg-trusted-badge {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ font-size: 11.5px;
+ font-weight: 600;
+ color: rgba(255, 255, 255, 0.95);
+ margin-top: 1px;
+ }
+
+ .ypg-green-shield {
+ width: 13px;
+ height: 13px;
+ flex-shrink: 0;
+ }
+
+ /* Profile Account Icon */
+ .ypg-btn-profile {
+ width: 34px;
+ height: 34px;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.2);
+ border: none;
+ color: #ffffff;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ transition: background 0.15s;
+ flex-shrink: 0;
+ }
+
+ .ypg-btn-profile:hover {
+ background: rgba(255, 255, 255, 0.35);
+ }
+
+ /* Sub-banner */
+ .ypg-header-subbanner {
+ background: rgba(0, 0, 0, 0.12);
+ padding: 6px 16px;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 11.5px;
+ font-weight: 500;
+ color: #ffffff;
+ }
+
+ .ypg-header-subbanner svg {
+ width: 14px;
+ height: 14px;
+ flex-shrink: 0;
+ }
+
+ /* Profile Dropdown Popover */
+ .ypg-account-popover {
+ position: absolute;
+ top: 54px;
+ right: 16px;
+ background: #ffffff;
+ color: var(--ypg-text-dark);
+ border-radius: 10px;
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
+ border: 1px solid var(--ypg-border);
+ padding: 8px;
+ z-index: 50;
+ min-width: 190px;
+ animation: ypgFadeInDown 0.15s ease-out;
+ }
+
+ @keyframes ypgFadeInDown {
+ from {
+ opacity: 0;
+ transform: translateY(-6px);
+ }
+
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+ }
+
+ .ypg-popover-item {
+ width: 100%;
+ text-align: left;
+ padding: 8px 12px;
+ background: none;
+ border: none;
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--ypg-text-dark);
+ border-radius: 6px;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ .ypg-popover-item:hover {
+ background: var(--ypg-bg);
+ }
+
+ /* --- 3. SCROLLABLE BODY (WHITE SURFACE) --- */
+ .ypg-body {
+ flex: 1;
+ overflow-y: auto;
+ background: #ffffff;
+ padding: 16px 16px 20px 16px;
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ }
+
+ .ypg-page-title {
+ font-size: 18px;
+ font-weight: 700;
+ color: var(--ypg-text-dark);
+ margin-bottom: 12px;
+ letter-spacing: -0.01em;
+ }
+
+ /* Available Offers Pill */
+ .ypg-offers-pill {
+ background: var(--ypg-offer-bg);
+ border: 1px solid var(--ypg-offer-border);
+ border-radius: 9999px;
+ padding: 6px 14px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 18px;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+
+ .ypg-offers-pill:hover {
+ background: #e2eeff;
+ }
+
+ .ypg-offers-left {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 12px;
+ font-weight: 600;
+ color: #1e3a8a;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ }
+
+ .ypg-offer-icon-badge {
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ background: #fee2e2;
+ color: #b91c1c;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 11px;
+ font-weight: 800;
+ flex-shrink: 0;
+ }
+
+ .ypg-offers-right {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--ypg-blue);
+ flex-shrink: 0;
+ }
+
+ /* Section Label Row */
+ .ypg-section-label-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 8px;
+ }
+
+ .ypg-section-heading {
+ font-size: 13.5px;
+ font-weight: 600;
+ color: #334155;
+ }
+
+ .ypg-countdown-pill {
+ background: #f1f5f9;
+ border: 1px solid #e2e8f0;
+ border-radius: 9999px;
+ padding: 2px 9px;
+ font-size: 11.5px;
+ font-weight: 600;
+ color: #475569;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ }
+
+ /* --- 4. CORE UPI QR CARD (STRICTLY UPI ONLY) --- */
+ .ypg-qr-card-container {
+ background: #f8fafc;
+ border: 1px solid var(--ypg-border-light);
+ border-radius: 16px;
+ padding: 16px;
+ display: flex;
+ gap: 16px;
+ align-items: center;
+ margin-bottom: 18px;
+ }
+
+ .ypg-qr-image-box {
+ width: 130px;
+ height: 130px;
+ background: #ffffff;
+ border: 1px solid #e2e8f0;
+ border-radius: 12px;
+ padding: 6px;
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ position: relative;
+ }
+
+ .ypg-qr-image-box svg {
+ width: 100%;
+ height: 100%;
+ }
+
+ .ypg-qr-details-col {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ flex: 1;
+ overflow: hidden;
+ }
+
+ .ypg-qr-prompt-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--ypg-text-dark);
+ line-height: 1.3;
+ }
+
+ /* UPI Brand Logos */
+ .ypg-upi-logos-row {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ flex-wrap: wrap;
+ }
+
+ .ypg-app-icon {
+ width: 22px;
+ height: 22px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+ }
+
+ .ypg-app-icon img,
+ .ypg-app-icon svg {
+ width: 100%;
+ height: 100%;
+ border-radius: 50%;
+ }
+
+ .ypg-green-pill-badge {
+ background: var(--ypg-green-bg);
+ color: var(--ypg-green);
+ font-size: 11px;
+ font-weight: 600;
+ padding: 2.5px 8px;
+ border-radius: 9999px;
+ align-self: flex-start;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ }
+
+ /* Payee VPA & Copy Button */
+ .ypg-vpa-copy-row {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 2px;
+ }
+
+ .ypg-vpa-badge {
+ font-size: 11px;
+ font-weight: 600;
+ color: #475569;
+ background: #edf2f7;
+ padding: 2px 7px;
+ border-radius: 6px;
+ max-width: 140px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .ypg-btn-mini-copy {
+ background: none;
+ border: 1px solid #cbd5e1;
+ border-radius: 5px;
+ font-size: 10px;
+ font-weight: 700;
+ color: #334155;
+ padding: 2px 6px;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ transition: all 0.15s;
+ }
+
+ .ypg-btn-mini-copy:hover {
+ border-color: var(--ypg-blue);
+ color: var(--ypg-blue);
+ }
+
+ .ypg-btn-mini-copy.copied {
+ background: #10b981;
+ border-color: #10b981;
+ color: #ffffff;
+ }
+
+ /* Live Observer Radar Strip */
+ .ypg-live-observer-strip {
+ background: #f0fdf4;
+ border: 1px solid #bbf7d0;
+ border-radius: 10px;
+ padding: 10px 14px;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 12px;
+ font-weight: 600;
+ color: #166534;
+ margin-bottom: 14px;
+ }
+
+ .ypg-radar-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: #16a34a;
+ box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
+ animation: ypgPulseDot 1.8s infinite;
+ flex-shrink: 0;
+ }
+
+ @keyframes ypgPulseDot {
+ 0% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
+ }
+
+ 70% {
+ transform: scale(1);
+ box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);
+ }
+
+ 100% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
+ }
+ }
+
+ /* UPI Instructions Card */
+ .ypg-instructions-card {
+ background: #ffffff;
+ border: 1px solid var(--ypg-border);
+ border-radius: 12px;
+ padding: 14px 16px;
+ margin-bottom: 16px;
+ }
+
+ .ypg-instruction-step {
+ display: flex;
+ align-items: flex-start;
+ gap: 10px;
+ margin-bottom: 8px;
+ font-size: 12.5px;
+ color: #334155;
+ }
+
+ .ypg-instruction-step:last-child {
+ margin-bottom: 0;
+ }
+
+ .ypg-step-num {
+ width: 18px;
+ height: 18px;
+ border-radius: 50%;
+ background: #eff6ff;
+ color: var(--ypg-blue);
+ font-size: 11px;
+ font-weight: 800;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ margin-top: 1px;
+ }
+
+ /* Payment Method Selector Bar (Online / Offline Modalities) */
+ .ypg-method-selector-bar {
+ display: flex;
+ gap: 6px;
+ background: #f1f5f9;
+ padding: 4px;
+ border-radius: 10px;
+ margin-bottom: 14px;
+ border: 1px solid var(--ypg-border);
+ }
+
+ .ypg-method-tab {
+ flex: 1;
+ text-align: center;
+ padding: 7px 10px;
+ border-radius: 8px;
+ font-size: 11.5px;
+ font-weight: 700;
+ cursor: pointer;
+ border: none;
+ background: transparent;
+ color: #64748b;
+ transition: all 0.15s ease;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 5px;
+ }
+
+ .ypg-method-tab:hover {
+ color: var(--ypg-navy);
+ }
+
+ .ypg-method-tab.active {
+ background: #ffffff;
+ color: var(--ypg-blue);
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
+ }
+
+ .ypg-tab-icon {
+ height: 14px;
+ width: auto;
+ object-fit: contain;
+ display: inline-block;
+ vertical-align: middle;
+ flex-shrink: 0;
+ }
+
+ .ypg-tab-icon-svg {
+ width: 14px;
+ height: 14px;
+ display: inline-block;
+ vertical-align: middle;
+ flex-shrink: 0;
+ }
+
+ .ypg-card-logos-combo {
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ vertical-align: middle;
+ flex-shrink: 0;
+ }
+
+ .ypg-card-logos-combo img {
+ height: 13px;
+ width: auto;
+ object-fit: contain;
+ display: inline-block;
+ }
+
+ /* --- 5. PRE-GATEWAY AUTH VIEW --- */
+ .ypg-auth-box {
+ background: #ffffff;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ margin-top: 4px;
+ }
+
+ .ypg-auth-sub-desc {
+ font-size: 12.5px;
+ color: var(--ypg-text-muted);
+ margin-bottom: 8px;
+ }
+
+ .ypg-auth-tab-row {
+ display: flex;
+ background: #f1f5f9;
+ border-radius: 8px;
+ padding: 3px;
+ }
+
+ .ypg-auth-tab-btn {
+ flex: 1;
+ padding: 8px 12px;
+ font-size: 12.5px;
+ font-weight: 700;
+ border: none;
+ border-radius: 6px;
+ background: transparent;
+ color: var(--ypg-text-muted);
+ cursor: pointer;
+ transition: all 0.15s;
+ }
+
+ .ypg-auth-tab-btn.active {
+ background: #ffffff;
+ color: var(--ypg-navy);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
+ }
+
+ .ypg-input-group {
+ margin-bottom: 12px;
+ }
+
+ .ypg-input-label {
+ display: block;
+ font-size: 11px;
+ font-weight: 700;
+ color: var(--ypg-text-dark);
+ margin-bottom: 4px;
+ text-transform: uppercase;
+ letter-spacing: 0.3px;
+ }
+
+ .ypg-input-control {
+ width: 100%;
+ padding: 10px 12px;
+ border: 1px solid #cbd5e1;
+ border-radius: 8px;
+ font-size: 13.5px;
+ color: var(--ypg-text-dark);
+ outline: none;
+ transition: border-color 0.15s;
+ }
+
+ .ypg-input-control:focus {
+ border-color: var(--ypg-blue);
+ box-shadow: 0 0 0 3px rgba(11, 99, 229, 0.15);
+ }
+
+ .ypg-btn-auth-action {
+ width: 100%;
+ padding: 12px;
+ background: var(--ypg-navy);
+ color: #ffffff;
+ border: none;
+ border-radius: 8px;
+ font-size: 13.5px;
+ font-weight: 700;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ transition: background 0.15s;
+ }
+
+ .ypg-btn-auth-action:hover {
+ background: #1e293b;
+ }
+
+ .ypg-btn-auth-action:disabled {
+ opacity: 0.65;
+ cursor: not-allowed;
+ }
+
+ .ypg-phone-input-wrap {
+ display: flex;
+ align-items: center;
+ border: 1px solid #cbd5e1;
+ border-radius: 8px;
+ overflow: hidden;
+ background: #ffffff;
+ transition: border-color 0.15s, box-shadow 0.15s;
+ }
+
+ .ypg-phone-input-wrap:focus-within {
+ border-color: var(--ypg-blue);
+ box-shadow: 0 0 0 3px rgba(11, 99, 229, 0.15);
+ }
+
+ .ypg-phone-prefix {
+ padding: 10px 12px;
+ background: #f8fafc;
+ border-right: 1px solid #e2e8f0;
+ font-size: 13.5px;
+ font-weight: 700;
+ color: var(--ypg-navy);
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ user-select: none;
+ }
+
+ .ypg-phone-control {
+ border: none !important;
+ box-shadow: none !important;
+ padding: 10px 12px;
+ font-size: 14.5px;
+ font-weight: 600;
+ letter-spacing: 0.5px;
+ flex: 1;
+ }
+
+ .ypg-auth-badge-banner {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ background: #f0fdf4;
+ border: 1px solid #bbf7d0;
+ border-radius: 8px;
+ padding: 10px 12px;
+ margin-bottom: 12px;
+ font-size: 12.5px;
+ color: #166534;
+ }
+
+ .ypg-btn-link {
+ background: none;
+ border: none;
+ color: var(--ypg-blue);
+ font-weight: 700;
+ cursor: pointer;
+ font-size: 12px;
+ padding: 0;
+ text-decoration: underline;
+ }
+
+ .ypg-otp-control {
+ text-align: center;
+ font-size: 24px !important;
+ font-weight: 800 !important;
+ letter-spacing: 12px !important;
+ font-family: monospace;
+ padding: 12px !important;
+ }
+
+ .ypg-autootp-status-box {
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
+ border-radius: 8px;
+ }
+
+ @keyframes ypg-pulse {
+ 0%, 100% { opacity: 1; transform: scale(1); }
+ 50% { opacity: 0.55; transform: scale(1.12); }
+ }
+
+ .ypg-pulse {
+ animation: ypg-pulse 1.8s infinite ease-in-out;
+ }
+
+ /* Saved Accounts Carousel */
+ .ypg-saved-accs-wrapper {
+ background: #f8fafc;
+ border: 1px solid var(--ypg-border);
+ border-radius: 10px;
+ padding: 12px;
+ }
+
+ .saved-account-row {
+ background: #ffffff;
+ border: 1px solid var(--ypg-border);
+ border-radius: 8px;
+ padding: 10px 12px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 8px;
+ cursor: pointer;
+ transition: all 0.15s;
+ }
+
+ .saved-account-row:hover {
+ border-color: var(--ypg-blue);
+ box-shadow: 0 2px 8px rgba(11, 99, 229, 0.12);
+ }
+
+ /* --- 6. QUEUE SYSTEM VIEW --- */
+ .ypg-queue-container {
+ background: #eff6ff;
+ border: 1px solid #bfdbfe;
+ border-radius: 14px;
+ padding: 28px 18px;
+ text-align: center;
+ margin: auto 0;
+ }
+
+ .ypg-queue-number {
+ font-size: 36px;
+ font-weight: 900;
+ color: #1d4ed8;
+ margin: 8px 0;
+ }
+
+ /* --- 7. PROCESSING / VERIFYING VIEW --- */
+ .ypg-processing-box {
+ text-align: center;
+ padding: 40px 18px;
+ margin: auto 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+
+ .ypg-double-spinner-box {
+ position: relative;
+ width: 72px;
+ height: 72px;
+ margin-bottom: 20px;
+ }
+
+ .ypg-spin-ring-outer {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ border: 4px solid rgba(11, 99, 229, 0.15);
+ border-radius: 50%;
+ }
+
+ .ypg-spin-ring-inner {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ border: 4px solid transparent;
+ border-top-color: var(--ypg-blue);
+ border-radius: 50%;
+ animation: ypgRotateRing 0.85s linear infinite;
+ }
+
+ @keyframes ypgRotateRing {
+ 0% {
+ transform: rotate(0deg);
+ }
+
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+
+ .ypg-spin-center-icon {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ width: 28px;
+ height: 28px;
+ color: var(--ypg-blue);
+ animation: ypgPulseCenter 1.5s ease-in-out infinite;
+ }
+
+ @keyframes ypgPulseCenter {
+
+ 0%,
+ 100% {
+ transform: translate(-50%, -50%) scale(0.9);
+ }
+
+ 50% {
+ transform: translate(-50%, -50%) scale(1.1);
+ }
+ }
+
+ .ypg-processing-title {
+ font-size: 16px;
+ font-weight: 700;
+ color: var(--ypg-text-dark);
+ margin-bottom: 6px;
+ }
+
+ .ypg-processing-sub {
+ font-size: 12px;
+ color: var(--ypg-text-muted);
+ line-height: 1.5;
+ max-width: 290px;
+ margin-bottom: 14px;
+ }
+
+ .ypg-proc-timer-badge {
+ background: #f1f5f9;
+ border: 1px solid #e2e8f0;
+ border-radius: 9999px;
+ padding: 3px 12px;
+ font-size: 12px;
+ font-weight: 700;
+ color: #334155;
+ }
+
+ /* --- 8. SUCCESS CELEBRATION VIEW --- */
+ .ypg-success-box {
+ text-align: center;
+ padding: 36px 18px;
+ margin: auto 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+
+ .ypg-success-circle {
+ width: 76px;
+ height: 76px;
+ border-radius: 50%;
+ background: #10b981;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
+ margin-bottom: 18px;
+ animation: ypgSpringPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
+ }
+
+ @keyframes ypgSpringPop {
+ 0% {
+ transform: scale(0);
+ opacity: 0;
+ }
+
+ 70% {
+ transform: scale(1.15);
+ }
+
+ 100% {
+ transform: scale(1);
+ opacity: 1;
+ }
+ }
+
+ .ypg-check-svg {
+ width: 42px;
+ height: 42px;
+ stroke: #ffffff;
+ stroke-width: 3.5;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+ fill: none;
+ }
+
+ .ypg-check-path {
+ stroke-dasharray: 40;
+ stroke-dashoffset: 40;
+ animation: ypgDrawCheck 0.45s 0.25s forwards ease-in-out;
+ }
+
+ @keyframes ypgDrawCheck {
+ to {
+ stroke-dashoffset: 0;
+ }
+ }
+
+ .ypg-success-title {
+ font-size: 19px;
+ font-weight: 800;
+ color: #0f172a;
+ margin-bottom: 4px;
+ }
+
+ .ypg-success-amount {
+ font-size: 24px;
+ font-weight: 900;
+ color: #10b981;
+ margin-bottom: 8px;
+ }
+
+ .btn-return-merchant {
+ background: var(--ypg-navy);
+ color: #ffffff;
+ text-decoration: none;
+ font-size: 13.5px;
+ font-weight: 700;
+ padding: 12px 26px;
+ border-radius: 8px;
+ margin-top: 14px;
+ display: inline-block;
+ }
+
+ /* --- 9. DEDICATED PAYMENT EXPIRED / FAILED VIEW (FIXED & CENTERED) --- */
+ .ypg-expired-box {
+ text-align: center;
+ padding: 32px 18px;
+ margin: auto 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: #ffffff;
+ border-radius: 16px;
+ border: 1px solid var(--ypg-border);
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
+ }
+
+ .ypg-expired-icon-wrap {
+ width: 68px;
+ height: 68px;
+ border-radius: 50%;
+ background: #fee2e2;
+ color: #ef4444;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-bottom: 16px;
+ box-shadow: 0 8px 16px rgba(239, 68, 68, 0.15);
+ }
+
+ .ypg-expired-icon-wrap svg {
+ width: 34px;
+ height: 34px;
+ }
+
+ .ypg-expired-title {
+ font-size: 19px;
+ font-weight: 800;
+ color: #0f172a;
+ margin-bottom: 6px;
+ }
+
+ .ypg-expired-desc {
+ font-size: 12.5px;
+ color: var(--ypg-text-muted);
+ max-width: 310px;
+ margin: 0 auto 20px auto;
+ line-height: 1.5;
+ }
+
+ .ypg-expired-actions {
+ display: flex;
+ gap: 10px;
+ justify-content: center;
+ width: 100%;
+ max-width: 300px;
+ }
+
+ .ypg-btn-expired-primary {
+ flex: 1;
+ padding: 12px;
+ background: var(--ypg-navy);
+ color: #ffffff;
+ border: none;
+ border-radius: 8px;
+ font-size: 13.5px;
+ font-weight: 700;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+
+ .ypg-btn-expired-primary:hover {
+ background: #1e293b;
+ }
+
+ .ypg-btn-expired-secondary {
+ padding: 12px 16px;
+ background: #f1f5f9;
+ color: #475569;
+ border: 1px solid #cbd5e1;
+ border-radius: 8px;
+ font-size: 13.5px;
+ font-weight: 700;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+
+ .ypg-btn-expired-secondary:hover {
+ background: #e2e8f0;
+ }
+
+ /* --- 10. DEDICATED FRAUD / SECURITY ALERT & ACCESS BLOCKED VIEW --- */
+ .ypg-blocked-box {
+ text-align: center;
+ padding: 32px 20px;
+ margin: auto 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: #ffffff;
+ border-radius: 16px;
+ border: 1.5px solid #fecaca;
+ box-shadow: 0 10px 30px rgba(220, 38, 38, 0.08);
+ position: relative;
+ overflow: hidden;
+ }
+ .ypg-blocked-box::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ height: 4px;
+ background: linear-gradient(90deg, #dc2626, #b91c1c, #991b1b);
+ }
+ .ypg-blocked-icon-wrap {
+ width: 72px;
+ height: 72px;
+ border-radius: 50%;
+ background: #fef2f2;
+ border: 2px solid #fee2e2;
+ color: #dc2626;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-bottom: 16px;
+ box-shadow: 0 8px 24px rgba(220, 38, 38, 0.16);
+ animation: ypgPulseAlert 2s infinite ease-in-out;
+ }
+ @keyframes ypgPulseAlert {
+ 0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(220, 38, 38, 0.16); }
+ 50% { transform: scale(1.05); box-shadow: 0 12px 30px rgba(220, 38, 38, 0.28); }
+ }
+ .ypg-blocked-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ background: #fef2f2;
+ color: #b91c1c;
+ border: 1px solid #fca5a5;
+ font-size: 11px;
+ font-weight: 800;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ padding: 4px 10px;
+ border-radius: 20px;
+ margin-bottom: 10px;
+ }
+ .ypg-blocked-badge-dot {
+ width: 7px;
+ height: 7px;
+ border-radius: 50%;
+ background: #dc2626;
+ box-shadow: 0 0 6px #dc2626;
+ animation: rzpHaloPulse 1.2s infinite;
+ }
+ .ypg-blocked-title {
+ font-size: 20px;
+ font-weight: 800;
+ color: #991b1b;
+ margin-bottom: 6px;
+ letter-spacing: -0.01em;
+ }
+ .ypg-blocked-subtitle {
+ font-size: 13px;
+ font-weight: 600;
+ color: #475569;
+ margin-bottom: 14px;
+ }
+ .ypg-blocked-card {
+ background: #f8fafc;
+ border: 1px solid #e2e8f0;
+ border-radius: 12px;
+ padding: 14px 16px;
+ margin-bottom: 18px;
+ width: 100%;
+ max-width: 340px;
+ text-align: left;
+ }
+ .ypg-blocked-desc {
+ font-size: 12px;
+ color: #334155;
+ line-height: 1.55;
+ margin: 0;
+ }
+ .ypg-blocked-investigation {
+ margin-top: 10px;
+ padding-top: 10px;
+ border-top: 1px dashed #cbd5e1;
+ display: flex;
+ align-items: flex-start;
+ gap: 8px;
+ font-size: 11.5px;
+ color: #64748b;
+ line-height: 1.45;
+ }
+ .ypg-blocked-details {
+ background: #0f172a;
+ border-radius: 8px;
+ padding: 10px 14px;
+ margin-bottom: 18px;
+ width: 100%;
+ max-width: 340px;
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 4px 10px;
+ font-size: 11px;
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
+ }
+ .ypg-blocked-details-label {
+ color: #94a3b8;
+ }
+ .ypg-blocked-details-val {
+ color: #f8fafc;
+ text-align: right;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .ypg-btn-blocked-exit {
+ background: #0f172a;
+ color: #ffffff;
+ border: none;
+ padding: 11px 20px;
+ border-radius: 10px;
+ font-weight: 700;
+ font-size: 13px;
+ cursor: pointer;
+ width: 100%;
+ max-width: 340px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ transition: all 0.2s;
+ }
+ .ypg-btn-blocked-exit:hover {
+ background: #1e293b;
+ }
+
+ /* --- 10b. DEDICATED DUPLICATE SESSION DETECTED VIEW (DEVICE BINDING SECURITY) --- */
+ .ypg-duplicate-box {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ text-align: center;
+ padding: 24px 20px;
+ animation: rzpFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
+ width: 100%;
+ box-sizing: border-box;
+ position: relative;
+ }
+ .ypg-duplicate-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ background: #fef3c7;
+ color: #92400e;
+ border: 1px solid #fde68a;
+ padding: 4px 12px;
+ border-radius: 20px;
+ font-size: 11px;
+ font-weight: 700;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ margin-bottom: 16px;
+ }
+ .ypg-duplicate-badge-dot {
+ width: 7px;
+ height: 7px;
+ border-radius: 50%;
+ background: #d97706;
+ box-shadow: 0 0 6px #d97706;
+ animation: rzpHaloPulse 1.2s infinite;
+ }
+ .ypg-duplicate-icon-wrap {
+ width: 64px;
+ height: 64px;
+ border-radius: 50%;
+ background: radial-gradient(circle, #fef3c7 0%, #fffbeb 100%);
+ border: 2px solid #fcd34d;
+ color: #b45309;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-bottom: 14px;
+ box-shadow: 0 4px 16px rgba(217, 119, 6, 0.15);
+ }
+ .ypg-duplicate-title {
+ font-size: 20px;
+ font-weight: 800;
+ color: #1e293b;
+ margin-bottom: 6px;
+ letter-spacing: -0.01em;
+ }
+ .ypg-duplicate-subtitle {
+ font-size: 13px;
+ font-weight: 600;
+ color: #64748b;
+ margin-bottom: 16px;
+ }
+ .ypg-duplicate-card {
+ background: #fffbeb;
+ border: 1px solid #fef08a;
+ border-radius: 12px;
+ padding: 16px 18px;
+ margin-bottom: 22px;
+ width: 100%;
+ max-width: 360px;
+ text-align: center;
+ }
+ .ypg-duplicate-desc {
+ font-size: 13px;
+ color: #1e293b;
+ line-height: 1.55;
+ margin: 0;
+ font-weight: 500;
+ }
+ .ypg-btn-duplicate-action {
+ background: #0f172a;
+ color: #ffffff;
+ border: none;
+ padding: 13px 20px;
+ border-radius: 10px;
+ font-weight: 700;
+ font-size: 13px;
+ cursor: pointer;
+ width: 100%;
+ box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
+ transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ letter-spacing: 0.02em;
+ }
+ .ypg-btn-duplicate-action:hover {
+ background: #1e293b;
+ transform: translateY(-1px);
+ box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
+ }
+ .ypg-btn-duplicate-action:active {
+ transform: translateY(0);
+ }
+
+ /* --- 11. AUTHENTIC STICKY BOTTOM FOOTER --- */
+ .ypg-sticky-footer {
+ background: #ffffff;
+ border-top: 1px solid #f1f5f9;
+ display: flex;
+ flex-direction: column;
+ flex-shrink: 0;
+ position: relative;
+ z-index: 20;
+ }
+
+ /* Legal Disclaimer */
+ .ypg-legal-disclaimer {
+ font-size: 11px;
+ color: #64748b;
+ text-align: center;
+ padding: 4px 16px;
+ line-height: 1.35;
+ }
+
+ /* Bottom Action Row (₹5,500 View Details | Continue Button) */
+ .ypg-action-bottom-bar {
+ padding: 10px 16px 14px 16px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ }
+
+ .ypg-amount-view-group {
+ display: flex;
+ flex-direction: column;
+ }
+
+ .ypg-bottom-price {
+ font-size: 18px;
+ font-weight: 800;
+ color: #0f172a;
+ letter-spacing: -0.01em;
+ line-height: 1.2;
+ }
+
+ .ypg-btn-view-details {
+ background: none;
+ border: none;
+ font-size: 11px;
+ font-weight: 600;
+ color: #64748b;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ padding: 0;
+ margin-top: 2px;
+ }
+
+ .ypg-btn-view-details:hover {
+ color: var(--ypg-blue);
+ }
+
+ .ypg-btn-continue {
+ background: var(--ypg-navy);
+ color: #ffffff;
+ border: none;
+ border-radius: 8px;
+ padding: 12px 34px;
+ font-size: 14.5px;
+ font-weight: 700;
+ cursor: pointer;
+ transition: background 0.15s, transform 0.1s;
+ }
+
+ .ypg-btn-continue:hover {
+ background: #1e293b;
+ }
+
+ .ypg-btn-continue:active {
+ transform: scale(0.98);
+ }
+
+ /* --- ORDER BREAKDOWN POPUP DRAWER --- */
+ .ypg-details-drawer {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ background: #ffffff;
+ border-top-left-radius: 16px;
+ border-top-right-radius: 16px;
+ box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.15);
+ border-top: 1px solid var(--ypg-border);
+ padding: 16px 18px;
+ z-index: 30;
+ transform: translateY(100%);
+ transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
+ }
+
+ .ypg-details-drawer.open {
+ transform: translateY(0);
+ }
+
+ .ypg-details-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 12px;
+ font-size: 14px;
+ font-weight: 700;
+ }
+
+ .ypg-details-row {
+ display: flex;
+ justify-content: space-between;
+ font-size: 12.5px;
+ color: #475569;
+ margin-bottom: 6px;
+ }
+
+ .ypg-details-row.total {
+ border-top: 1px dashed var(--ypg-border);
+ padding-top: 8px;
+ font-size: 14px;
+ font-weight: 800;
+ color: #0f172a;
+ }
+
+ /* Toast Notification */
+ .ypg-toast {
+ position: absolute;
+ top: 16px;
+ left: 50%;
+ transform: translateX(-50%) translateY(-20px);
+ background: #1e293b;
+ color: #ffffff;
+ padding: 8px 16px;
+ border-radius: 9999px;
+ font-size: 12px;
+ font-weight: 600;
+ opacity: 0;
+ pointer-events: none;
+ transition: all 0.25s ease-out;
+ z-index: 1000;
+ white-space: nowrap;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
+ }
+
+ .ypg-toast.show {
+ transform: translateX(-50%) translateY(0);
+ opacity: 1;
+ }
+
+ /* Help Modal Overlay */
+ .ypg-dialog-overlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: rgba(15, 23, 42, 0.6);
+ backdrop-filter: blur(4px);
+ z-index: 200;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 16px;
+ }
+
+ .ypg-dialog-overlay[hidden] {
+ display: none !important;
+ }
+
+ .ypg-dialog-card {
+ background: #ffffff;
+ border-radius: 12px;
+ width: 100%;
+ max-width: 360px;
+ padding: 18px;
+ }
+
+ /* --- AUTHENTIC RAZORPAY 3D RUNNING COIN & MODAL SHEETS --- */
+ .rzp-coin-stage {
+ position: relative;
+ width: 84px;
+ height: 84px;
+ margin: 8px auto;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ perspective: 600px;
+ }
+
+ .rzp-halo-ring {
+ position: absolute;
+ width: 76px;
+ height: 76px;
+ border-radius: 50%;
+ border: 2px solid rgba(254, 240, 138, 0.45);
+ box-shadow: 0 0 16px rgba(250, 204, 21, 0.28), inset 0 0 10px rgba(250, 204, 21, 0.18);
+ animation: rzpHaloPulse 2.2s ease-in-out infinite;
+ }
+
+ @keyframes rzpHaloPulse {
+
+ 0%,
+ 100% {
+ transform: scale(0.95);
+ opacity: 0.55;
+ }
+
+ 50% {
+ transform: scale(1.05);
+ opacity: 0.95;
+ }
+ }
+
+ .rzp-3d-coin {
+ width: 54px;
+ height: 54px;
+ position: relative;
+ transform-style: preserve-3d;
+ animation: rzpCoinSpin 1.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
+ }
+
+ @keyframes rzpCoinSpin {
+ 0% {
+ transform: rotateY(0deg);
+ }
+
+ 50% {
+ transform: rotateY(180deg);
+ }
+
+ 100% {
+ transform: rotateY(360deg);
+ }
+ }
+
+ .rzp-coin-face {
+ position: absolute;
+ inset: 0;
+ border-radius: 50%;
+ backface-visibility: hidden;
+ background: radial-gradient(circle at 35% 35%, #fff9c4 0%, #fbc02d 42%, #f57f17 82%, #d97706 100%);
+ border: 3.5px solid #fff59d;
+ box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3), inset 0 1.5px 3px rgba(255, 255, 255, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .rzp-coin-back {
+ transform: rotateY(180deg);
+ }
+
+ .rzp-coin-inner-rim {
+ width: 38px;
+ height: 38px;
+ border-radius: 50%;
+ background: radial-gradient(circle at 38% 38%, #ffd54f 0%, #fbc02d 55%, #f57f17 100%);
+ box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
+ position: relative;
+ overflow: hidden;
+ }
+
+ .rzp-coin-sheen {
+ position: absolute;
+ inset: 0;
+ border-radius: 50%;
+ background: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 50%);
+ pointer-events: none;
+ }
+
+ /* Compact Coin for Inline Waiting Card */
+ .rzp-coin-stage-inline {
+ position: relative;
+ width: 54px;
+ height: 54px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ perspective: 500px;
+ }
+
+ .rzp-coin-stage-inline .rzp-halo-ring {
+ width: 50px;
+ height: 50px;
+ border-width: 1.5px;
+ }
+
+ .rzp-coin-stage-inline .rzp-3d-coin {
+ width: 36px;
+ height: 36px;
+ }
+
+ .rzp-coin-stage-inline .rzp-coin-face {
+ border-width: 2.5px;
+ }
+
+ .rzp-coin-stage-inline .rzp-coin-inner-rim {
+ width: 24px;
+ height: 24px;
+ }
+
+ /* Inline Waiting Card (on UPI QR page) */
+ .rzp-inline-waiting-card {
+ margin: 14px 0;
+ padding: 14px 16px;
+ background: #ffffff;
+ border: 1.5px solid #fde047;
+ border-radius: 14px;
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ box-shadow: 0 4px 14px rgba(234, 179, 8, 0.15);
+ position: relative;
+ overflow: hidden;
+ text-align: left;
+ }
+
+ .rzp-inline-waiting-card::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ height: 3px;
+ background: linear-gradient(90deg, #f59e0b, #eab308, #f59e0b);
+ background-size: 200% 100%;
+ animation: rzpGlowBar 2s linear infinite;
+ }
+
+ @keyframes rzpGlowBar {
+ 0% {
+ background-position: 0% 50%;
+ }
+
+ 100% {
+ background-position: 200% 50%;
+ }
+ }
+
+ /* Full-Screen Bottom Sheet / Dialog Modals */
+ .rzp-sheet-backdrop {
+ position: fixed;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ height: 100dvh;
+ background: rgba(15, 23, 42, 0.65);
+ backdrop-filter: blur(5px);
+ -webkit-backdrop-filter: blur(5px);
+ z-index: 99999;
+ display: flex;
+ align-items: flex-end;
+ justify-content: center;
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity 0.25s ease-out;
+ overflow: hidden;
+ }
+
+ @media (min-width: 601px) {
+ .rzp-sheet-backdrop {
+ align-items: center;
+ }
+ }
+
+ .rzp-sheet-backdrop.active {
+ opacity: 1;
+ pointer-events: auto;
+ }
+
+ .rzp-sheet-dialog {
+ width: 100%;
+ max-width: 440px;
+ max-height: 88dvh;
+ max-height: 88vh;
+ background: #ffffff;
+ border-top-left-radius: 20px;
+ border-top-right-radius: 20px;
+ box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
+ overflow-y: auto !important;
+ -webkit-overflow-scrolling: touch !important;
+ overscroll-behavior-y: contain !important;
+ transform: translateY(100%);
+ transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ }
+
+ @media (min-width: 601px) {
+ .rzp-sheet-dialog {
+ border-radius: 20px;
+ max-height: 85vh;
+ transform: translateY(20px) scale(0.98);
+ }
+
+ .rzp-sheet-backdrop.active .rzp-sheet-dialog {
+ transform: translateY(0) scale(1);
+ }
+ }
+
+ .rzp-sheet-backdrop.active .rzp-sheet-dialog {
+ transform: translateY(0);
+ }
+
+ .rzp-sheet-content {
+ padding: 16px 20px 20px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ text-align: center;
+ width: 100%;
+ box-sizing: border-box;
+ }
+
+ .rzp-sheet-title {
+ font-size: 19px;
+ font-weight: 800;
+ color: #0f172a;
+ letter-spacing: -0.3px;
+ margin-bottom: 4px;
+ }
+
+ .rzp-sheet-subtitle {
+ font-size: 13px;
+ color: #64748b;
+ margin-bottom: 6px;
+ line-height: 1.4;
+ }
+
+ .rzp-sheet-cancel-btn {
+ width: 100%;
+ height: 42px;
+ background: #ffffff;
+ border: 1.5px solid #e2e8f0;
+ border-radius: 10px;
+ font-size: 14px;
+ font-weight: 700;
+ color: #0b63e5;
+ cursor: pointer;
+ margin-top: 14px;
+ transition: all 0.2s;
+ }
+
+ .rzp-sheet-cancel-btn:hover {
+ background: #f8fafc;
+ border-color: #cbd5e1;
+ }
+
+ /* Cancel Modal Header Arc with Doors */
+ .rzp-cancel-header-arc {
+ width: 120%;
+ height: 80px;
+ background: #dbeafe;
+ border-bottom-left-radius: 50% 28px;
+ border-bottom-right-radius: 50% 28px;
+ display: flex;
+ align-items: flex-end;
+ justify-content: center;
+ padding-bottom: 6px;
+ position: relative;
+ margin-left: -10%;
+ margin-right: -10%;
+ }
+
+ .rzp-btn-sheet-close {
+ position: absolute;
+ top: 12px;
+ right: calc(10% + 12px);
+ width: 30px;
+ height: 30px;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.7);
+ border: none;
+ color: #334155;
+ font-size: 15px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+
+ .rzp-btn-sheet-close:hover {
+ background: rgba(255, 255, 255, 0.95);
+ }
+
+ .rzp-btn-wait {
+ width: 100%;
+ height: 42px;
+ background: #ffffff;
+ border: 1.5px solid #e2e8f0;
+ border-radius: 10px;
+ font-size: 14px;
+ font-weight: 700;
+ color: #0f172a;
+ cursor: pointer;
+ margin-top: 14px;
+ transition: all 0.2s;
+ }
+
+ .rzp-btn-wait:hover {
+ background: #f8fafc;
+ }
+
+ .rzp-btn-confirm-cancel {
+ width: 100%;
+ height: 42px;
+ background: #0f172a;
+ border: none;
+ border-radius: 10px;
+ font-size: 14px;
+ font-weight: 700;
+ color: #ffffff;
+ cursor: pointer;
+ margin-top: 8px;
+ transition: all 0.2s;
+ }
+
+ .rzp-btn-confirm-cancel:hover {
+ background: #1e293b;
+ }
+
+ .rzp-secured-by {
+ font-size: 12px;
+ color: #64748b;
+ margin-top: 22px;
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ }
+
+ /* --- PSYCHOLOGICAL TIME-SAVING CONVERSION BANNER --- */
+ .ypg-time-saving-banner {
+ background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
+ border: 1px solid #86efac;
+ border-radius: 10px;
+ padding: 10px 14px;
+ margin-bottom: 14px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
+ }
+
+ .ypg-time-saving-text {
+ font-size: 12px;
+ font-weight: 700;
+ color: #14532d;
+ line-height: 1.4;
+ flex: 1;
+ }
+
+ .ypg-banner-running-timer {
+ font-family: monospace;
+ font-size: 13px;
+ font-weight: 800;
+ color: #15803d;
+ background: rgba(255, 255, 255, 0.85);
+ padding: 1px 6px;
+ border-radius: 4px;
+ border: 1px solid #bbf7d0;
+ display: inline-block;
+ letter-spacing: 0.5px;
+ }
+
+ .ypg-btn-fast-switch {
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
+ color: #ffffff;
+ border: none;
+ border-radius: 8px;
+ padding: 8px 12px;
+ font-size: 11.5px;
+ font-weight: 700;
+ cursor: pointer;
+ white-space: nowrap;
+ flex-shrink: 0;
+ box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
+ transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ }
+
+ .ypg-btn-fast-switch:hover {
+ background: linear-gradient(135deg, #059669 0%, #047857 100%);
+ transform: translateY(-1px);
+ box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35);
+ }
+
+ /* Dedicated Psychological Conversion Card in UPI Queue View */
+ .ypg-queue-conversion-card {
+ background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
+ border: 1px solid #86efac;
+ border-radius: 12px;
+ padding: 14px 16px;
+ margin-bottom: 14px;
+ box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
+ text-align: left;
+ }
+
+ .ypg-queue-conversion-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ margin-bottom: 8px;
+ }
+
+ .ypg-queue-conversion-badge {
+ font-size: 11.5px;
+ font-weight: 800;
+ color: #065f46;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ }
+
+ .ypg-queue-conversion-pill {
+ font-size: 11.5px;
+ font-weight: 700;
+ color: #15803d;
+ background: rgba(255, 255, 255, 0.9);
+ padding: 2px 8px;
+ border-radius: 12px;
+ border: 1px solid #bbf7d0;
+ white-space: nowrap;
+ }
+
+ .ypg-queue-conversion-text {
+ font-size: 12.5px;
+ line-height: 1.45;
+ color: #14532d;
+ margin-bottom: 12px;
+ }
+
+ .ypg-btn-queue-switch {
+ width: 100%;
+ height: 42px;
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
+ color: #ffffff;
+ border: none;
+ border-radius: 9px;
+ font-size: 13px;
+ font-weight: 700;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
+ transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
+ }
+
+ .ypg-btn-queue-switch:hover {
+ background: linear-gradient(135deg, #059669 0%, #047857 100%);
+ transform: translateY(-1px);
+ box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
+ }
+
+ /* --- DESKTOP / PC SPECIFIC 2-COLUMN RAZORPAY REDESIGN --- */
+ @media (min-width: 768px) {
+ body {
+ padding: 0;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #0b0f19;
+ }
+
+ body:not(.is-embedded) {
+ padding: 20px;
+ }
+
+ .ypg-wrapper {
+ width: 900px !important;
+ max-width: 95vw !important;
+ height: 600px !important;
+ max-height: 92vh !important;
+ border-radius: 16px !important;
+ display: flex !important;
+ flex-direction: row !important;
+ box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5) !important;
+ overflow: hidden !important;
+ position: relative !important;
+ }
+
+ body.is-embedded .ypg-wrapper {
+ width: 100% !important;
+ max-width: 100% !important;
+ height: 100% !important;
+ min-height: 100% !important;
+ border-radius: 16px !important;
+ }
+
+ .ypg-header {
+ display: none !important;
+ }
+
+ .ypg-drag-handle-bar {
+ display: none !important;
+ }
+
+ .ypg-action-bottom-bar {
+ display: none !important;
+ }
+
+ .ypg-footer {
+ display: none !important;
+ }
+
+ /* PC Left Sidebar (Blue Branding Panel - ~310px width) */
+ .ypg-pc-sidebar {
+ width: 310px;
+ min-width: 310px;
+ max-width: 310px;
+ height: 100%;
+ background: linear-gradient(180deg, var(--ypg-blue, #0b63e5) 0%, var(--ypg-blue-dark, #0854c6) 100%);
+ padding: 22px 20px;
+ display: flex !important;
+ flex-direction: column;
+ justify-content: space-between;
+ color: #ffffff;
+ position: relative;
+ overflow: hidden;
+ box-sizing: border-box;
+ }
+
+ .ypg-pc-brand-header {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 12px;
+ }
+
+ .ypg-pc-avatar {
+ width: 42px;
+ height: 42px;
+ border-radius: 10px;
+ background: rgba(255, 255, 255, 0.22);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 20px;
+ font-weight: 800;
+ color: #ffffff;
+ overflow: hidden;
+ flex-shrink: 0;
+ }
+
+ .ypg-pc-avatar img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+
+ .ypg-pc-brand-info {
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ min-width: 0;
+ }
+
+ .ypg-pc-merchant-name {
+ font-size: 16px;
+ font-weight: 800;
+ color: #ffffff;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ line-height: 1.2;
+ }
+
+ .ypg-pc-trust-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ background: rgba(255, 255, 255, 0.16);
+ border-radius: 20px;
+ padding: 2px 8px;
+ font-size: 11px;
+ font-weight: 600;
+ color: #ffffff;
+ width: fit-content;
+ }
+
+ .ypg-pc-green-shield {
+ width: 13px;
+ height: 13px;
+ }
+
+ /* Social Proof Pill */
+ .ypg-pc-social-proof {
+ background: rgba(255, 255, 255, 0.12);
+ border-radius: 8px;
+ padding: 8px 12px;
+ margin-top: 6px;
+ font-size: 11.5px;
+ color: rgba(255, 255, 255, 0.95);
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ /* Price Summary White Card - NO UPI ID VISIBLE */
+ .ypg-pc-price-card {
+ background: #ffffff;
+ border-radius: 10px;
+ padding: 14px 16px;
+ margin-top: 14px;
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
+ color: #0f172a;
+ }
+
+ .ypg-pc-price-label {
+ font-size: 12px;
+ font-weight: 600;
+ color: #64748b;
+ letter-spacing: 0.2px;
+ }
+
+ .ypg-pc-price-val {
+ font-size: 26px;
+ font-weight: 800;
+ color: #0f172a;
+ margin-top: 4px;
+ letter-spacing: -0.5px;
+ }
+
+ /* User Profile Row Button */
+ .ypg-pc-row-btn {
+ background: rgba(255, 255, 255, 0.12);
+ border-radius: 8px;
+ padding: 10px 12px;
+ margin-top: 10px;
+ font-size: 12px;
+ color: #ffffff;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+
+ .ypg-pc-row-btn:hover {
+ background: rgba(255, 255, 255, 0.18);
+ }
+
+ .ypg-pc-row-left {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ overflow: hidden;
+ }
+
+ #pcCustomerProfileText {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ .ypg-pc-chevron {
+ font-size: 16px;
+ opacity: 0.75;
+ flex-shrink: 0;
+ }
+
+ /* Shopping Bags Graphic */
+ .ypg-pc-bags-wrap {
+ width: 100%;
+ display: flex;
+ justify-content: center;
+ margin-top: auto;
+ padding-top: 14px;
+ padding-bottom: 4px;
+ }
+
+ /* PC Right Column / Workspace */
+ .ypg-pc-workspace {
+ flex: 1;
+ height: 100%;
+ display: flex !important;
+ flex-direction: column;
+ background: #ffffff;
+ overflow: hidden;
+ min-width: 0;
+ }
+
+ .ypg-pc-topbar {
+ height: 48px;
+ border-bottom: 1px solid #f1f5f9;
+ display: flex !important;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 20px;
+ background: #ffffff;
+ flex-shrink: 0;
+ position: relative;
+ z-index: 60;
+ }
+
+ .ypg-pc-topbar-title {
+ font-size: 15px;
+ font-weight: 700;
+ color: #0f172a;
+ }
+
+ .ypg-pc-topbar-actions {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ position: relative;
+ z-index: 61;
+ }
+
+ .ypg-pc-btn-more,
+ .ypg-pc-btn-close {
+ background: none;
+ border: none;
+ font-size: 16px;
+ color: #64748b;
+ cursor: pointer;
+ padding: 4px 6px;
+ border-radius: 4px;
+ line-height: 1;
+ transition: color 0.15s, background 0.15s;
+ }
+
+ .ypg-pc-btn-close {
+ font-size: 18px;
+ font-weight: 600;
+ }
+
+ .ypg-pc-btn-more:hover,
+ .ypg-pc-btn-close:hover {
+ color: #0f172a;
+ background: #f1f5f9;
+ }
+
+ /* PC Body Container - Bounded to viewport height */
+ .ypg-body {
+ flex: 1 !important;
+ height: calc(100% - 48px) !important;
+ max-height: calc(100% - 48px) !important;
+ display: flex !important;
+ flex-direction: column !important;
+ padding: 0 !important;
+ overflow: hidden !important;
+ min-height: 0 !important;
+ }
+
+ #paymentGatewayInterface:not([hidden]) {
+ flex: 1 !important;
+ height: 100% !important;
+ max-height: 100% !important;
+ display: flex !important;
+ flex-direction: column !important;
+ min-height: 0 !important;
+ overflow: hidden !important;
+ }
+
+ #paymentGatewayInterface[hidden] {
+ display: none !important;
+ }
+
+ #preGatewayAuthView:not([hidden]) {
+ flex: 1 !important;
+ height: 100% !important;
+ max-height: 100% !important;
+ display: flex !important;
+ flex-direction: column !important;
+ overflow-y: auto !important;
+ padding: 24px 32px !important;
+ box-sizing: border-box !important;
+ }
+
+ #preGatewayAuthView[hidden] {
+ display: none !important;
+ }
+
+ /* Clean PC layout */
+ .ypg-pc-columns {
+ display: flex !important;
+ flex-direction: row !important;
+ flex: 1 !important;
+ height: 100% !important;
+ max-height: 100% !important;
+ min-height: 0 !important;
+ overflow: hidden !important;
+ }
+
+ .ypg-pc-methods-list {
+ width: 220px !important;
+ min-width: 220px !important;
+ height: 100% !important;
+ max-height: 100% !important;
+ border-right: 1px solid #f1f5f9 !important;
+ padding: 14px 12px !important;
+ display: flex !important;
+ flex-direction: column !important;
+ gap: 8px !important;
+ overflow-y: auto !important;
+ background: #ffffff !important;
+ scrollbar-width: thin !important;
+ scrollbar-color: #e2e8f0 transparent !important;
+ }
+
+ .ypg-pc-methods-list::-webkit-scrollbar {
+ width: 4px;
+ }
+
+ .ypg-pc-methods-list::-webkit-scrollbar-thumb {
+ background: #e2e8f0;
+ border-radius: 4px;
+ }
+
+ .ypg-pc-method-card {
+ border: 1.5px solid #e2e8f0;
+ border-radius: 10px;
+ padding: 10px 12px;
+ cursor: pointer;
+ transition: all 0.2s ease;
+ background: #ffffff;
+ }
+
+ .ypg-pc-method-card:hover {
+ border-color: #cbd5e1;
+ background: #f8fafc;
+ }
+
+ .ypg-pc-method-card.is-active {
+ border-color: var(--ypg-blue, #0b63e5);
+ background: #eff6ff;
+ box-shadow: 0 0 0 1px var(--ypg-blue, #0b63e5);
+ }
+
+ .ypg-pc-method-card.disabled {
+ opacity: 0.6;
+ cursor: default;
+ }
+
+ .ypg-pc-method-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 2px;
+ }
+
+ .ypg-pc-method-title {
+ font-size: 13px;
+ font-weight: 700;
+ color: #0f172a;
+ }
+
+ .ypg-pc-cash-pill {
+ font-size: 10px;
+ font-weight: 700;
+ color: #0369a1;
+ background: #e0f2fe;
+ padding: 2px 6px;
+ border-radius: 10px;
+ }
+
+ .ypg-pc-method-sub {
+ font-size: 11px;
+ color: #64748b;
+ }
+
+ .ypg-pc-method-icons {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ margin-top: 6px;
+ }
+
+ .ypg-pc-mini-icon {
+ width: 18px;
+ height: 18px;
+ border-radius: 4px;
+ object-fit: cover;
+ }
+
+ /* Right active workspace - Bounded height with buttery-smooth scrolling */
+ .ypg-pc-active-view {
+ flex: 1 !important;
+ height: 100% !important;
+ max-height: 100% !important;
+ padding: 16px 22px !important;
+ overflow-y: auto !important;
+ display: flex !important;
+ flex-direction: column !important;
+ min-width: 0 !important;
+ scrollbar-width: thin !important;
+ scrollbar-color: #cbd5e1 transparent !important;
+ }
+
+ .ypg-pc-active-view::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ .ypg-pc-active-view::-webkit-scrollbar-track {
+ background: transparent;
+ }
+
+ .ypg-pc-active-view::-webkit-scrollbar-thumb {
+ background: #cbd5e1;
+ border-radius: 4px;
+ }
+
+ .ypg-pc-active-view::-webkit-scrollbar-thumb:hover {
+ background: #94a3b8;
+ }
+
+ /* Desktop: Hide redundant step cards since QR details column has instructions */
+ .ypg-instructions-card {
+ display: none !important;
+ }
+
+ /* Desktop method selector override */
+ .ypg-method-selector-bar {
+ display: none !important;
+ }
+
+ /* PC Exit Modal Styling (Razorpay desktop modal) */
+ .mob-only-title,
+ .mob-only-sub,
+ .mob-only-btn {
+ display: none !important;
+ }
+
+ .pc-only-title,
+ .pc-only-sub,
+ .pc-only-btn {
+ display: inline !important;
+ }
+
+ .rzp-sheet-dialog {
+ width: 420px !important;
+ border-radius: 16px !important;
+ box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4) !important;
+ animation: rzpModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
+ }
+ }
+
+ /* MOBILE SPECIFIC RULES - PINNED HEADER WITH CONTENT SCROLLING BEHIND IT */
+ @media (max-width: 767px) {
+ .ypg-pc-sidebar {
+ display: none !important;
+ }
+
+ .ypg-pc-topbar {
+ display: none !important;
+ }
+
+ .ypg-wrapper {
+ height: 100% !important;
+ height: 100dvh !important;
+ min-height: 100% !important;
+ min-height: 100dvh !important;
+ max-height: 100% !important;
+ max-height: 100dvh !important;
+ display: flex !important;
+ flex-direction: column !important;
+ overflow: hidden !important;
+ width: 100vw !important;
+ max-width: 100vw !important;
+ border-radius: 0 !important;
+ }
+
+ .ypg-pc-workspace {
+ height: 100% !important;
+ max-height: 100% !important;
+ display: flex !important;
+ flex-direction: column !important;
+ overflow: hidden !important;
+ flex: 1 !important;
+ position: relative !important;
+ }
+
+ /* Pinned/Sticky Header: Store name sits firmly at top */
+ .ypg-header {
+ position: sticky !important;
+ top: 0 !important;
+ z-index: 50 !important;
+ flex-shrink: 0 !important;
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
+ }
+
+ /* Body is the single fluid scroll container that flows behind the header */
+ .ypg-body {
+ display: block !important;
+ flex: 1 !important;
+ height: auto !important;
+ min-height: 0 !important;
+ overflow-y: auto !important;
+ -webkit-overflow-scrolling: touch !important;
+ overscroll-behavior-y: contain !important;
+ padding: 14px 16px 140px 16px !important;
+ scrollbar-width: none !important;
+ }
+
+ .ypg-body::-webkit-scrollbar {
+ display: none !important;
+ }
+
+ /* Method tabs scroll smoothly under the header */
+ .ypg-method-selector-bar {
+ position: sticky !important;
+ top: -14px !important;
+ z-index: 30 !important;
+ background: #ffffff !important;
+ padding-top: 4px !important;
+ padding-bottom: 8px !important;
+ }
+
+ /* Inner wrappers must NOT have conflicting overflow or height */
+ #paymentGatewayInterface:not([hidden]) {
+ display: block !important;
+ height: auto !important;
+ max-height: none !important;
+ overflow: visible !important;
+ flex: none !important;
+ }
+
+ #paymentGatewayInterface[hidden] {
+ display: none !important;
+ }
+
+ #preGatewayAuthView:not([hidden]) {
+ display: block !important;
+ width: 100% !important;
+ padding: 16px 16px 24px !important;
+ box-sizing: border-box !important;
+ }
+
+ #preGatewayAuthView[hidden] {
+ display: none !important;
+ }
+
+ .ypg-pc-columns {
+ display: block !important;
+ height: auto !important;
+ max-height: none !important;
+ overflow: visible !important;
+ flex: none !important;
+ }
+
+ .ypg-pc-methods-list {
+ display: none !important;
+ }
+
+ .ypg-pc-active-view {
+ display: block !important;
+ height: auto !important;
+ max-height: none !important;
+ overflow: visible !important;
+ padding: 0 !important;
+ width: 100% !important;
+ flex: none !important;
+ }
+
+ /* Fixed Bottom Footer Bar */
+ .ypg-sticky-footer {
+ position: fixed !important;
+ bottom: 0 !important;
+ left: 0 !important;
+ right: 0 !important;
+ z-index: 45 !important;
+ background: #ffffff !important;
+ box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08) !important;
+ }
+
+ .pc-only-title,
+ .pc-only-sub,
+ .pc-only-btn {
+ display: none !important;
+ }
+
+ .mob-only-title,
+ .mob-only-sub,
+ .mob-only-btn {
+ display: inline !important;
+ }
+ }
+
+ /* --- OFFICIAL GOOGLE PLAY STORE APP ICONS --- */
+ .ypg-upi-logos-row {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ flex-wrap: wrap;
+ }
+
+ .ypg-app-icon {
+ width: 26px;
+ height: 26px;
+ border-radius: 6px;
+ overflow: hidden;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #ffffff;
+ border: 1px solid #e2e8f0;
+ flex-shrink: 0;
+ }
+
+ .ypg-app-icon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: 5px;
+ display: block;
+ }
+
+ /* --- UPI SERVER HEALTH INDICATOR & DOWNTIME ALERT --- */
+ .ypg-server-health-indicator {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 10px;
+ border-radius: 20px;
+ font-size: 11px;
+ font-weight: 700;
+ letter-spacing: 0.2px;
+ margin: 0 auto 10px auto;
+ transition: all 0.25s ease;
+ width: fit-content;
+ }
+
+ .ypg-server-health-indicator.is-working {
+ background: #f0fdf4;
+ color: #15803d;
+ border: 1px solid #bbf7d0;
+ }
+
+ .ypg-server-health-indicator.is-busy {
+ background: #fefce8;
+ color: #854d0e;
+ border: 1px solid #fef08a;
+ }
+
+ .ypg-server-health-indicator.is-issues {
+ background: #fef2f2;
+ color: #b91c1c;
+ border: 1px solid #fecaca;
+ }
+
+ .ypg-pulse-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ display: inline-block;
+ }
+
+ .ypg-server-health-indicator.is-working .ypg-pulse-dot {
+ background: #22c55e;
+ box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
+ animation: pulse-green 1.8s infinite;
+ }
+
+ .ypg-server-health-indicator.is-busy .ypg-pulse-dot {
+ background: #eab308;
+ box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
+ animation: pulse-yellow 1.8s infinite;
+ }
+
+ .ypg-server-health-indicator.is-issues .ypg-pulse-dot {
+ background: #ef4444;
+ box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
+ animation: pulse-red 1.8s infinite;
+ }
+
+ @keyframes pulse-yellow {
+ 0% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
+ }
+
+ 70% {
+ transform: scale(1);
+ box-shadow: 0 0 0 6px rgba(234, 179, 8, 0);
+ }
+
+ 100% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(234, 179, 8, 0);
+ }
+ }
+
+ @keyframes pulse-green {
+ 0% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
+ }
+
+ 70% {
+ transform: scale(1);
+ box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
+ }
+
+ 100% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
+ }
+ }
+
+ @keyframes pulse-red {
+ 0% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
+ }
+
+ 70% {
+ transform: scale(1);
+ box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
+ }
+
+ 100% {
+ transform: scale(0.95);
+ box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
+ }
+ }
+
+ .ypg-downtime-alert {
+ background: #fff5f5;
+ border: 1px solid #fed7d7;
+ border-left: 4px solid #e53e3e;
+ border-radius: 8px;
+ padding: 10px 14px;
+ margin: 10px 0;
+ display: flex;
+ gap: 10px;
+ align-items: flex-start;
+ text-align: left;
+ }
+
+ .ypg-downtime-alert.is-warning {
+ background: #fffbeb;
+ border: 1px solid #fef3c7;
+ border-left: 4px solid #f59e0b;
+ }
+
+ .ypg-downtime-alert.is-warning .ypg-downtime-heading {
+ color: #92400e;
+ }
+
+ .ypg-downtime-alert.is-warning .ypg-downtime-msg {
+ color: #78350f;
+ }
+
+ .ypg-downtime-icon {
+ font-size: 18px;
+ line-height: 1;
+ flex-shrink: 0;
+ }
+
+ .ypg-downtime-heading {
+ font-size: 12px;
+ font-weight: 800;
+ color: #991b1b;
+ margin-bottom: 3px;
+ }
+
+ .ypg-downtime-msg {
+ font-size: 11.5px;
+ color: #7f1d1d;
+ line-height: 1.4;
+ margin-bottom: 6px;
+ }
+
+ .ypg-btn-downtime-alt {
+ background: #0f172a;
+ color: #ffffff;
+ border: none;
+ border-radius: 6px;
+ font-size: 11px;
+ font-weight: 700;
+ padding: 6px 12px;
+ cursor: pointer;
+ transition: opacity 0.2s;
+ }
+
+ .ypg-btn-downtime-alt:hover {
+ opacity: 0.9;
+ }
\ No newline at end of file
diff --git a/apps/checkout-portal/public/js/checkout.js b/apps/checkout-portal/public/js/checkout.js
new file mode 100644
index 0000000..9231659
--- /dev/null
+++ b/apps/checkout-portal/public/js/checkout.js
@@ -0,0 +1,2720 @@
+
+ let state = null;
+ let countdownTimer = null;
+ let queuePollTimer = null;
+ let sse = null;
+ let activeCustomer = null;
+ let activeToken = null;
+
+ const STORAGE_KEY_IDENTITY = 'youpi.customer.identity';
+ const STORAGE_KEY_ACCOUNTS = 'youpi.customer.accounts';
+ const STORAGE_KEY_ACTIVE = 'youpi.customer.activeId';
+ const MAX_IDENTITY_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days (maximum 1 week)
+
+ function getPreservedIdentity() {
+ try {
+ const raw = localStorage.getItem(STORAGE_KEY_IDENTITY);
+ if (!raw) return null;
+ const data = JSON.parse(raw);
+ if (!data || !data.customer) {
+ clearPreservedIdentity();
+ return null;
+ }
+ const now = Date.now();
+ const expiry = data.expiresAt || ((data.savedAt || now) + MAX_IDENTITY_AGE_MS);
+ if (now > expiry) {
+ console.log('[Auth] Preserved identity expired (> 1 week). Purging.');
+ clearPreservedIdentity();
+ return null;
+ }
+ return data;
+ } catch {
+ return null;
+ }
+ }
+
+ function savePreservedIdentity(cust, token) {
+ if (!cust || !cust.id) return;
+ try {
+ const now = Date.now();
+ const cleanCust = {
+ id: cust.id,
+ name: cust.name || cust.fullName || 'Customer',
+ email: cust.email || '',
+ mobileNumber: cust.mobileNumber || cust.phoneNumber || '',
+ status: cust.status || 'ACTIVE'
+ };
+ const resolvedToken = token || activeToken || localStorage.getItem('ypg_customer_token') || null;
+ const payload = {
+ customer: cleanCust,
+ token: resolvedToken,
+ savedAt: now,
+ expiresAt: now + MAX_IDENTITY_AGE_MS
+ };
+ // 1. Preserve 1-week identity
+ localStorage.setItem(STORAGE_KEY_IDENTITY, JSON.stringify(payload));
+ // 2. Strict single-user saved account store
+ localStorage.setItem(STORAGE_KEY_ACCOUNTS, JSON.stringify([cleanCust]));
+ localStorage.setItem(STORAGE_KEY_ACTIVE, cust.id);
+ if (resolvedToken) {
+ localStorage.setItem('ypg_customer_token', resolvedToken);
+ }
+ } catch { }
+ }
+
+ function clearPreservedIdentity() {
+ try {
+ localStorage.removeItem(STORAGE_KEY_IDENTITY);
+ localStorage.removeItem(STORAGE_KEY_ACCOUNTS);
+ localStorage.removeItem(STORAGE_KEY_ACTIVE);
+ localStorage.removeItem('ypg_customer_token');
+ } catch { }
+ }
+
+ // Immediately restore 1-week preserved identity if present
+ const initPreserved = getPreservedIdentity();
+ if (initPreserved && initPreserved.customer) {
+ activeCustomer = initPreserved.customer;
+ activeToken = initPreserved.token || null;
+ }
+
+ // Notify parent if embedded in iframe
+ if (window.parent !== window || location.search.includes('embedded=1')) {
+ document.body.classList.add('is-embedded');
+ try {
+ window.parent.postMessage({ event: 'youpi.modal_ready', paymentId: PAYMENT_ID }, '*');
+ } catch (e) { }
+ }
+
+ // Dismiss Initial Splash Screen smoothly after brief intro
+ function dismissSplashScreen() {
+ const splash = document.getElementById('ypgSplashScreen');
+ if (splash && !splash.classList.contains('fade-out')) {
+ setTimeout(() => {
+ splash.classList.add('fade-out');
+ }, 550);
+ }
+ }
+
+ // Toast helper
+ let toastTimer = null;
+ function showOptionToast(msg) {
+ const toast = document.getElementById('ypgToast');
+ if (!toast) return;
+ toast.textContent = msg;
+ toast.classList.add('show');
+ if (toastTimer) clearTimeout(toastTimer);
+ toastTimer = setTimeout(() => {
+ toast.classList.remove('show');
+ }, 2500);
+ }
+
+ // Toggle Order Breakdown Drawer
+ function toggleOrderDetails() {
+ const drawer = document.getElementById('orderDetailsDrawer');
+ const chevron = document.getElementById('chevronDetailsIcon');
+ if (!drawer) return;
+ const isOpen = drawer.classList.contains('open');
+ if (isOpen) {
+ drawer.classList.remove('open');
+ if (chevron) chevron.innerHTML = '▴';
+ } else {
+ drawer.classList.add('open');
+ if (chevron) chevron.innerHTML = '▾';
+ }
+ }
+
+ // Failure redirect URL resolver
+ function getFailedRedirectUrl() {
+ const orderId = state?.orderId || '';
+ const reason = state?.status || 'FAILED';
+ const paymentId = typeof PAYMENT_ID !== 'undefined' ? PAYMENT_ID : (state?.id || '');
+
+ let baseOrigin = '';
+ if (state && state.returnUrl) {
+ try {
+ baseOrigin = new URL(state.returnUrl).origin;
+ } catch (e) { }
+ }
+ if (!baseOrigin && document.referrer) {
+ try {
+ baseOrigin = new URL(document.referrer).origin;
+ } catch (e) { }
+ }
+
+ const query = `orderId=${encodeURIComponent(orderId)}&reason=${encodeURIComponent(reason)}&paymentId=${encodeURIComponent(paymentId)}`;
+ return baseOrigin ? `${baseOrigin}/order-failed?${query}` : `/order-failed?${query}`;
+ }
+
+ // Store return URL resolver (used when user cancels payment or returns to merchant store)
+ function getStoreReturnUrl() {
+ if (typeof state !== 'undefined' && state) {
+ if (state.cancelUrl) {
+ return state.cancelUrl;
+ }
+ if (state.returnUrl) {
+ try {
+ const parsed = new URL(state.returnUrl);
+ return parsed.origin ? `${parsed.origin}/` : state.returnUrl;
+ } catch (e) { }
+ }
+ }
+ try {
+ const params = new URLSearchParams(window.location.search);
+ const cancelParam = params.get('cancelUrl') || params.get('cancel_url');
+ if (cancelParam) return cancelParam;
+ const qUrl = params.get('returnUrl') || params.get('storeUrl') || params.get('redirectUrl');
+ if (qUrl) {
+ const parsed = new URL(qUrl, window.location.origin);
+ return parsed.origin ? `${parsed.origin}/` : qUrl;
+ }
+ } catch (e) { }
+ if (document.referrer) {
+ try {
+ const refUrl = new URL(document.referrer);
+ if (refUrl.host !== window.location.host) {
+ return `${refUrl.origin}/`;
+ }
+ } catch (e) { }
+ }
+ if (window.location.port === '7000' || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
+ return 'http://localhost:5000/';
+ }
+ return '/';
+ }
+
+ // Retry / Close on Expired or Failed session
+ function handleRetryNewPayment() {
+ const failRedirectUrl = getFailedRedirectUrl();
+ const orderId = state?.orderId || '';
+ const reason = state?.status || 'FAILED';
+ const paymentId = typeof PAYMENT_ID !== 'undefined' ? PAYMENT_ID : (state?.id || '');
+
+ const isEmbedded = (window.parent !== window) || location.search.includes('embedded=1');
+
+ if (isEmbedded) {
+ try {
+ window.parent.postMessage({
+ event: 'youpi.payment_failed',
+ data: {
+ orderId,
+ reason,
+ paymentId,
+ status: reason,
+ redirectUrl: failRedirectUrl
+ },
+ orderId,
+ reason,
+ paymentId,
+ status: reason,
+ redirectUrl: failRedirectUrl
+ }, '*');
+ } catch (e) { }
+
+ // Fallback postMessage in case parent container only listens for modal_close
+ try {
+ window.parent.postMessage({
+ event: 'youpi.modal_close',
+ action: 'payment_failed',
+ redirectUrl: failRedirectUrl
+ }, '*');
+ } catch (e) { }
+ } else {
+ // Standalone full page checkout
+ window.location.href = failRedirectUrl;
+ }
+ }
+
+ // --- ACTION HOOK ENGINE (Dispatches triggers to merchant website and backend telemetry) ---
+ function emitTriggerHook(action, details = {}) {
+ try {
+ window.parent.postMessage({
+ type: 'YOUPI_PAYMENT_HOOK',
+ action,
+ paymentId: PAYMENT_ID,
+ orderId: state?.orderId,
+ details
+ }, '*');
+ } catch { }
+
+ fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/trigger-hook`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ action, details })
+ }).catch(() => { });
+ }
+
+ // --- SAVED / REMEMBERED CUSTOMER ACCOUNT (STRICT SINGLE USER) ---
+ function getRememberedAccounts() {
+ try {
+ const preserved = getPreservedIdentity();
+ if (preserved && preserved.customer) {
+ return [preserved.customer];
+ }
+ const raw = localStorage.getItem(STORAGE_KEY_ACCOUNTS);
+ if (!raw) return [];
+ const parsed = JSON.parse(raw);
+ if (!Array.isArray(parsed) || parsed.length === 0) return [];
+ return [parsed[0]]; // Strictly single user only
+ } catch {
+ return [];
+ }
+ }
+
+ function saveRememberedAccount(cust, token) {
+ if (!cust || !cust.id) return;
+ savePreservedIdentity(cust, token);
+ }
+
+ function removeRememberedAccount(customerId, e) {
+ if (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ clearPreservedIdentity();
+ if (activeCustomer && activeCustomer.id === customerId) {
+ activeCustomer = null;
+ activeToken = null;
+ }
+ updateCustomerDisplay(null);
+ renderSavedAccountsUI();
+ }
+
+ function renderSavedAccountsUI() {
+ const accounts = getRememberedAccounts();
+ const container = document.getElementById('preAuthSavedAccountsContainer');
+ const listEl = document.getElementById('savedAccountsList');
+ const badge = document.getElementById('savedAccountCountBadge');
+
+ if (badge) badge.style.display = 'none';
+
+ if (container && listEl) {
+ if (accounts.length > 0) {
+ container.hidden = false;
+ let html = '';
+ accounts.slice(0, 1).forEach(acc => {
+ const initial = (acc.name || 'U').charAt(0).toUpperCase();
+ const isActive = activeCustomer && activeCustomer.id === acc.id;
+ html += `
+ <div class="saved-account-row ${isActive ? 'active' : ''}" onclick="handleSelectSavedAccount('${acc.id}', event)">
+ <div style="display:flex; align-items:center; gap:8px;">
+ <div style="width:28px; height:28px; border-radius:50%; background:#e0f2fe; color:#0369a1; font-weight:800; font-size:12px; display:flex; align-items:center; justify-content:center;">${initial}</div>
+ <div>
+ <div style="font-size:13px; font-weight:700;">${escapeHtml(acc.name)}</div>
+ <div style="font-size:11px; color:#64748b;">${escapeHtml(acc.email || '')} ${acc.mobileNumber ? '&bull; ' + escapeHtml(acc.mobileNumber) : ''}</div>
+ </div>
+ </div>
+ <div style="display:flex; align-items:center; gap:6px;">
+ <button type="button" class="ypg-btn-select-account" style="background:#eff6ff; border:1px solid #bfdbfe; color:var(--ypg-blue); font-size:11px; font-weight:700; padding:4px 10px; border-radius:6px; cursor:pointer; display:inline-flex; align-items:center; gap:2px; transition:all 0.15s;" onclick="handleSelectSavedAccount('${acc.id}', event)">
+ <span>Select</span> &rsaquo;
+ </button>
+ <button type="button" style="background:none; border:none; color:#94a3b8; font-size:14px; cursor:pointer; padding:2px 6px;" onclick="removeRememberedAccount('${acc.id}', event)" title="Remove Account">✕</button>
+ </div>
+ </div>
+ `;
+ });
+ listEl.innerHTML = html;
+ } else {
+ container.hidden = true;
+ listEl.innerHTML = '';
+ }
+ }
+ }
+
+ let currentAuthMobile = '';
+ let currentAuthName = '';
+ let currentAuthEmail = '';
+ let currentAuthStep = 'mobile';
+ let hasAttemptedAutoLogin = false;
+ let otpCooldownTimer = null;
+ let otpCooldownSec = 0;
+
+ function setGatewayAuthMode(isAuthView) {
+ const authEl = document.getElementById('preGatewayAuthView');
+ const payEl = document.getElementById('paymentGatewayInterface');
+ const footerEl = document.getElementById('ypgStickyFooter');
+ const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
+
+ if (isAuthView) {
+ if (authEl) {
+ authEl.hidden = false;
+ authEl.style.removeProperty('display');
+ }
+ if (payEl) {
+ payEl.hidden = true;
+ payEl.style.setProperty('display', 'none', 'important');
+ }
+ if (footerEl) {
+ footerEl.style.display = 'none';
+ }
+ if (pcTopbarTitle) {
+ pcTopbarTitle.textContent = 'Sign in to Pay';
+ }
+ } else {
+ if (authEl) {
+ authEl.hidden = true;
+ authEl.style.setProperty('display', 'none', 'important');
+ }
+ if (payEl) {
+ payEl.hidden = false;
+ payEl.style.removeProperty('display');
+ }
+ if (footerEl) {
+ footerEl.style.display = '';
+ }
+ if (pcTopbarTitle) {
+ pcTopbarTitle.textContent = 'Payment Options';
+ }
+ }
+ }
+
+ function goToAuthStep(step) {
+ currentAuthStep = step;
+ const stepMobile = document.getElementById('authStepMobile');
+ const stepSignup = document.getElementById('authStepSignup');
+ const stepOtp = document.getElementById('authStepOtp');
+ const title = document.getElementById('authViewMainTitle');
+ const subtitle = document.getElementById('authViewSubTitle');
+ const savedAccountsBox = document.getElementById('preAuthSavedAccountsContainer');
+
+ if (step === 'mobile') {
+ if (stepMobile) stepMobile.hidden = false;
+ if (stepSignup) stepSignup.hidden = true;
+ if (stepOtp) stepOtp.hidden = true;
+ if (savedAccountsBox && getRememberedAccounts().length > 0) savedAccountsBox.hidden = false;
+ if (title) title.innerText = 'Sign in to Pay';
+ if (subtitle) subtitle.innerText = 'Enter your 10-digit WhatsApp mobile number to continue';
+ const input = document.getElementById('authMobileInput');
+ if (input) {
+ if (currentAuthMobile && !input.value) {
+ input.value = currentAuthMobile;
+ }
+ if (document.activeElement !== input) {
+ setTimeout(() => input.focus(), 50);
+ }
+ }
+ } else if (step === 'signup') {
+ if (stepMobile) stepMobile.hidden = true;
+ if (stepSignup) stepSignup.hidden = false;
+ if (stepOtp) stepOtp.hidden = true;
+ if (savedAccountsBox) savedAccountsBox.hidden = true;
+ if (title) title.innerText = 'Create Account';
+ if (subtitle) subtitle.innerText = 'Complete your profile to proceed with instant checkout';
+ const badge = document.getElementById('authSignupPhoneBadge');
+ if (badge) badge.innerText = '+91 ' + currentAuthMobile;
+ const nameInput = document.getElementById('authSignupName');
+ const emailInput = document.getElementById('authSignupEmail');
+ if (nameInput && currentAuthName && !nameInput.value) nameInput.value = currentAuthName;
+ if (emailInput && currentAuthEmail && !emailInput.value) emailInput.value = currentAuthEmail;
+ if (nameInput && document.activeElement !== nameInput && document.activeElement !== emailInput) {
+ setTimeout(() => nameInput.focus(), 50);
+ }
+ } else if (step === 'otp') {
+ if (stepMobile) stepMobile.hidden = true;
+ if (stepSignup) stepSignup.hidden = true;
+ if (stepOtp) stepOtp.hidden = false;
+ if (savedAccountsBox) savedAccountsBox.hidden = true;
+ if (title) title.innerText = 'Verify Mobile OTP';
+ if (subtitle) subtitle.innerText = 'Enter the 6-digit code sent to your WhatsApp number';
+ const badge = document.getElementById('authOtpPhoneBadge');
+ if (badge) badge.innerText = '+91 ' + currentAuthMobile;
+ const otpInput = document.getElementById('authOtpInput');
+ if (otpInput) {
+ otpInput.value = '';
+ setTimeout(() => otpInput.focus(), 50);
+ }
+ startOtpCooldown(30);
+ }
+ }
+
+ function startOtpCooldown(sec = 30) {
+ clearInterval(otpCooldownTimer);
+ otpCooldownSec = sec;
+ const resendBtn = document.getElementById('btnResendOtp');
+ const countdownEl = document.getElementById('otpCountdownTimer');
+
+ const updateUI = () => {
+ if (otpCooldownSec > 0) {
+ if (resendBtn) {
+ resendBtn.disabled = true;
+ resendBtn.style.opacity = '0.5';
+ resendBtn.style.cursor = 'not-allowed';
+ }
+ if (countdownEl) countdownEl.innerText = `(${otpCooldownSec}s)`;
+ otpCooldownSec--;
+ } else {
+ clearInterval(otpCooldownTimer);
+ if (resendBtn) {
+ resendBtn.disabled = false;
+ resendBtn.style.opacity = '1';
+ resendBtn.style.cursor = 'pointer';
+ }
+ if (countdownEl) countdownEl.innerText = '';
+ }
+ };
+
+ updateUI();
+ otpCooldownTimer = setInterval(updateUI, 1000);
+ }
+
+ async function handleAuthMobileSubmit() {
+ const input = document.getElementById('authMobileInput');
+ const btn = document.getElementById('btnAuthContinue');
+ const raw = input ? input.value : '';
+ const clean = String(raw).replace(/\D/g, '').slice(-10);
+
+ if (!clean || clean.length !== 10) {
+ showOptionToast('Please enter a valid 10-digit mobile number');
+ input?.focus();
+ return;
+ }
+
+ currentAuthMobile = clean;
+ const oldHtml = btn.innerHTML;
+ btn.disabled = true;
+ btn.innerHTML = '<span>Checking account...</span>';
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/customer/check-user`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ mobileNumber: clean })
+ });
+ const data = await res.json();
+
+ if (!res.ok) {
+ showOptionToast(data.error || 'Failed to check mobile number');
+ return;
+ }
+
+ const accounts = getRememberedAccounts();
+ const savedMatch = accounts.find(a => String(a.mobileNumber || '').replace(/\D/g, '').slice(-10) === clean);
+
+ if (data.exists && data.customer) {
+ // Existing customer in DB -> automatically send OTP and show OTP screen
+ currentAuthName = data.customer.name;
+ currentAuthEmail = data.customer.email;
+ btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
+
+ const sendRes = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: clean
+ })
+ });
+ const sendData = await sendRes.json();
+ if (sendData && sendData.devOtp) lastReceivedDevOtp = sendData.devOtp;
+
+ const greetingEl = document.getElementById('authOtpGreeting');
+ if (greetingEl) {
+ greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(data.customer.name)}</strong>! Enter the 6-digit WhatsApp OTP:`;
+ }
+
+ goToAuthStep('otp');
+ showOptionToast('OTP sent to your WhatsApp number!');
+ } else if (savedMatch) {
+ // Known customer in browser saved accounts -> dispatch OTP directly with saved profile
+ currentAuthName = savedMatch.name || 'Customer';
+ currentAuthEmail = savedMatch.email || '';
+ btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
+
+ const sendRes = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: clean,
+ name: currentAuthName,
+ email: currentAuthEmail
+ })
+ });
+ const sendData = await sendRes.json();
+ if (sendData && sendData.devOtp) lastReceivedDevOtp = sendData.devOtp;
+
+ const greetingEl = document.getElementById('authOtpGreeting');
+ if (greetingEl) {
+ greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(currentAuthName)}</strong>! Enter the 6-digit WhatsApp OTP:`;
+ }
+
+ goToAuthStep('otp');
+ showOptionToast('OTP sent to your WhatsApp number!');
+ } else {
+ // New customer -> prompt for name and email
+ goToAuthStep('signup');
+ }
+ } catch (e) {
+ showOptionToast('Network error checking mobile number.');
+ } finally {
+ btn.disabled = false;
+ btn.innerHTML = oldHtml;
+ }
+ }
+
+ async function handleAuthSignupSubmit() {
+ const nameInput = document.getElementById('authSignupName');
+ const emailInput = document.getElementById('authSignupEmail');
+ const btn = document.getElementById('btnAuthSignup');
+
+ const name = nameInput ? nameInput.value.trim() : '';
+ const email = emailInput ? emailInput.value.trim() : '';
+
+ if (!name) {
+ showOptionToast('Please enter your full name');
+ nameInput?.focus();
+ return;
+ }
+ if (!email || !email.includes('@') || !email.includes('.')) {
+ showOptionToast('Please enter a valid email address');
+ emailInput?.focus();
+ return;
+ }
+
+ currentAuthName = name;
+ currentAuthEmail = email;
+
+ const oldHtml = btn.innerHTML;
+ btn.disabled = true;
+ btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: currentAuthMobile,
+ name,
+ email,
+ isNewUser: true
+ })
+ });
+ const data = await res.json();
+ if (data && data.devOtp) lastReceivedDevOtp = data.devOtp;
+
+ if (res.ok) {
+ const greetingEl = document.getElementById('authOtpGreeting');
+ if (greetingEl) {
+ greetingEl.innerHTML = `Hello <strong>${escapeHtml(name)}</strong>! Enter the 6-digit WhatsApp OTP:`;
+ }
+ goToAuthStep('otp');
+ showOptionToast('WhatsApp verification code sent!');
+ } else {
+ showOptionToast(data.error || 'Failed to send WhatsApp OTP.');
+ }
+ } catch (e) {
+ showOptionToast('Network error sending WhatsApp OTP.');
+ } finally {
+ btn.disabled = false;
+ btn.innerHTML = oldHtml;
+ }
+ }
+
+ async function handleAuthVerifyOtpSubmit() {
+ const otpInput = document.getElementById('authOtpInput');
+ const btn = document.getElementById('btnAuthVerifyOtp');
+ const otp = otpInput ? otpInput.value.trim() : '';
+
+ if (!otp || otp.length < 6) {
+ showOptionToast('Please enter the 6-digit WhatsApp OTP');
+ otpInput?.focus();
+ return;
+ }
+
+ const oldHtml = btn.innerHTML;
+ btn.disabled = true;
+ btn.innerHTML = '<span>Verifying OTP...</span>';
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/customer/verify-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: currentAuthMobile,
+ otp,
+ name: currentAuthName,
+ email: currentAuthEmail
+ })
+ });
+ const data = await res.json();
+
+ if (res.ok && data.customer) {
+ activeCustomer = data.customer;
+ activeToken = data.token;
+ saveRememberedAccount(activeCustomer, activeToken);
+
+ // Bind session
+ await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/bind-customer`, {
+ method: 'POST',
+ headers: getApiHeaders({
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${activeToken}`
+ }),
+ body: JSON.stringify({ token: activeToken, customerId: activeCustomer.id })
+ });
+
+ emitTriggerHook('AUTH_COMPLETED', { customerId: activeCustomer.id });
+
+ setGatewayAuthMode(false);
+ updateCustomerDisplay(activeCustomer);
+ loadState();
+ showOptionToast(`Welcome, ${activeCustomer.name}! Verified via WhatsApp.`);
+ } else {
+ showOptionToast(data.error || 'Invalid or expired OTP. Please try again.');
+ otpInput.select();
+ }
+ } catch (e) {
+ showOptionToast('Network error verifying OTP.');
+ } finally {
+ btn.disabled = false;
+ btn.innerHTML = oldHtml;
+ }
+ }
+
+ async function handleResendOtp() {
+ if (otpCooldownSec > 0) return;
+ showOptionToast('Resending WhatsApp OTP...');
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: currentAuthMobile,
+ name: currentAuthName,
+ email: currentAuthEmail
+ })
+ });
+ const data = await res.json();
+ if (res.ok) {
+ startOtpCooldown(30);
+ showOptionToast('Fresh OTP dispatched to your WhatsApp number!');
+ const otpInput = document.getElementById('authOtpInput');
+ if (otpInput) {
+ otpInput.value = '';
+ otpInput.focus();
+ }
+ } else {
+ showOptionToast(data.error || 'Failed to resend OTP.');
+ }
+ } catch (e) {
+ showOptionToast('Network error resending OTP.');
+ }
+ }
+
+ async function handleSelectSavedAccount(accountId, event) {
+ if (event) {
+ event.stopPropagation();
+ }
+ const accounts = getRememberedAccounts();
+ const account = accounts.find(a => a.id === accountId);
+ if (!account) return;
+
+ const rawPhone = account.mobileNumber || '';
+ const clean = String(rawPhone).replace(/\D/g, '').slice(-10);
+
+ if (!clean || clean.length !== 10) {
+ showOptionToast('Saved account does not have a valid 10-digit mobile number.');
+ const input = document.getElementById('authMobileInput');
+ if (input) {
+ input.value = rawPhone;
+ input.focus();
+ }
+ return;
+ }
+
+ currentAuthMobile = clean;
+ currentAuthName = account.name || 'Customer';
+ currentAuthEmail = account.email || '';
+
+ const input = document.getElementById('authMobileInput');
+ if (input) input.value = clean;
+
+ // Provide visual loading feedback on the clicked button if present
+ const selectBtn = event?.currentTarget?.querySelector?.('.ypg-btn-select-account') ||
+ (event?.target?.classList?.contains('ypg-btn-select-account') ? event.target : null);
+ const oldBtnHtml = selectBtn ? selectBtn.innerHTML : null;
+ if (selectBtn) {
+ selectBtn.disabled = true;
+ selectBtn.innerHTML = '<span>Sending OTP...</span>';
+ }
+
+ showOptionToast(`Sending WhatsApp OTP to +91 ${clean}...`);
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ mobileNumber: clean,
+ name: currentAuthName,
+ email: currentAuthEmail
+ })
+ });
+ const data = await res.json();
+ if (data && data.devOtp) lastReceivedDevOtp = data.devOtp;
+
+ if (!res.ok) {
+ showOptionToast(data.error || 'Failed to send WhatsApp OTP.');
+ return;
+ }
+
+ const greetingEl = document.getElementById('authOtpGreeting');
+ if (greetingEl) {
+ greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(account.name || 'Customer')}</strong>! Enter the 6-digit WhatsApp OTP:`;
+ }
+ const badge = document.getElementById('authOtpPhoneBadge');
+ if (badge) badge.innerText = '+91 ' + clean;
+
+ goToAuthStep('otp');
+ showOptionToast('WhatsApp verification code sent!');
+ } catch (err) {
+ console.error('[Select Saved Account Error]:', err);
+ showOptionToast('Network error sending WhatsApp OTP.');
+ } finally {
+ if (selectBtn && oldBtnHtml) {
+ selectBtn.disabled = false;
+ selectBtn.innerHTML = oldBtnHtml;
+ }
+ }
+ }
+
+ function updateCustomerDisplay(cust) {
+ const displayName = cust
+ ? `${cust.fullName || cust.name || 'Customer'} (${cust.mobileNumber || cust.phoneNumber || cust.email || ''})`
+ : 'Guest User';
+ const nameElMobile = document.getElementById('popoverCustomerName');
+ if (nameElMobile) nameElMobile.textContent = displayName;
+ const nameElPc = document.getElementById('popoverCustomerNamePc');
+ if (nameElPc) nameElPc.textContent = displayName;
+
+ const pcCustomerText = document.getElementById('pcCustomerProfileText');
+ if (pcCustomerText) {
+ if (!cust) {
+ pcCustomerText.textContent = 'Using as Guest User';
+ return;
+ }
+ const name = cust.fullName || cust.name || cust.customerName || '';
+ const phone = cust.mobileNumber || cust.phoneNumber || '';
+ const clean = phone ? String(phone).replace(/^\+91/, '').replace(/\D/g, '').slice(-10) : '';
+ if (name && clean) {
+ pcCustomerText.textContent = `Using as ${name} (+91 ${clean})`;
+ } else if (name) {
+ pcCustomerText.textContent = `Using as ${name}`;
+ } else if (clean) {
+ pcCustomerText.textContent = `Using as +91 ${clean}`;
+ } else if (cust.email) {
+ pcCustomerText.textContent = `Using as ${cust.email}`;
+ } else {
+ pcCustomerText.textContent = 'Using as Guest User';
+ }
+ }
+ }
+
+ function toggleAccountMenu(e) {
+ if (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ const isPc = window.innerWidth > 600 && !document.body.classList.contains('is-embedded-mobile');
+ const popover = isPc
+ ? (document.getElementById('accountMenuPopoverPc') || document.getElementById('accountMenuPopover'))
+ : (document.getElementById('accountMenuPopover') || document.getElementById('accountMenuPopoverPc'));
+ if (!popover) return;
+
+ const isHidden = popover.hidden || popover.style.display === 'none' || popover.hasAttribute('hidden');
+ if (isHidden) {
+ popover.removeAttribute('hidden');
+ popover.hidden = false;
+ popover.style.display = 'block';
+ const dismissHandler = (evt) => {
+ if (!popover.contains(evt.target) &&
+ !evt.target.closest('#btnProfileMenu') &&
+ !evt.target.closest('.ypg-pc-btn-more') &&
+ !evt.target.closest('#btnPcMore') &&
+ !evt.target.closest('#pcCustomerProfileRow')) {
+ popover.setAttribute('hidden', '');
+ popover.hidden = true;
+ popover.style.display = 'none';
+ document.removeEventListener('click', dismissHandler);
+ }
+ };
+ setTimeout(() => document.addEventListener('click', dismissHandler), 10);
+ } else {
+ popover.setAttribute('hidden', '');
+ popover.hidden = true;
+ popover.style.display = 'none';
+ }
+ }
+
+ async function handleCustomerLogout() {
+ const popoverMobile = document.getElementById('accountMenuPopover');
+ if (popoverMobile) { popoverMobile.setAttribute('hidden', ''); popoverMobile.hidden = true; popoverMobile.style.display = 'none'; }
+ const popoverPc = document.getElementById('accountMenuPopoverPc');
+ if (popoverPc) { popoverPc.setAttribute('hidden', ''); popoverPc.hidden = true; popoverPc.style.display = 'none'; }
+
+ if (activeToken) {
+ try {
+ await fetch(`${API_BASE}/api/v1/customer/logout`, {
+ method: 'POST',
+ headers: { 'Authorization': `Bearer ${activeToken}` }
+ });
+ } catch { }
+ }
+
+ clearPreservedIdentity();
+ activeCustomer = null;
+ activeToken = null;
+ hasAttemptedAutoLogin = false;
+ updateCustomerDisplay(null);
+ setGatewayAuthMode(true);
+ goToAuthStep('mobile');
+ renderSavedAccountsUI();
+ }
+
+ function escapeHtml(str) {
+ if (!str) return '';
+ return String(str).replace(/[&<>"']/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[m]);
+ }
+
+ let currentSelectedMethod = 'UPI';
+
+ function hideAllContent() {
+ document.getElementById('viewUpiContent').hidden = true;
+ const vCod = document.getElementById('viewCodContent');
+ if (vCod) vCod.hidden = true;
+ const vCash = document.getElementById('viewCashContent');
+ if (vCash) vCash.hidden = true;
+ const vCard = document.getElementById('viewCardContent');
+ if (vCard) vCard.hidden = true;
+ document.getElementById('viewProcessingContent').hidden = true;
+ document.getElementById('viewSuccessContent').hidden = true;
+ document.getElementById('viewFailedContent').hidden = true;
+ document.getElementById('viewQueuedContent').hidden = true;
+ const vBlocked = document.getElementById('viewBlockedContent');
+ if (vBlocked) vBlocked.hidden = true;
+ const vDup = document.getElementById('viewDuplicateSessionContent');
+ if (vDup) vDup.hidden = true;
+ }
+
+ function formatTime(totalSec) {
+ const m = Math.floor(totalSec / 60);
+ const s = totalSec % 60;
+ return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
+ }
+
+ let _activeCountdownTargetTime = null;
+
+ function runCountdown(seconds, onTick, onDone, targetExpiresAt) {
+ const targetTime = targetExpiresAt
+ ? new Date(targetExpiresAt).getTime()
+ : (_activeCountdownTargetTime || (Date.now() + (seconds || 300) * 1000));
+
+ if (countdownTimer && _activeCountdownTargetTime && Math.abs(_activeCountdownTargetTime - targetTime) <= 2500) {
+ return;
+ }
+
+ _activeCountdownTargetTime = targetTime;
+ if (countdownTimer) clearInterval(countdownTimer);
+
+ const calcRemaining = () => {
+ return Math.max(0, Math.ceil((targetTime - Date.now()) / 1000));
+ };
+
+ const doTick = (sec) => {
+ onTick(sec);
+ const tStr = formatTime(sec);
+ document.querySelectorAll('.ypg-banner-running-timer').forEach(el => {
+ el.textContent = tStr;
+ });
+ };
+ doTick(calcRemaining());
+
+ countdownTimer = setInterval(() => {
+ const remaining = calcRemaining();
+ if (remaining <= 0) {
+ clearInterval(countdownTimer);
+ countdownTimer = null;
+ _activeCountdownTargetTime = null;
+ doTick(0);
+ if (onDone) onDone();
+ } else {
+ doTick(remaining);
+ }
+ }, 1000);
+ }
+
+ function renderMethodSelectorBar(data) {
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ const sellingMode = data.sellingMode || 'ONLINE';
+ const enabledMethods = data.enabledMethods || ['UPI'];
+
+ // Populate authenticated customer into COD view
+ const c = data.customer || activeCustomer;
+ if (c) {
+ const nameEl = document.getElementById('codCustomerName');
+ const phoneEl = document.getElementById('codCustomerPhone');
+ if (nameEl) nameEl.textContent = c.fullName || c.name || 'Customer';
+ if (phoneEl) phoneEl.textContent = c.phoneNumber || c.mobileNumber || '-';
+ }
+
+ // Maintain authentic 3-column desktop layout
+ const pcMethodsList = document.getElementById('pcMethodsList');
+ const pcActiveView = document.querySelector('.ypg-pc-active-view');
+ const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
+
+ if (pcMethodsList) pcMethodsList.style.removeProperty('display');
+ if (pcActiveView) pcActiveView.style.width = '';
+ if (pcTopbarTitle) pcTopbarTitle.textContent = 'Payment Options';
+
+ // Mobile selector bar is visible only when more than 1 method is available
+ if (bar) {
+ bar.style.display = (!enabledMethods || enabledMethods.length <= 1) ? 'none' : 'flex';
+ }
+
+ const tabUpi = document.getElementById('tabMethodUpi');
+ const tabCod = document.getElementById('tabMethodCod');
+ const tabCash = document.getElementById('tabMethodCash');
+ const tabCard = document.getElementById('tabMethodCard');
+
+ if (tabUpi) tabUpi.style.display = 'inline-flex';
+
+ const pcUpi = document.getElementById('pcMethodCardUpi');
+ const pcCod = document.getElementById('pcMethodCardCod');
+ const pcCash = document.getElementById('pcMethodCardCash');
+ const pcCard = document.getElementById('pcMethodCardCard');
+
+ if (pcUpi) pcUpi.style.display = 'block';
+
+ if (sellingMode === 'ONLINE') {
+ // Online Selling Mode:
+ // COD works (configurable ON/OFF).
+ // Cash on counter and Card on counter do NOT exist (hidden).
+ if (tabCod) tabCod.style.display = enabledMethods.includes('COD') ? 'inline-flex' : 'none';
+ if (tabCash) tabCash.style.display = 'none';
+ if (tabCard) tabCard.style.display = 'none';
+
+ if (pcCod) pcCod.style.display = enabledMethods.includes('COD') ? 'block' : 'none';
+ if (pcCash) pcCash.style.display = 'none';
+ if (pcCard) pcCard.style.display = 'none';
+ } else {
+ // Offline Selling Mode:
+ // Cash works (configurable ON/OFF).
+ // Card works (configurable ON/OFF).
+ // COD does NOT exist (hidden).
+ if (tabCod) tabCod.style.display = 'none';
+ if (tabCash) tabCash.style.display = enabledMethods.includes('CASH_COUNTER') ? 'inline-flex' : 'none';
+ if (tabCard) tabCard.style.display = enabledMethods.includes('CARD_COUNTER') ? 'inline-flex' : 'none';
+
+ if (pcCod) pcCod.style.display = 'none';
+ if (pcCash) pcCash.style.display = enabledMethods.includes('CASH_COUNTER') ? 'block' : 'none';
+ if (pcCard) pcCard.style.display = enabledMethods.includes('CARD_COUNTER') ? 'block' : 'none';
+ }
+
+ if (!enabledMethods.includes(currentSelectedMethod)) {
+ currentSelectedMethod = 'UPI';
+ }
+ updateMethodTabsUI(currentSelectedMethod);
+ }
+
+ function updateMethodTabsUI(method) {
+ const tabs = [
+ { id: 'tabMethodUpi', method: 'UPI' },
+ { id: 'tabMethodCod', method: 'COD' },
+ { id: 'tabMethodCash', method: 'CASH_COUNTER' },
+ { id: 'tabMethodCard', method: 'CARD_COUNTER' }
+ ];
+ tabs.forEach(t => {
+ const el = document.getElementById(t.id);
+ if (!el) return;
+ if (t.method === method) {
+ el.classList.add('active');
+ } else {
+ el.classList.remove('active');
+ }
+ });
+
+ const pcCards = [
+ { id: 'pcMethodCardUpi', method: 'UPI' },
+ { id: 'pcMethodCardCod', method: 'COD' },
+ { id: 'pcMethodCardCash', method: 'CASH_COUNTER' },
+ { id: 'pcMethodCardCard', method: 'CARD_COUNTER' }
+ ];
+ pcCards.forEach(c => {
+ const el = document.getElementById(c.id);
+ if (!el) return;
+ if (c.method === method) {
+ el.classList.add('is-active');
+ } else {
+ el.classList.remove('is-active');
+ }
+ });
+ }
+
+ function switchMethodFromDowntime() {
+ const enabled = state?.enabledMethods || state?.branding?.enabledPaymentMethods || [];
+ const sellingMode = state?.sellingMode || state?.branding?.sellingMode || 'OFFLINE';
+ if (sellingMode === 'ONLINE' && enabled.includes('COD')) {
+ selectPaymentMethod('COD');
+ } else if (enabled.includes('CASH_COUNTER')) {
+ selectPaymentMethod('CASH_COUNTER');
+ }
+ }
+
+ async function selectPaymentMethod(method) {
+ currentSelectedMethod = method;
+ updateMethodTabsUI(method);
+ hideAllContent();
+
+ if (method === 'UPI') {
+ document.getElementById('viewUpiContent').hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'flex';
+ } else if (method === 'COD') {
+ const vCod = document.getElementById('viewCodContent');
+ if (vCod) vCod.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ } else if (method === 'CASH_COUNTER') {
+ const vCash = document.getElementById('viewCashContent');
+ if (vCash) vCash.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ } else if (method === 'CARD_COUNTER') {
+ const vCard = document.getElementById('viewCardContent');
+ if (vCard) vCard.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ }
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/select-method`, {
+ method: 'POST',
+ headers: getApiHeaders({ 'Content-Type': 'application/json' }),
+ body: JSON.stringify({ method, deviceId: DeviceIdentity?.currentDeviceId })
+ });
+ const resData = await res.json();
+ if (res.ok && resData) {
+ state.method = method;
+ if (resData.timeRemainingSeconds !== undefined) {
+ state.timeRemainingSeconds = resData.timeRemainingSeconds;
+ }
+ if (resData.status) {
+ state.status = resData.status;
+ }
+
+ if (method === 'COD') {
+ runCountdown(resData.timeRemainingSeconds || 300, sec => {
+ const el = document.getElementById('codTimerText');
+ if (el) el.textContent = formatTime(sec);
+ }, () => {
+ const el = document.getElementById('codTimerText');
+ if (el) el.textContent = 'Expired';
+ fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
+ loadState();
+ });
+ } else if (method === 'UPI') {
+ if (resData.status === 'ACTIVE') {
+ loadQrSvg();
+ runCountdown(resData.timeRemainingSeconds || 300, sec => {
+ const el = document.getElementById('activeTimerText');
+ if (el) el.textContent = formatTime(sec);
+ }, () => {
+ const el = document.getElementById('activeTimerText');
+ if (el) el.textContent = 'Expired';
+ fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
+ loadState();
+ });
+ } else if (resData.status === 'QUEUED') {
+ loadState();
+ }
+ } else {
+ // Offline Counter mode: no timer countdown
+ if (countdownTimer) clearInterval(countdownTimer);
+ }
+ }
+ } catch (e) {
+ console.warn('selectPaymentMethod network error:', e);
+ }
+ }
+
+ async function promptConfirmCodOrder() {
+ const amt = state?.amount || '' + (state?.amount || "0.00") + '';
+ if (!confirm(`Are you sure you want to confirm and place this Cash on Delivery (COD) order for ₹${amt}? You will pay in cash upon doorstep delivery.`)) {
+ return;
+ }
+ await executeConfirmCodOrder();
+ }
+
+ async function executeConfirmCodOrder() {
+ const btn = document.getElementById('btnConfirmCod');
+ if (btn) {
+ btn.disabled = true;
+ btn.innerText = 'Placing Cash on Delivery Order...';
+ }
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/confirm-cod`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' }
+ });
+ const data = await res.json();
+ if (res.ok) {
+ loadState();
+ } else {
+ alert(data.error || 'Failed to place COD order');
+ if (btn) {
+ btn.disabled = false;
+ btn.innerHTML = '<span>Confirm &amp; Place COD Order (₹' + (state?.amount || '' + (state?.amount || "0.00") + '') + ')</span> &rsaquo;';
+ }
+ }
+ } catch (e) {
+ alert('Network error confirming COD order.');
+ if (btn) {
+ btn.disabled = false;
+ btn.innerHTML = '<span>Confirm &amp; Place COD Order (₹' + (state?.amount || '' + (state?.amount || "0.00") + '') + ')</span> &rsaquo;';
+ }
+ }
+ }
+
+ // --- DEVICE IDENTITY & HARDWARE CONTEXT BINDING LAYER ---
+ const DeviceIdentity = {
+ dbName: 'youpi_device_keystore_v1',
+ storeName: 'keys',
+ currentDeviceId: null,
+ currentDeviceToken: null,
+
+ async openDb() {
+ return new Promise((resolve) => {
+ if (!window.indexedDB) {
+ resolve(null);
+ return;
+ }
+ const req = window.indexedDB.open(this.dbName, 1);
+ req.onupgradeneeded = (e) => {
+ const db = e.target.result;
+ if (!db.objectStoreNames.contains(this.storeName)) {
+ db.createObjectStore(this.storeName, { keyPath: 'id' });
+ }
+ };
+ req.onsuccess = () => resolve(req.result);
+ req.onerror = () => resolve(null);
+ });
+ },
+
+ async getStoredRecord() {
+ try {
+ const db = await this.openDb();
+ if (!db) return null;
+ return new Promise((resolve) => {
+ const tx = db.transaction(this.storeName, 'readonly');
+ const store = tx.objectStore(this.storeName);
+ const req = store.get('primary_device');
+ req.onsuccess = () => resolve(req.result || null);
+ req.onerror = () => resolve(null);
+ });
+ } catch {
+ return null;
+ }
+ },
+
+ async saveRecord(record) {
+ try {
+ const db = await this.openDb();
+ if (!db) return;
+ return new Promise((resolve) => {
+ const tx = db.transaction(this.storeName, 'readwrite');
+ const store = tx.objectStore(this.storeName);
+ store.put({ id: 'primary_device', ...record });
+ tx.oncomplete = () => resolve();
+ tx.onerror = () => resolve();
+ });
+ } catch {}
+ },
+
+ collectSignals() {
+ let canvasSig = '';
+ try {
+ const canvas = document.createElement('canvas');
+ canvas.width = 120;
+ canvas.height = 30;
+ const ctx = canvas.getContext('2d');
+ ctx.textBaseline = 'top';
+ ctx.font = "14px 'Arial'";
+ ctx.fillText('YouPI-PG-Device-Binding-2026', 2, 2);
+ canvasSig = canvas.toDataURL().slice(-32);
+ } catch {}
+
+ let webglRenderer = '';
+ try {
+ const gl = document.createElement('canvas').getContext('webgl');
+ if (gl) {
+ const dbg = gl.getExtension('WEBGL_debug_renderer_info');
+ if (dbg) webglRenderer = gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL);
+ }
+ } catch {}
+
+ return {
+ userAgent: navigator.userAgent || '',
+ platform: navigator.platform || '',
+ language: navigator.language || '',
+ timezone: (Intl && Intl.DateTimeFormat) ? Intl.DateTimeFormat().resolvedOptions().timeZone : '',
+ screenSignature: `${window.screen?.width || 0}x${window.screen?.height || 0}x${window.screen?.colorDepth || 24}`,
+ hardwareConcurrency: navigator.hardwareConcurrency || 0,
+ deviceMemory: navigator.deviceMemory || 0,
+ webglRenderer,
+ canvasSignature: canvasSig
+ };
+ },
+
+ async getOrRegister() {
+ if (this.currentDeviceId) {
+ return { deviceId: this.currentDeviceId, deviceToken: this.currentDeviceToken };
+ }
+
+ // 1. Check local storage / session cache first
+ let cachedId = localStorage.getItem('ypg_device_id');
+ let cachedToken = localStorage.getItem('ypg_device_token');
+
+ // 2. Check IndexedDB persistent store
+ const stored = await this.getStoredRecord();
+ if (stored?.deviceId) {
+ this.currentDeviceId = stored.deviceId;
+ this.currentDeviceToken = stored.deviceToken;
+ localStorage.setItem('ypg_device_id', stored.deviceId);
+ if (stored.deviceToken) localStorage.setItem('ypg_device_token', stored.deviceToken);
+ return { deviceId: stored.deviceId, deviceToken: stored.deviceToken };
+ }
+
+ if (cachedId) {
+ this.currentDeviceId = cachedId;
+ this.currentDeviceToken = cachedToken;
+ return { deviceId: cachedId, deviceToken: cachedToken };
+ }
+
+ // 3. Generate new Web Crypto key pair
+ let publicKeyBase64 = '';
+ try {
+ if (window.crypto && window.crypto.subtle) {
+ const keyPair = await window.crypto.subtle.generateKey(
+ { name: 'ECDSA', namedCurve: 'P-256' },
+ true,
+ ['sign', 'verify']
+ );
+ const spki = await window.crypto.subtle.exportKey('spki', keyPair.publicKey);
+ const bytes = new Uint8Array(spki);
+ let binary = '';
+ for (let i = 0; i < bytes.byteLength; i++) {
+ binary += String.fromCharCode(bytes[i]);
+ }
+ publicKeyBase64 = btoa(binary);
+ }
+ } catch (e) {
+ console.warn('[DeviceIdentity] Web Crypto keygen fallback:', e.message);
+ }
+
+ if (!publicKeyBase64) {
+ publicKeyBase64 = btoa(`fallback-device-key-${Math.random()}-${Date.now()}`);
+ }
+
+ // 4. Register with YouPI backend
+ const signals = this.collectSignals();
+ try {
+ const resp = await fetch(`${API_BASE}/api/v1/devices/register`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ publicKey: publicKeyBase64, signals })
+ });
+ const data = await resp.json();
+ if (data?.deviceId) {
+ this.currentDeviceId = data.deviceId;
+ this.currentDeviceToken = data.deviceToken;
+ localStorage.setItem('ypg_device_id', data.deviceId);
+ if (data.deviceToken) localStorage.setItem('ypg_device_token', data.deviceToken);
+
+ await this.saveRecord({
+ deviceId: data.deviceId,
+ deviceToken: data.deviceToken,
+ publicKeyBase64,
+ registeredAt: new Date().toISOString()
+ });
+
+ return { deviceId: data.deviceId, deviceToken: data.deviceToken };
+ }
+ } catch (err) {
+ console.error('[DeviceIdentity] Registration error:', err);
+ }
+
+ return { deviceId: null, deviceToken: null };
+ }
+ };
+
+ function getApiHeaders(customHeaders = {}) {
+ const headers = { ...customHeaders };
+ if (typeof DeviceIdentity !== 'undefined' && DeviceIdentity?.currentDeviceId) {
+ headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
+ }
+ if (typeof DeviceIdentity !== 'undefined' && DeviceIdentity?.currentDeviceToken) {
+ headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
+ }
+ const token = activeToken || (getPreservedIdentity()?.token) || localStorage.getItem('ypg_customer_token');
+ if (token) {
+ headers['Authorization'] = `Bearer ${token}`;
+ headers['x-customer-token'] = token;
+ }
+ return headers;
+ }
+
+ async function loadState() {
+ try {
+ await DeviceIdentity.getOrRegister();
+ const headers = getApiHeaders();
+
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/state`, { headers });
+ const data = await res.json().catch(() => ({}));
+
+ if (res.status === 409 || data.error === 'DUPLICATE_SESSION_DETECTED') {
+ renderDuplicateSession(data);
+ dismissSplashScreen();
+ return;
+ }
+
+ if (!res.ok) {
+ dismissSplashScreen();
+ return;
+ }
+
+ renderState(data);
+ dismissSplashScreen();
+ } catch (e) {
+ console.warn('loadState error:', e);
+ dismissSplashScreen();
+ }
+ }
+
+ function adjustHexColor(col, amt) {
+ if (!col) return '#0957cb';
+ try {
+ let usePound = false;
+ if (col[0] === '#') {
+ col = col.slice(1);
+ usePound = true;
+ }
+ if (col.length === 3) col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
+ const num = parseInt(col, 16);
+ let r = (num >> 16) + amt;
+ if (r > 255) r = 255; else if (r < 0) r = 0;
+ let b = ((num >> 8) & 0x00FF) + amt;
+ if (b > 255) b = 255; else if (b < 0) b = 0;
+ let g = (num & 0x0000FF) + amt;
+ if (g > 255) g = 255; else if (g < 0) g = 0;
+ return (usePound ? '#' : '') + (g | (b << 8) | (r << 16)).toString(16).padStart(6, '0');
+ } catch {
+ return col;
+ }
+ }
+
+ function applyDynamicTheme(branding) {
+ if (!branding) return;
+ const primary = branding.primaryColor || '#0b63e5';
+ const darkPrimary = adjustHexColor(primary, -25);
+ const root = document.documentElement;
+
+ root.style.setProperty('--ypg-blue', primary);
+ root.style.setProperty('--ypg-blue-dark', darkPrimary);
+
+ const theme = branding.headerTheme || 'gradient';
+ const headerEl = document.querySelector('.ypg-header');
+ const sidebarEl = document.querySelector('.ypg-pc-sidebar');
+
+ if (theme === 'solid') {
+ root.style.setProperty('--ypg-header-gradient', primary);
+ if (headerEl) headerEl.style.background = primary;
+ if (sidebarEl) sidebarEl.style.background = primary;
+ } else if (theme === 'dark') {
+ root.style.setProperty('--ypg-header-gradient', '#0b1329');
+ if (headerEl) headerEl.style.background = '#0b1329';
+ if (sidebarEl) sidebarEl.style.background = 'linear-gradient(180deg, #0b1329 0%, #030712 100%)';
+ } else {
+ const grad = `linear-gradient(180deg, ${primary} 0%, ${darkPrimary} 100%)`;
+ root.style.setProperty('--ypg-header-gradient', grad);
+ if (headerEl) headerEl.style.background = grad;
+ if (sidebarEl) sidebarEl.style.background = grad;
+ }
+ }
+
+ function renderHelpLegalLinks(branding) {
+ const container = document.getElementById('helpModalLegalLinks');
+ if (!container) return;
+ let html = '';
+ if (branding.privacyPolicyUrl) {
+ html += `<a href="${branding.privacyPolicyUrl}" target="_blank" rel="noopener noreferrer" style="color:var(--ypg-blue); text-decoration:underline; font-weight:600;">Privacy Policy &nearr;</a>`;
+ }
+ if (branding.termsUrl) {
+ html += `<a href="${branding.termsUrl}" target="_blank" rel="noopener noreferrer" style="color:var(--ypg-blue); text-decoration:underline; font-weight:600;">Terms of Service &nearr;</a>`;
+ }
+ container.innerHTML = html;
+ container.style.display = html ? 'flex' : 'none';
+ }
+
+ function renderState(data) {
+ state = data;
+ const b = data.branding || {};
+ const appName = b.appName || 'YouPI PG';
+ const merchantName = data.merchantName || 'Merchant Checkout';
+
+ // 1. Dynamic Title
+ document.title = `${merchantName} · ${appName} Checkout`;
+
+ // 2. Dynamic Colors & Header Theme
+ applyDynamicTheme(b);
+
+ // 3. Merchant Name & Avatar
+ if (data.merchantName) {
+ const nameEl = document.getElementById('headerMerchantName');
+ if (nameEl) nameEl.textContent = data.merchantName;
+ const letterEl = document.getElementById('merchantAvatarLetter');
+ if (letterEl) letterEl.textContent = data.merchantName.charAt(0).toUpperCase();
+ }
+
+ // 4. Verified Trust Badge
+ const trustBadgeEl = document.getElementById('headerTrustBadge');
+ const trustBadgeTextEl = document.getElementById('headerTrustBadgeText');
+ if (trustBadgeEl) {
+ if (b.hideTrustBadge) {
+ trustBadgeEl.style.display = 'none';
+ } else {
+ trustBadgeEl.style.display = 'inline-flex';
+ if (trustBadgeTextEl) {
+ trustBadgeTextEl.textContent = b.trustBadgeText || `${appName} Verified Business`;
+ }
+ }
+ }
+
+ // 5. Header Sub-banner
+ const subbannerEl = document.getElementById('headerSubbanner');
+ const subbannerTextEl = document.getElementById('subbannerText');
+ if (subbannerEl) {
+ if (b.hideSubbanner) {
+ subbannerEl.style.display = 'none';
+ } else {
+ subbannerEl.style.display = 'flex';
+ if (subbannerTextEl) {
+ subbannerTextEl.textContent = b.subbannerText || b.sidebarNotice || `Verified & Protected by ${appName}`;
+ }
+ }
+ }
+
+ // 6. Time-Saving Conversion Banner
+ if (b.hideTimeSavingBanner) {
+ document.querySelectorAll('.ypg-time-saving-banner').forEach(el => el.style.setProperty('display', 'none', 'important'));
+ }
+
+
+ // Update PC Sidebar Details & Whitelabeling
+ const pcMerchant = document.getElementById('pcMerchantName');
+ if (pcMerchant) pcMerchant.textContent = data.merchantName || 'Merchant Name';
+ const pcPrice = document.getElementById('pcPriceSummaryAmount');
+ if (pcPrice && data.amount) pcPrice.textContent = `₹${data.amount}`;
+ const pcAppBrand = document.getElementById('pcAppNameBrand');
+ if (pcAppBrand) pcAppBrand.textContent = appName;
+
+ // PC Avatar Logo Whitelabel
+ const pcLogoImg = document.getElementById('pcMerchantAvatarImg');
+ const pcLetterSpan = document.getElementById('pcMerchantAvatarLetter');
+ if (b.logoUrl) {
+ if (pcLogoImg) {
+ pcLogoImg.src = b.logoUrl;
+ pcLogoImg.style.display = 'block';
+ }
+ if (pcLetterSpan) pcLetterSpan.style.display = 'none';
+ } else {
+ if (pcLogoImg) pcLogoImg.style.display = 'none';
+ if (pcLetterSpan) {
+ pcLetterSpan.style.display = 'block';
+ pcLetterSpan.textContent = (data.merchantName || 'M').charAt(0).toUpperCase();
+ }
+ }
+
+ // PC Trust Badge Whitelabel
+ const pcTrust = document.getElementById('pcTrustBadge');
+ const pcTrustText = document.getElementById('pcTrustBadgeText');
+ if (pcTrust) {
+ if (b.hideTrustBadge) {
+ pcTrust.style.display = 'none';
+ } else {
+ pcTrust.style.display = 'inline-flex';
+ if (pcTrustText) {
+ pcTrustText.textContent = b.trustBadgeText || `${appName} Trusted Business`;
+ }
+ }
+ }
+
+ // PC Social Proof / Subbanner Whitelabel
+ const pcSocialWrap = document.getElementById('pcSocialProofWrap');
+ const pcSocialProof = document.getElementById('pcSocialProofText');
+ if (pcSocialWrap) {
+ if (b.hideSubbanner) {
+ pcSocialWrap.style.display = 'none';
+ } else {
+ pcSocialWrap.style.display = 'flex';
+ if (pcSocialProof) {
+ pcSocialProof.textContent = b.subbannerText || b.sidebarNotice || `500+ orders last month from ${data.merchantName || 'Merchant'}`;
+ }
+ }
+ }
+
+ const pcCustomerText = document.getElementById('pcCustomerProfileText');
+ if (pcCustomerText) {
+ const c = data.customer || activeCustomer || (typeof getPreservedIdentity === 'function' ? getPreservedIdentity()?.customer : null);
+ if (c) {
+ const name = c.fullName || c.name || c.customerName || '';
+ const mobile = c.mobileNumber || c.phoneNumber || '';
+ const clean = mobile ? String(mobile).replace(/^\+91/, '').replace(/\D/g, '').slice(-10) : '';
+ if (name && clean) {
+ pcCustomerText.textContent = `Using as ${name} (+91 ${clean})`;
+ } else if (name) {
+ pcCustomerText.textContent = `Using as ${name}`;
+ } else if (clean) {
+ pcCustomerText.textContent = `Using as +91 ${clean}`;
+ } else if (c.email) {
+ pcCustomerText.textContent = `Using as ${c.email}`;
+ } else {
+ pcCustomerText.textContent = 'Using as Guest User';
+ }
+ } else {
+ pcCustomerText.textContent = 'Using as Guest User';
+ }
+ }
+ document.querySelectorAll('.cancelMerchantNameSpan').forEach(el => {
+ el.textContent = data.merchantName || 'Merchant';
+ });
+
+ // Update UPI Server Health Indicator (3-Tier Model: Green, Yellow, Red)
+ const serverIndicator = data.upiServerIndicator || { status: 'WORKING', tier: 'GREEN', label: 'Server Is Working', isWorking: true };
+ const healthPill = document.getElementById('upiServerHealthIndicator');
+ const healthLabel = document.getElementById('serverStatusLabel');
+ const downtimeAlert = document.getElementById('serverDowntimeAlert');
+ const downtimeHeading = document.querySelector('#serverDowntimeAlert .ypg-downtime-heading');
+ const downtimeMsg = document.getElementById('serverDowntimeMsg');
+ const btnCashAlt = document.getElementById('btnDowntimeCashAlt');
+
+ const tier = serverIndicator.tier || (serverIndicator.status === 'WORKING' ? 'GREEN' : (serverIndicator.status === 'BUSY' ? 'YELLOW' : 'RED'));
+
+ if (healthPill) {
+ if (tier === 'GREEN') {
+ healthPill.className = 'ypg-server-health-indicator is-working';
+ } else if (tier === 'YELLOW') {
+ healthPill.className = 'ypg-server-health-indicator is-busy';
+ } else {
+ healthPill.className = 'ypg-server-health-indicator is-issues';
+ }
+ }
+ if (healthLabel) {
+ healthLabel.textContent = serverIndicator.label || (tier === 'GREEN' ? 'Server Is Working' : (tier === 'YELLOW' ? 'UPI Server Busy' : 'Server Facing Issues'));
+ }
+ if (downtimeAlert) {
+ if (tier === 'GREEN') {
+ downtimeAlert.style.display = 'none';
+ } else if (tier === 'YELLOW') {
+ downtimeAlert.style.display = 'flex';
+ downtimeAlert.className = 'ypg-downtime-alert is-warning';
+ if (downtimeHeading) downtimeHeading.textContent = 'UPI Server Busy';
+ if (downtimeMsg) {
+ downtimeMsg.textContent = serverIndicator.warning || 'Your payment may go through extra processing seconds.';
+ }
+ if (btnCashAlt) {
+ btnCashAlt.style.display = (serverIndicator.recommendedAlternative === 'CASH') ? 'inline-block' : 'none';
+ }
+ } else {
+ // RED
+ downtimeAlert.style.display = 'flex';
+ downtimeAlert.className = 'ypg-downtime-alert';
+ if (downtimeHeading) downtimeHeading.textContent = 'UPI Server Facing Issues';
+ if (downtimeMsg) {
+ downtimeMsg.textContent = serverIndicator.warning || 'It is not recommended to pay by UPI right now as the server is facing downtime. We recommend paying by cash instead.';
+ }
+ if (btnCashAlt) {
+ btnCashAlt.style.display = (serverIndicator.recommendedAlternative === 'CASH') ? 'inline-block' : 'none';
+ }
+ }
+ }
+
+ // CRITICAL INVARIANT: In all 3 states (Green, Yellow, Red), ALWAYS display the dynamic UPI QR code
+ const upiCardContainer = document.querySelector('.ypg-qr-card-container');
+ if (upiCardContainer) upiCardContainer.style.display = 'flex';
+ const qrContainerBox = document.getElementById('qrImageContainer');
+ if (qrContainerBox && (!qrContainerBox.querySelector('svg') || qrContainerBox.textContent.includes('Loading QR'))) {
+ loadQrSvg();
+ }
+
+ // 7. Amount & Order IDs
+ if (data.amount) {
+ const formatted = `₹${data.amount}`;
+ const bAmt = document.getElementById('bottomAmountDisplay');
+ if (bAmt) bAmt.textContent = formatted;
+ const dAmt = document.getElementById('drawerTotalAmount');
+ if (dAmt) dAmt.textContent = formatted;
+ const sAmt = document.getElementById('successAmountVal');
+ if (sAmt) sAmt.textContent = formatted;
+ }
+ if (data.orderId || data.id) {
+ const oId = data.orderId || data.id;
+ const dOrder = document.getElementById('drawerOrderId');
+ if (dOrder) dOrder.textContent = oId;
+ const formattedOId = String(oId).startsWith('#') ? oId : `#${oId}`;
+ document.querySelectorAll('.cashierOrderIdDisplay').forEach(el => {
+ el.textContent = formattedOId;
+ });
+ }
+ // Note: Payee VPA / UPI ID is strictly hidden from customer view in all screens
+
+ // 8. In-Store Offline Counter Instructions
+ const cashNoticeEl = document.getElementById('cashCounterDeskNotice');
+ if (cashNoticeEl && b.counterInstructions) {
+ cashNoticeEl.textContent = b.counterInstructions;
+ }
+ const cardNoticeEl = document.getElementById('cardCounterDeskNotice');
+ if (cardNoticeEl && b.cardCounterInstructions) {
+ cardNoticeEl.textContent = b.cardCounterInstructions;
+ }
+
+ // 9. Dynamic Logo
+ const logoImg = document.getElementById('merchantAvatarImg');
+ const letterSpan = document.getElementById('merchantAvatarLetter');
+ if (b.logoUrl) {
+ if (logoImg) {
+ logoImg.src = b.logoUrl;
+ logoImg.style.display = 'block';
+ }
+ if (letterSpan) letterSpan.style.display = 'none';
+ } else {
+ if (logoImg) logoImg.style.display = 'none';
+ if (letterSpan) letterSpan.style.display = 'block';
+ }
+
+ // 10. Splash Screen Branding
+ const splashLogo = document.getElementById('splashBrandLogo');
+ const splashDefaultShield = document.getElementById('splashDefaultShield');
+ const splashSecuredText = document.getElementById('splashSecuredByText');
+ if (b.logoUrl && splashLogo) {
+ splashLogo.src = b.logoUrl;
+ splashLogo.style.display = 'block';
+ if (splashDefaultShield) splashDefaultShield.style.display = 'none';
+ }
+ if (splashSecuredText) {
+ splashSecuredText.textContent = b.hidePoweredBy ? (b.appName || '256-Bit Bank Encryption') : (b.appName || 'YouPI PG');
+ }
+
+ // 12. Legal Disclaimer Strip
+ const legalDisclaimerEl = document.getElementById('footerLegalDisclaimer');
+ if (legalDisclaimerEl) {
+ if (b.hidePoweredBy) {
+ legalDisclaimerEl.innerHTML = `Secured by 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;" onclick="openHelpModal()">Privacy &amp; Terms</span>`;
+ } else {
+ legalDisclaimerEl.innerHTML = `Secured by ${appName} &amp; 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;" onclick="openHelpModal()">Privacy Notice</span>`;
+ }
+ }
+
+ // 13. Success Screen Description
+ const 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.`;
+ }
+
+ // 14. Help Modal Title & Legal Links
+ const helpTitle = document.getElementById('helpModalTitle');
+ if (helpTitle) helpTitle.textContent = `${appName} Help & Support`;
+ renderHelpLegalLinks(b);
+
+ // 1. Conflict detection: single active payment session invariant
+ const conflictModal = document.getElementById('activeConflictModal');
+ if (data.hasActiveSessionConflict) {
+ hideAllContent();
+ if (conflictModal) conflictModal.hidden = false;
+ if (data.conflictingSession && data.conflictingSession.id) {
+ activeConflictSessionId = data.conflictingSession.id;
+ const desc = document.getElementById('conflictModalDesc');
+ if (desc) {
+ desc.textContent = `You already have an active payment session (#${data.conflictingSession.orderId || data.conflictingSession.id.slice(0, 8)}) for ₹${data.conflictingSession.amount}. For security, only one active payment session is allowed per customer.`;
+ }
+ }
+ if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
+ if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
+ return;
+ } else {
+ if (conflictModal) conflictModal.hidden = true;
+ }
+
+ // --- 2. TERMINAL PAYMENT STATES (TERMINAL & OVER) ---
+ if (['SUCCESS', 'CANCELLED', 'EXPIRED', 'FAILED'].includes(data.status)) {
+ if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
+ if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
+ setGatewayAuthMode(false);
+
+ if (data.status === 'CANCELLED') {
+ emitTriggerHook('CANCEL_CONFIRMED');
+ closeProcessingModal();
+ closeCancelPaymentModal();
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+
+ hideAllContent();
+ const failedView = document.getElementById('viewFailedContent');
+ if (failedView) failedView.hidden = false;
+ const footer = document.getElementById('ypgStickyFooter');
+ if (footer) footer.style.display = 'none';
+
+ const titleEl = document.getElementById('failedTitleText');
+ if (titleEl) titleEl.textContent = 'Payment Cancelled';
+ const descEl = document.getElementById('failedDescriptionText');
+ if (descEl) descEl.textContent = 'You cancelled this payment session. Click below to return to the store.';
+
+ const btnAction = document.getElementById('btnFailedAction');
+ if (btnAction) {
+ btnAction.textContent = 'Back to Store';
+ btnAction.onclick = () => {
+ const storeUrl = getStoreReturnUrl();
+ const isEmbedded = (window.parent && window.parent !== window) || location.search.includes('embedded=1');
+ if (isEmbedded) {
+ try {
+ window.parent.postMessage({ event: 'youpi.modal_close', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.close', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.cancel', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.payment_cancelled', redirectUrl: storeUrl }, '*');
+ } catch (e) {}
+ } else if (storeUrl && storeUrl !== '#' && !storeUrl.startsWith('javascript:')) {
+ window.location.href = storeUrl;
+ } else {
+ window.history.back();
+ }
+ };
+ }
+ return;
+ }
+
+ if (data.status === 'FAILED' || data.status === 'EXPIRED') {
+ closeProcessingModal();
+ closeCancelPaymentModal();
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+
+ hideAllContent();
+ const failedView = document.getElementById('viewFailedContent');
+ if (failedView) failedView.hidden = false;
+ const footer = document.getElementById('ypgStickyFooter');
+ if (footer) footer.style.display = 'none';
+ emitTriggerHook('PAYMENT_FAILED', { status: data.status });
+
+ const isExpired = data.status === 'EXPIRED';
+ const titleEl = document.getElementById('failedTitleText');
+ if (titleEl) titleEl.textContent = isExpired ? 'Payment Session Expired' : 'Payment Not Confirmed';
+ const descEl = document.getElementById('failedDescriptionText');
+ if (descEl) {
+ descEl.textContent = isExpired
+ ? 'The 5-minute active payment window elapsed before verification was completed. For security, please return to the store and initiate a new order.'
+ : 'No matching UPI bank confirmation was detected during the verification window.';
+ }
+ const btnAction = document.getElementById('btnFailedAction');
+ if (btnAction) {
+ btnAction.textContent = isExpired ? 'Start New Payment' : 'Try Again';
+ btnAction.onclick = () => retryNewPayment();
+ }
+ return;
+ }
+
+ if (data.status === 'SUCCESS') {
+ closeProcessingModal();
+ closeCancelPaymentModal();
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+
+ hideAllContent();
+ const successView = document.getElementById('viewSuccessContent');
+ if (successView) successView.hidden = false;
+ const footer = document.getElementById('ypgStickyFooter');
+ if (footer) footer.style.display = 'none';
+ const amtEl = document.getElementById('successAmountVal');
+ if (amtEl) amtEl.textContent = `₹${data.amount}`;
+
+ const isCodOrder = data.method === 'COD' || data.verificationTag === 'COD_ORDER_PLACED';
+ const titleEl = document.getElementById('successTitleText');
+ const descEl = document.getElementById('successDescText');
+ const codApiBox = document.getElementById('successCodDevApiBox');
+ const codApiUrl = document.getElementById('successCodDevApiUrl');
+
+ if (isCodOrder) {
+ if (titleEl) titleEl.textContent = 'Order Placed (Cash on Delivery)!';
+ if (descEl) descEl.textContent = `Your order #${data.orderId} was confirmed. Please keep ₹${data.amount} in cash ready for the courier agent upon arrival.`;
+ if (codApiBox && codApiUrl) {
+ codApiBox.style.display = 'block';
+ codApiUrl.textContent = `${API_BASE}/api/v1/orders/${data.orderId}/cod`;
+ }
+ } else {
+ if (titleEl) titleEl.textContent = 'Payment Successful!';
+ if (descEl) descEl.textContent = 'Your payment was automatically verified by YouPI PG banking observers.';
+ if (codApiBox) codApiBox.style.display = 'none';
+ }
+
+ emitTriggerHook('PAYMENT_COMPLETED', { amount: data.amount, method: data.method, isCod: isCodOrder });
+
+ try {
+ window.parent.postMessage({
+ event: 'youpi.payment_success',
+ data: data
+ }, '*');
+ } catch (e) { }
+
+ const btnReturn = document.getElementById('btnReturnStore') || document.getElementById('btnReturnToStore');
+ if (btnReturn && data.returnUrl) {
+ btnReturn.hidden = false;
+ btnReturn.href = data.returnUrl;
+ if (window.parent === window) {
+ setTimeout(() => { window.location.href = data.returnUrl; }, 2000);
+ }
+ } else if (btnReturn) {
+ btnReturn.hidden = true;
+ }
+ return;
+ }
+ }
+
+ // Sync payment methods & modality layout immediately to match merchant settings
+ renderMethodSelectorBar(data);
+
+ // Auto-bind customer to payment session helper
+ if (typeof autoBindCustomerToSession !== 'function') {
+ window.autoBindCustomerToSession = async function(customerId, token) {
+ if (window.isAutoBindingSession || !PAYMENT_ID || !token || !customerId) return;
+ window.isAutoBindingSession = true;
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/bind-customer`, {
+ method: 'POST',
+ headers: getApiHeaders({
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${token}`
+ }),
+ body: JSON.stringify({ token, customerId })
+ });
+ if (res.ok) {
+ const boundData = await res.json().catch(() => null);
+ if (boundData && boundData.status && boundData.status !== 'INITIATED') {
+ loadState();
+ }
+ } else if (res.status === 401) {
+ clearPreservedIdentity();
+ activeCustomer = null;
+ activeToken = null;
+ setGatewayAuthMode(true);
+ goToAuthStep('mobile');
+ renderSavedAccountsUI();
+ }
+ } catch (e) {
+ } finally {
+ window.isAutoBindingSession = false;
+ }
+ };
+ }
+
+ // 3. Pre-Gateway Customer Authentication Gate (Preserves identity up to 1 week)
+ if (data.customer) {
+ activeCustomer = data.customer;
+ } else if (!activeCustomer) {
+ const preserved = getPreservedIdentity();
+ if (preserved && preserved.customer) {
+ activeCustomer = preserved.customer;
+ activeToken = preserved.token || activeToken;
+ }
+ }
+ const hasCustomer = Boolean(data.customer || activeCustomer);
+
+ if (!hasCustomer) {
+ setGatewayAuthMode(true);
+ const stepMob = document.getElementById('authStepMobile');
+ const isAlreadyOnMobile = stepMob && !stepMob.hidden;
+ if (!currentAuthStep || (currentAuthStep === 'mobile' && !isAlreadyOnMobile)) {
+ goToAuthStep('mobile');
+ }
+ renderSavedAccountsUI();
+ return;
+ }
+
+ // Authenticated Customer
+ if (activeCustomer) {
+ updateCustomerDisplay(activeCustomer);
+ // Automatically bind customer to the payment session if session is INITIATED or unbound
+ if (activeToken && PAYMENT_ID && (!data.customer || data.status === 'INITIATED')) {
+ window.autoBindCustomerToSession(activeCustomer.id, activeToken);
+ }
+ }
+ setGatewayAuthMode(false);
+
+ // Render psychological time-saving conversion banner
+ renderTimeSavingBanners(data);
+
+ // 3. Status Handling: BLOCKED, QUEUED, ACTIVE, PROCESSING, SUCCESS, FAILED, EXPIRED
+ if (data.status === 'BLOCKED' || data.isBanned || data.fraudDetected) {
+ renderBlockedState(data);
+ return;
+ }
+
+ if (data.status === 'QUEUED') {
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+
+ hideAllContent();
+ document.getElementById('viewQueuedContent').hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ document.getElementById('queueNumberDisplay').textContent = `#${data.queuePosition || 1}`;
+ runCountdown(data.timeRemainingSeconds, sec => {
+ document.getElementById('queueTimerText').textContent = formatTime(sec);
+ }, () => loadState());
+
+ if (!queuePollTimer) {
+ queuePollTimer = setInterval(() => { loadState(); }, 1200);
+ }
+ return;
+ }
+
+ if (queuePollTimer) {
+ clearInterval(queuePollTimer);
+ queuePollTimer = null;
+ }
+
+ if (data.status === 'ACTIVE' || (data.status === 'INITIATED' && (data.timeRemainingSeconds > 0 || data.expiresAt))) {
+ renderMethodSelectorBar(data);
+
+ hideAllContent();
+ if (currentSelectedMethod === 'COD') {
+ const vCod = document.getElementById('viewCodContent');
+ if (vCod) vCod.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+
+ runCountdown(data.timeRemainingSeconds || 300, sec => {
+ const el = document.getElementById('codTimerText');
+ if (el) el.textContent = formatTime(sec);
+ }, () => {
+ const el = document.getElementById('codTimerText');
+ if (el) el.textContent = 'Expired';
+ fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
+ loadState();
+ }, data.expiresAt);
+ } else if (currentSelectedMethod === 'CASH_COUNTER') {
+ const vCash = document.getElementById('viewCashContent');
+ if (vCash) vCash.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ } else if (currentSelectedMethod === 'CARD_COUNTER') {
+ const vCard = document.getElementById('viewCardContent');
+ if (vCard) vCard.hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ } else {
+ // Default: UPI QR (CRITICAL INVARIANT: ALWAYS SHOWS QR AND RUNS 5:00 TIMER REGARDLESS OF GREEN/YELLOW/RED)
+ document.getElementById('viewUpiContent').hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'flex';
+ loadQrSvg();
+
+ const btnContinue = document.getElementById('btnContinuePayment');
+
+ const remainingSec = (data.timeRemainingSeconds !== undefined && data.timeRemainingSeconds !== null) ? Number(data.timeRemainingSeconds) : 300;
+ const targetExpiry = data.expiresAt || new Date(Date.now() + remainingSec * 1000).toISOString();
+
+ if (remainingSec <= 0 && data.status === 'ACTIVE') {
+ const tText = document.getElementById('activeTimerText');
+ if (tText) tText.textContent = 'Expired';
+ if (btnContinue) btnContinue.style.display = 'none';
+ return;
+ }
+
+ // Initialize button hidden until 4:00 has elapsed
+ if (btnContinue && remainingSec > 240) {
+ btnContinue.style.display = 'none';
+ } else if (btnContinue) {
+ btnContinue.style.display = 'block';
+ }
+
+ runCountdown(remainingSec, sec => {
+ const tText = document.getElementById('activeTimerText');
+ if (tText) tText.textContent = formatTime(sec);
+
+ // "Payment Done — Check My Payment" button appears after 4:00
+ if (sec <= 240 && btnContinue) {
+ btnContinue.style.display = 'block';
+ } else if (btnContinue) {
+ btnContinue.style.display = 'none';
+ }
+ }, () => {
+ const tText = document.getElementById('activeTimerText');
+ if (tText) tText.textContent = 'Expired';
+ if (btnContinue) btnContinue.style.display = 'none';
+ closeProcessingModal();
+ fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
+ loadState();
+ }, targetExpiry);
+ }
+ return;
+ }
+
+ if (data.status === 'PROCESSING') {
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+
+ hideAllContent();
+ document.getElementById('viewProcessingContent').hidden = false;
+ document.getElementById('ypgStickyFooter').style.display = 'none';
+ runCountdown(data.timeRemainingSeconds, sec => {
+ document.getElementById('procTimerText').textContent = `${sec}s`;
+ }, () => loadState(), data.expiresAt);
+ return;
+ }
+
+
+ }
+
+ // --- PSYCHOLOGICAL TIME-SAVING CONVERSION BANNER ---
+ // Invariant: ONLY display when the customer is actively waiting in the UPI queue!
+ function renderTimeSavingBanners(data) {
+ const qBanner = document.getElementById('queueTimeSavingBanner');
+ const uBanner = document.getElementById('upiTimeSavingBanner');
+ if (uBanner) uBanner.style.display = 'none'; // NEVER show on active UPI session
+
+ const isQueued = (data.status === 'QUEUED') || (Number(data.queuePosition || 0) > 0);
+ if (!isQueued || !qBanner) {
+ if (qBanner) qBanner.style.display = 'none';
+ return;
+ }
+
+ const enabled = data.enabledMethods || ['UPI'];
+ const sellingMode = data.sellingMode || 'OFFLINE';
+
+ let altMethodCode = null;
+ let altMethodName = null;
+
+ if (sellingMode === 'ONLINE') {
+ if (enabled.includes('COD')) {
+ altMethodCode = 'COD';
+ altMethodName = 'Cash on Delivery';
+ } else if (enabled.includes('CARD')) {
+ altMethodCode = 'CARD';
+ altMethodName = 'Credit / Debit Card';
+ } else if (enabled.includes('NETBANKING')) {
+ altMethodCode = 'NETBANKING';
+ altMethodName = 'Net Banking';
+ } else if (enabled.includes('CARD_COUNTER')) {
+ altMethodCode = 'CARD_COUNTER';
+ altMethodName = 'Card Payment';
+ }
+ } else {
+ // Offline selling mode (retail till / counter)
+ if (enabled.includes('CASH_COUNTER')) {
+ altMethodCode = 'CASH_COUNTER';
+ altMethodName = 'Cash at Till';
+ } else if (enabled.includes('CARD_COUNTER')) {
+ altMethodCode = 'CARD_COUNTER';
+ altMethodName = 'Card at Counter';
+ }
+ }
+
+ // CRITICAL REQUIREMENT: If both cash and card are disabled by merchant, psychological conversion MUST NOT BE SHOWN!
+ if (!altMethodCode || (!enabled.includes('COD') && !enabled.includes('CASH_COUNTER') && !enabled.includes('CARD') && !enabled.includes('CARD_COUNTER'))) {
+ qBanner.style.display = 'none';
+ return;
+ }
+
+ const timeSec = data.timeRemainingSeconds || (data.queuePosition ? data.queuePosition * 30 : 30);
+ const initialTimerStr = formatTime(timeSec);
+
+ const actionText = sellingMode === 'ONLINE'
+ ? `Skip the UPI wait! Pay with <strong>${altMethodName}</strong> instantly without waiting for a UPI slot.`
+ : `Don't wait in the UPI line! Pay with <strong>${altMethodName}</strong> right now to complete your purchase instantly.`;
+
+ qBanner.innerHTML = `
+ <div class="ypg-queue-conversion-card">
+ <div class="ypg-queue-conversion-header">
+ <div class="ypg-queue-conversion-badge"><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" style="display:inline-block; vertical-align:middle; margin-right:3px;"><path d="M12 2l2.4 7.2h7.6l-6 4.8 2.4 7.2-6.4-4.8-6.4 4.8 2.4-7.2-6-4.8h7.6z"/></svg>Instant Alternative</div>
+ <div class="ypg-queue-conversion-pill">Save <span class="ypg-banner-running-timer">${initialTimerStr}</span></div>
+ </div>
+ <div class="ypg-queue-conversion-text">
+ ${actionText}
+ </div>
+ <button type="button" class="ypg-btn-queue-switch" onclick="selectPaymentMethod('${altMethodCode}')">
+ <span>Pay with ${altMethodName}</span>
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="9 18 15 12 9 6"/></svg>
+ </button>
+ </div>
+ `;
+ qBanner.style.display = 'block';
+ }
+
+ // --- PURE QR SVG LOADER (ALWAYS LOADS & SHOWS QR CODE REGARDLESS OF SERVER STATUS) ---
+ async function loadQrSvg() {
+ const container = document.getElementById('qrImageContainer');
+ if (!container) return;
+ try {
+ const res = await fetch(`/checkout/${PAYMENT_ID}/qr.svg`);
+ if (res.ok) {
+ const svg = await res.text();
+ if (svg && svg.includes('<svg')) {
+ container.innerHTML = svg;
+ return;
+ }
+ }
+ } catch (e) {
+ console.warn('loadQrSvg error:', e);
+ }
+ // Automatic retry to guarantee QR code is loaded
+ setTimeout(async () => {
+ try {
+ const res = await fetch(`/checkout/${PAYMENT_ID}/qr.svg`);
+ if (res.ok) {
+ const svg = await res.text();
+ if (svg && svg.includes('<svg')) {
+ container.innerHTML = svg;
+ }
+ }
+ } catch (e) {}
+ }, 400);
+ }
+
+ function copyVpaId() {
+ const vpa = (state?.payeeVpa || document.getElementById('displayVpaVal')?.textContent || '').trim();
+ if (!vpa) return;
+
+ const btn = document.getElementById('btnCopyVpa');
+ const text = document.getElementById('copyVpaText');
+ if (btn && text) {
+ navigator.clipboard.writeText(vpa).then(() => {
+ text.textContent = 'Copied!';
+ btn.classList.add('copied');
+ setTimeout(() => {
+ text.textContent = 'Copy';
+ btn.classList.remove('copied');
+ }, 2000);
+ }).catch(() => {
+ text.textContent = 'Copied!';
+ setTimeout(() => { text.textContent = 'Copy'; }, 2000);
+ });
+ }
+ }
+
+ // --- RAZORPAY AUTHENTIC "PROCESSING YOUR PAYMENT" MODAL SHEET ---
+ function openProcessingModal(title = 'Processing your payment', subtitle = 'This will only take a few seconds.') {
+ const modal = document.getElementById('rzpProcessingModal');
+ const tEl = document.getElementById('rzpProcessingTitle');
+ const sEl = document.getElementById('rzpProcessingSubtitle');
+ if (tEl) tEl.textContent = title;
+ if (sEl) sEl.textContent = subtitle;
+ if (modal) {
+ modal.hidden = false;
+ requestAnimationFrame(() => modal.classList.add('active'));
+ }
+ }
+
+ function closeProcessingModal() {
+ const modal = document.getElementById('rzpProcessingModal');
+ if (modal) {
+ modal.classList.remove('active');
+ setTimeout(() => { modal.hidden = true; }, 300);
+ }
+ }
+
+ // --- RAZORPAY AUTHENTIC "CANCEL PAYMENT" CONFIRMATION MODAL SHEET ---
+ function openCancelPaymentModal() {
+ emitTriggerHook('CANCEL_CLICKED');
+ document.body.style.overflow = 'hidden';
+ const yBody = document.querySelector('.ypg-body');
+ if (yBody) yBody.style.overflow = 'hidden';
+
+ const modal = document.getElementById('rzpCancelModal');
+ const promptView = document.getElementById('rzpCancelPromptView');
+ const progressView = document.getElementById('rzpCancellingProgressView');
+ if (promptView) promptView.style.display = 'flex';
+ if (progressView) progressView.style.display = 'none';
+ if (modal) {
+ modal.hidden = false;
+ requestAnimationFrame(() => modal.classList.add('active'));
+ }
+ }
+
+ function closeCancelPaymentModal() {
+ document.body.style.overflow = '';
+ const yBody = document.querySelector('.ypg-body');
+ if (yBody) yBody.style.overflow = '';
+
+ const modal = document.getElementById('rzpCancelModal');
+ if (modal) {
+ modal.classList.remove('active');
+ setTimeout(() => { modal.hidden = true; }, 300);
+ }
+ }
+
+ async function confirmCancelPayment() {
+ emitTriggerHook('CANCEL_CONFIRMED');
+ if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
+ if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
+
+ const promptView = document.getElementById('rzpCancelPromptView');
+ const progressView = document.getElementById('rzpCancellingProgressView');
+ if (promptView) promptView.style.display = 'none';
+ if (progressView) progressView.style.display = 'flex';
+
+ try {
+ await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/cancel`, {
+ method: 'POST',
+ headers: getApiHeaders()
+ });
+ } catch (e) { }
+
+ // Smooth realistic delay matching Razorpay transition
+ setTimeout(() => {
+ document.body.style.overflow = '';
+ const yBody = document.querySelector('.ypg-body');
+ if (yBody) yBody.style.overflow = '';
+
+ closeCancelPaymentModal();
+ closeProcessingModal();
+
+ const storeUrl = getStoreReturnUrl();
+ const isEmbedded = (window.parent && window.parent !== window) || location.search.includes('embedded=1');
+
+ if (isEmbedded) {
+ try {
+ window.parent.postMessage({ event: 'youpi.modal_close', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.close', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.cancel', redirectUrl: storeUrl }, '*');
+ window.parent.postMessage({ event: 'youpi.payment_cancelled', redirectUrl: storeUrl }, '*');
+ } catch (e) { }
+ }
+
+ loadState();
+ }, 500);
+ }
+
+ // Direct invocation from header back button, close button, or inline links
+ function cancelPayment() {
+ openCancelPaymentModal();
+ }
+
+ // Listen for cancel requests from parent iframe cross button
+ window.addEventListener('message', (e) => {
+ if (e.data && e.data.event === 'youpi.request_cancel') {
+ openCancelPaymentModal();
+ }
+ });
+
+ // --- MANUAL PAYMENT DONE VERIFICATION ---
+ async function submitPaymentDone() {
+ openProcessingModal('Processing your payment', 'This will only take a few seconds.');
+ emitTriggerHook('PAYMENT_DONE_CLICKED');
+
+ try {
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/payment-done`, {
+ method: 'POST'
+ });
+ if (res.ok) {
+ loadState();
+ }
+ } catch (e) { }
+ }
+
+ // --- SINGLE ACTIVE PAYMENT SESSION CONFLICT RESOLUTION ---
+ let activeConflictSessionId = null;
+
+ async function executeRetryNewPayment() {
+ try {
+ const btn = document.getElementById('btnEndSessionAndStartNew');
+ if (btn) {
+ btn.disabled = true;
+ btn.textContent = 'Activating new payment...';
+ }
+ const headers = { 'Content-Type': 'application/json' };
+ if (typeof DeviceIdentity !== 'undefined') {
+ if (DeviceIdentity.currentDeviceId) headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
+ if (DeviceIdentity.currentDeviceToken) headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
+ }
+ const token = activeToken || localStorage.getItem('ypg_customer_token');
+ if (token) {
+ headers['Authorization'] = `Bearer ${token}`;
+ headers['x-customer-token'] = token;
+ }
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/retry-new-payment`, {
+ method: 'POST',
+ headers
+ });
+ if (res.ok) {
+ const conflictModal = document.getElementById('activeConflictModal');
+ if (conflictModal) conflictModal.hidden = true;
+ await loadState();
+ } else {
+ const err = await res.json().catch(() => ({}));
+ alert(err.error || 'Failed to retry payment');
+ if (btn) {
+ btn.disabled = false;
+ btn.textContent = 'END SESSION & START NEW PAYMENT';
+ }
+ }
+ } catch (e) {
+ alert('Network error while retrying payment');
+ const btn = document.getElementById('btnEndSessionAndStartNew');
+ if (btn) {
+ btn.disabled = false;
+ btn.textContent = 'END SESSION & START NEW PAYMENT';
+ }
+ }
+ }
+
+ function continueExistingActivePayment() {
+ if (activeConflictSessionId) {
+ window.location.href = `/checkout/${activeConflictSessionId}`;
+ } else {
+ const conflictModal = document.getElementById('activeConflictModal');
+ if (conflictModal) conflictModal.hidden = true;
+ loadState();
+ }
+ }
+
+
+
+ function renderBlockedState(data) {
+ closeProcessingModal();
+ closeCancelPaymentModal();
+ if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
+ if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
+
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+ const footer = document.getElementById('ypgStickyFooter');
+ if (footer) footer.style.display = 'none';
+
+ hideAllContent();
+ const vBlocked = document.getElementById('viewBlockedContent');
+ if (vBlocked) vBlocked.hidden = false;
+
+ // Expand to full width on PC desktop split view
+ const pcMethodsList = document.getElementById('pcMethodsList');
+ if (pcMethodsList) pcMethodsList.style.setProperty('display', 'none', 'important');
+ const pcActiveView = document.querySelector('.ypg-pc-active-view');
+ if (pcActiveView) pcActiveView.style.width = '100%';
+ const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
+ if (pcTopbarTitle) pcTopbarTitle.textContent = 'Security Incident Investigation';
+
+ const orderRef = data.orderId || state?.orderId || 'N/A';
+ const orderEl = document.getElementById('blockedOrderRefVal');
+ if (orderEl) orderEl.textContent = `#${orderRef}`;
+
+ const sessEl = document.getElementById('blockedSessionIdVal');
+ if (sessEl) sessEl.textContent = data.id || PAYMENT_ID || 'N/A';
+
+ const timeEl = document.getElementById('blockedTimestampVal');
+ if (timeEl) timeEl.textContent = new Date().toLocaleTimeString();
+
+ if (data.blockedNotice?.title) {
+ const titleEl = document.getElementById('blockedTitleText');
+ if (titleEl) titleEl.textContent = data.blockedNotice.title;
+ }
+ if (data.blockedNotice?.subtitle) {
+ const subEl = document.getElementById('blockedSubtitleText');
+ if (subEl) subEl.textContent = data.blockedNotice.subtitle;
+ }
+ if (data.blockedNotice?.message) {
+ const msgEl = document.getElementById('blockedNoticeText');
+ if (msgEl) msgEl.textContent = data.blockedNotice.message;
+ }
+
+ emitTriggerHook('PAYMENT_BLOCKED', {
+ reason: data.reason || data.blockedNotice?.reason || 'FRAUDULENT_PAYMENT_INJECTION',
+ orderId: orderRef
+ });
+
+ try {
+ window.parent.postMessage({
+ event: 'youpi.payment_blocked',
+ data: {
+ status: 'BLOCKED',
+ isBanned: true,
+ orderId: orderRef,
+ paymentId: data.id || PAYMENT_ID
+ }
+ }, '*');
+ } catch (e) {}
+ }
+
+ function handleBlockedExit() {
+ const failRedirectUrl = getFailedRedirectUrl();
+ if (window.parent && window.parent !== window) {
+ try {
+ window.parent.postMessage({
+ event: 'youpi.payment_blocked_exit',
+ data: { status: 'BLOCKED', isBanned: true, orderId: state?.orderId }
+ }, '*');
+ } catch (e) {}
+ }
+ window.location.href = failRedirectUrl;
+ }
+
+ let lastDuplicateSessionPayload = null;
+ function renderDuplicateSession(data) {
+ lastDuplicateSessionPayload = data;
+ if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
+ if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
+ if (sse) { try { sse.close(); } catch(e){} sse = null; }
+
+ const bar = document.getElementById('paymentMethodSelectorBar');
+ if (bar) bar.style.display = 'none';
+ const footer = document.getElementById('ypgStickyFooter');
+ if (footer) footer.style.display = 'none';
+
+ hideAllContent();
+ const vDup = document.getElementById('viewDuplicateSessionContent');
+ if (vDup) vDup.hidden = false;
+
+ // Expand to full width on PC desktop split view
+ const pcMethodsList = document.getElementById('pcMethodsList');
+ if (pcMethodsList) pcMethodsList.style.setProperty('display', 'none', 'important');
+ const pcActiveView = document.querySelector('.ypg-pc-active-view');
+ if (pcActiveView) pcActiveView.style.width = '100%';
+ const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
+ if (pcTopbarTitle) pcTopbarTitle.textContent = 'Device Security Verification';
+
+ emitTriggerHook('DUPLICATE_SESSION_DETECTED', {
+ sessionId: data.session_id || PAYMENT_ID,
+ action: 'END_SESSION_AND_CREATE_NEW'
+ });
+ }
+
+ async function handleEndAndStartNewPayment() {
+ const btn = document.getElementById('btnEndAndRestartPayment');
+ if (btn) {
+ btn.disabled = true;
+ btn.innerHTML = '<span class="ypg-spinner" style="display:inline-block;width:15px;height:15px;border:2px solid #fff;border-top-color:transparent;border-radius:50%;animation:rzpRotate 0.8s linear infinite;margin-right:8px;vertical-align:middle;"></span> CREATING NEW PAYMENT...';
+ }
+
+ try {
+ await DeviceIdentity.getOrRegister();
+ const headers = { 'Content-Type': 'application/json' };
+ if (DeviceIdentity.currentDeviceId) {
+ headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
+ }
+ if (DeviceIdentity.currentDeviceToken) {
+ headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
+ }
+
+ const conflictingSessionId = lastDuplicateSessionPayload?.conflicting_session_id || activeConflictSessionId || null;
+
+ const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/end-and-restart-payment`, {
+ method: 'POST',
+ headers,
+ body: JSON.stringify({
+ deviceId: DeviceIdentity.currentDeviceId,
+ conflictingSessionId
+ })
+ });
+
+ const data = await res.json();
+ if (data.success && (data.checkoutUrl || data.newSessionId)) {
+ const targetUrl = data.checkoutUrl || `/checkout/${data.newSessionId}`;
+ window.location.href = targetUrl;
+ } else {
+ alert(data.error || 'Failed to start new payment session. Please try again.');
+ if (btn) {
+ btn.disabled = false;
+ btn.innerHTML = '<span>END SESSION &amp; START NEW PAYMENT</span>';
+ }
+ }
+ } catch (err) {
+ alert('Network error while starting new payment session.');
+ if (btn) {
+ btn.disabled = false;
+ btn.innerHTML = '<span>END SESSION &amp; START NEW PAYMENT</span>';
+ }
+ }
+ }
+
+ // --- SSE REALTIME STREAM (AUTOMATIC OBSERVER & CASHIER INTEGRATION) ---
+ function connectSse() {
+ if (sse) {
+ try { sse.close(); } catch (e) { }
+ sse = null;
+ }
+
+ try {
+ const devQuery = DeviceIdentity.currentDeviceId ? `?deviceId=${encodeURIComponent(DeviceIdentity.currentDeviceId)}` : '';
+ const streamUrl = `${API_BASE}/api/v1/checkout/${PAYMENT_ID}/stream${devQuery}`;
+ sse = new EventSource(streamUrl);
+
+ const handleRealtimePayload = (event) => {
+ try {
+ const data = JSON.parse(event.data);
+ if (data && (data.error === 'DUPLICATE_SESSION_DETECTED' || data.type === 'DUPLICATE_SESSION_DETECTED')) {
+ renderDuplicateSession(data);
+ } else if (data && (data.status === 'BLOCKED' || data.isBanned || data.fraudDetected || data.type === 'FRAUD_BLOCKED' || data.event === 'account_blocked')) {
+ renderBlockedState(data);
+ } else if (data && data.type === 'STATE_CHANGE' && data.payload) {
+ renderState(data.payload);
+ } else if (data && data.status) {
+ if (data.status === 'BLOCKED' || data.isBanned) {
+ renderBlockedState(data);
+ } else {
+ loadState();
+ }
+ } else {
+ loadState();
+ }
+ } catch (e) {
+ loadState();
+ }
+ };
+
+ sse.onmessage = handleRealtimePayload;
+ sse.addEventListener('status_change', handleRealtimePayload);
+ sse.addEventListener('state_change', handleRealtimePayload);
+ sse.addEventListener('account_blocked', handleRealtimePayload);
+ sse.addEventListener('fraud_detected', handleRealtimePayload);
+ sse.addEventListener('counter_payment_confirmed', handleRealtimePayload);
+ sse.addEventListener('counter_payment_declined', handleRealtimePayload);
+ sse.addEventListener('payment_success', handleRealtimePayload);
+ sse.addEventListener('queue_cleared', handleRealtimePayload);
+ sse.addEventListener('session_expired', handleRealtimePayload);
+
+ sse.onerror = () => {
+ if (sse) {
+ try { sse.close(); } catch (e) { }
+ sse = null;
+ }
+ setTimeout(connectSse, 3000);
+ };
+ } catch (e) {
+ setTimeout(connectSse, 3000);
+ }
+ }
+
+ // Continuous 2-second fallback polling: guarantees instant response when cashier confirms/declines or queues clear
+ setInterval(() => {
+ if (state && (state.status === 'SUCCESS' || state.status === 'FAILED' || state.status === 'EXPIRED' || state.status === 'BLOCKED' || state.isBanned)) {
+ return;
+ }
+ loadState();
+ }, 2000);
+
+ // --- SUPPORT / HELP MODAL ---
+ function openHelpModal() {
+ document.getElementById('helpModal').hidden = false;
+ const popoverMobile = document.getElementById('accountMenuPopover');
+ if (popoverMobile) { popoverMobile.setAttribute('hidden', ''); popoverMobile.hidden = true; popoverMobile.style.display = 'none'; }
+ const popoverPc = document.getElementById('accountMenuPopoverPc');
+ if (popoverPc) { popoverPc.setAttribute('hidden', ''); popoverPc.hidden = true; popoverPc.style.display = 'none'; }
+
+ const branding = state?.branding || {};
+ renderSupportInfo({
+ supportEmails: branding.supportEmails || (branding.supportEmail ? [branding.supportEmail] : []),
+ supportMobiles: branding.supportMobiles || (branding.supportMobile ? [branding.supportMobile] : [])
+ });
+ }
+
+ function renderSupportInfo(info) {
+ const emailBox = document.getElementById('helpModalEmailsContainer');
+ const phoneBox = document.getElementById('helpModalMobilesContainer');
+ const caseBox = document.getElementById('helpModalCaseInfoText');
+
+ if (emailBox && info.supportEmails) {
+ emailBox.innerHTML = `<strong>Email:</strong> ${info.supportEmails.join(', ')}`;
+ }
+ if (phoneBox && info.supportMobiles) {
+ phoneBox.innerHTML = `<strong>Phone:</strong> ${info.supportMobiles.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'}`;
+ }
+ }
+
+ function closeHelpModal() {
+ document.getElementById('helpModal').hidden = true;
+ }
+
+ function copyCaseInfo() {
+ const text = document.getElementById('helpModalCaseInfoText').textContent;
+ navigator.clipboard.writeText(text).then(() => {
+ document.getElementById('copyCaseText').textContent = 'Copied to Clipboard!';
+ setTimeout(() => {
+ document.getElementById('copyCaseText').textContent = 'Copy Payment Case Details';
+ }, 2000);
+ });
+ }
+
+ // WhatsApp OTP Input Keyboard Listeners
+ const mobIn = document.getElementById('authMobileInput');
+ if (mobIn) {
+ mobIn.addEventListener('input', (e) => {
+ const clean = e.target.value.replace(/\D/g, '').slice(0, 10);
+ if (e.target.value !== clean) {
+ e.target.value = clean;
+ }
+ currentAuthMobile = clean;
+ });
+ mobIn.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ handleAuthMobileSubmit();
+ }
+ });
+ }
+
+ const nameIn = document.getElementById('authSignupName');
+ const emailIn = document.getElementById('authSignupEmail');
+ if (nameIn) {
+ nameIn.addEventListener('input', (e) => {
+ currentAuthName = e.target.value;
+ });
+ nameIn.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ emailIn?.focus();
+ }
+ });
+ }
+ if (emailIn) {
+ emailIn.addEventListener('input', (e) => {
+ currentAuthEmail = e.target.value;
+ });
+ emailIn.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ handleAuthSignupSubmit();
+ }
+ });
+ }
+
+ const otpIn = document.getElementById('authOtpInput');
+ if (otpIn) {
+ otpIn.addEventListener('input', (e) => {
+ const val = e.target.value.replace(/\D/g, '');
+ e.target.value = val;
+ if (val.length === 6) {
+ handleAuthVerifyOtpSubmit();
+ }
+ });
+ otpIn.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ handleAuthVerifyOtpSubmit();
+ }
+ });
+ }
+
+ // Boot checkout - restore preserved 1-week identity if available
+ const bootPreserved = getPreservedIdentity();
+ if (bootPreserved && bootPreserved.customer) {
+ activeCustomer = bootPreserved.customer;
+ activeToken = bootPreserved.token || localStorage.getItem('ypg_customer_token') || null;
+ updateCustomerDisplay(activeCustomer);
+ } else {
+ activeCustomer = null;
+ activeToken = null;
+ }
+
+ try {
+ const initEl = document.getElementById('ypgInitialState');
+ if (initEl && initEl.textContent && initEl.textContent.trim()) {
+ const parsed = JSON.parse(initEl.textContent);
+ if (parsed && (parsed.amount || parsed.branding || parsed.merchantName)) {
+ renderState(parsed);
+ }
+ }
+ } catch (e) { }
+
+ loadState();
+ connectSse();
\ No newline at end of file
diff --git a/apps/checkout-portal/src/__tests__/checkout-portal.test.js b/apps/checkout-portal/src/__tests__/checkout-portal.test.js
index c5b8d72..3f36089 100644
--- a/apps/checkout-portal/src/__tests__/checkout-portal.test.js
+++ b/apps/checkout-portal/src/__tests__/checkout-portal.test.js
@@ -2,7 +2,7 @@ import { test, describe, before, after } from 'node:test';
import assert from 'node:assert/strict';
import http from 'node:http';
import { startCheckoutServer } from '../index.js';
-import { generateQrMatrix, generateQrSvg } from '../qr.js';
+import { generateQrMatrix, generateQrSvg } from '@youpi/core';
describe('Checkout Portal Integration Tests', () => {
let serverInstance;
@@ -143,5 +143,17 @@ describe('Checkout Portal Integration Tests', () => {
// INVARIANT: Raw Payee VPA / UPI ID row is REMOVED from Order Summary
assert.equal(res.text.includes('id="drawerVpa"'), false);
});
+
+ test('GET /css/checkout.css and /js/checkout.js return static modular assets with CORS', async () => {
+ const resCss = await get('/css/checkout.css');
+ assert.equal(resCss.status, 200);
+ assert.ok(resCss.headers['content-type'].includes('text/css'));
+ assert.ok(resCss.text.includes('.ypg-wrapper'));
+
+ const resJs = await get('/js/checkout.js');
+ assert.equal(resJs.status, 200);
+ assert.ok(resJs.headers['content-type'].includes('application/javascript'));
+ assert.ok(resJs.text.includes('STORAGE_KEY_IDENTITY'));
+ });
});
});
diff --git a/apps/checkout-portal/src/server.js b/apps/checkout-portal/src/server.js
index 4fa3e9f..563de9a 100644
--- a/apps/checkout-portal/src/server.js
+++ b/apps/checkout-portal/src/server.js
@@ -97,12 +97,27 @@ export class CheckoutServer {
}
}
- renderHtml(paymentId, state) {
+ loadTemplateWithPartials() {
try {
- this.template = fs.readFileSync(this.htmlTemplatePath, 'utf8');
- } catch {}
+ let content = fs.readFileSync(this.htmlTemplatePath, 'utf8');
+ const partialsDir = path.resolve(__dirname, 'views', 'partials');
+ content = content.replace(/<!--\s*include:partials\/([a-zA-Z0-9_\-.]+)\s*-->/g, (match, filename) => {
+ try {
+ const partialPath = path.resolve(partialsDir, filename);
+ if (partialPath.startsWith(partialsDir) && fs.existsSync(partialPath)) {
+ return fs.readFileSync(partialPath, 'utf8');
+ }
+ } catch {}
+ return match;
+ });
+ return content;
+ } catch {
+ return this.template || '';
+ }
+ }
- let html = this.template;
+ renderHtml(paymentId, state) {
+ let html = this.loadTemplateWithPartials();
const appName = state?.branding?.appName || 'YouPI PG';
const primaryColor = state?.branding?.primaryColor || '#0b63e5';
@@ -243,11 +258,14 @@ export class CheckoutServer {
return;
}
- // Static icons: GET /icons/:filename
+ // Static icons: GET /icons/:filename with path traversal protection
if (pathname.startsWith('/icons/')) {
const iconName = path.basename(pathname);
- const iconPath = path.join(__dirname, '..', 'public', 'icons', iconName);
- if (fs.existsSync(iconPath)) {
+ const iconDir = path.resolve(__dirname, '..', 'public', 'icons');
+ const iconPath = path.resolve(iconDir, iconName);
+ const relative = path.relative(iconDir, iconPath);
+ const isSecure = relative && !relative.startsWith('..') && !path.isAbsolute(relative);
+ if (isSecure && fs.existsSync(iconPath)) {
const ext = path.extname(iconName).toLowerCase();
const contentType = ext === '.png' ? 'image/png' : ext === '.svg' ? 'image/svg+xml' : 'image/jpeg';
res.writeHead(200, {
@@ -260,6 +278,28 @@ export class CheckoutServer {
}
}
+ // Static CSS & JS Asset Handler with Secure Path Traversal Prevention
+ if (pathname.startsWith('/css/') || pathname.startsWith('/js/')) {
+ const assetFolder = pathname.startsWith('/css/') ? 'css' : 'js';
+ const assetName = path.basename(pathname);
+ const assetDir = path.resolve(__dirname, '..', 'public', assetFolder);
+ const assetPath = path.resolve(assetDir, assetName);
+
+ const relative = path.relative(assetDir, assetPath);
+ const isSecure = relative && !relative.startsWith('..') && !path.isAbsolute(relative);
+
+ if (isSecure && fs.existsSync(assetPath)) {
+ const contentType = assetFolder === 'css' ? 'text/css; charset=utf-8' : 'application/javascript; charset=utf-8';
+ res.writeHead(200, {
+ 'Content-Type': contentType,
+ 'Cache-Control': 'public, max-age=86400',
+ 'Access-Control-Allow-Origin': '*'
+ });
+ fs.createReadStream(assetPath).pipe(res);
+ return;
+ }
+ }
+
// QR SVG: GET /checkout/:id/qr.svg (Direct from merchant receiving account)
const qrMatch = pathname.match(/^\/checkout\/([^/]+)\/qr\.svg$/);
if (qrMatch) {
diff --git a/apps/checkout-portal/src/views/checkout.html b/apps/checkout-portal/src/views/checkout.html
index 7404244..e37101b 100644
--- a/apps/checkout-portal/src/views/checkout.html
+++ b/apps/checkout-portal/src/views/checkout.html
@@ -2,6864 +2,41 @@
<html lang="en">
<head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>{{MERCHANT_NAME}} · {{APP_NAME}} Checkout</title>
- <style>
- :root {
- --ypg-blue: #0b63e5;
- --ypg-blue-dark: #0957cb;
- --ypg-navy: #0b1526;
- --ypg-header-gradient: linear-gradient(180deg, #0b63e5 0%, #0957cb 100%);
- --ypg-bg: #f8fafc;
- --ypg-card: #ffffff;
- --ypg-text-dark: #0f172a;
- --ypg-text-muted: #64748b;
- --ypg-border: #e2e8f0;
- --ypg-border-light: #eef2f6;
- --ypg-green: #0d9f67;
- --ypg-green-bg: #e6f9f0;
- --ypg-offer-bg: #eff6ff;
- --ypg-offer-border: #dbeafe;
- --ypg-danger: #ef4444;
- --ypg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
- }
-
- * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- font-family: var(--ypg-font);
- -webkit-tap-highlight-color: transparent;
- }
-
- [hidden],
- #paymentGatewayInterface[hidden],
- #preGatewayAuthView[hidden] {
- display: none !important;
- }
-
- html,
- body {
- touch-action: pan-y;
- -webkit-overflow-scrolling: touch;
- height: 100%;
- height: 100dvh;
- margin: 0;
- padding: 0;
- }
-
- body {
- background-color: #0b0f19;
- color: var(--ypg-text-dark);
- min-height: 100vh;
- min-height: 100dvh;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0;
- margin: 0;
- overflow-x: hidden;
- font-size: 14px;
- }
-
- body.is-embedded {
- background: transparent;
- padding: 0;
- margin: 0;
- width: 100%;
- height: 100%;
- height: 100dvh;
- min-height: 100%;
- overflow: hidden;
- }
-
- /* --- YOUPI PG CARD / DRAWER CONTAINER --- */
- .ypg-wrapper {
- width: 100%;
- max-width: 440px;
- min-height: 100vh;
- background: #ffffff;
- display: flex;
- flex-direction: column;
- box-shadow: 0 25px 65px rgba(0, 0, 0, 0.45);
- position: relative;
- overflow: hidden;
- }
-
- @media (min-width: 601px) {
- body:not(.is-embedded) {
- padding: 24px;
- }
-
- body:not(.is-embedded) .ypg-wrapper {
- min-height: 640px;
- max-height: 92vh;
- border-radius: 16px;
- }
-
- body.is-embedded .ypg-wrapper {
- min-height: 100vh;
- height: 100%;
- max-width: 100%;
- border-radius: 0;
- }
- }
-
- @media (max-width: 600px) {
- .ypg-wrapper {
- max-width: 100vw;
- border-top-left-radius: 20px;
- border-top-right-radius: 20px;
- }
- }
-
- /* --- MOBILE TOP DRAG HANDLE --- */
- .ypg-drag-handle-bar {
- display: none;
- width: 36px;
- height: 4px;
- background: rgba(255, 255, 255, 0.45);
- border-radius: 9999px;
- margin: 8px auto 6px auto;
- }
-
- @media (max-width: 600px) {
- .ypg-drag-handle-bar {
- display: block;
- }
- }
-
- /* --- 1. INITIAL LOADING SPLASH SCREEN (YOUPI PG EMBLEM) --- */
- .ypg-splash-screen {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: #f4f5f7;
- z-index: 100;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- transition: opacity 0.4s ease, visibility 0.4s ease;
- }
-
- .ypg-splash-screen.fade-out {
- opacity: 0;
- visibility: hidden;
- pointer-events: none;
- }
-
- .ypg-splash-center {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- margin-bottom: 70px;
- }
-
- .ypg-shield-orbit-box {
- position: relative;
- width: 110px;
- height: 110px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
-
- .ypg-shield-icon-svg {
- width: 82px;
- height: 94px;
- filter: drop-shadow(0 8px 18px rgba(11, 99, 229, 0.3));
- animation: ypgPulseShield 2s infinite ease-in-out;
- }
-
- @keyframes ypgPulseShield {
-
- 0%,
- 100% {
- transform: scale(1);
- }
-
- 50% {
- transform: scale(1.04);
- }
- }
-
- .ypg-orbit-dot {
- position: absolute;
- width: 12px;
- height: 12px;
- background: #0b63e5;
- border: 2px solid #ffffff;
- border-radius: 50%;
- top: 8px;
- left: 20px;
- box-shadow: 0 0 8px rgba(11, 99, 229, 0.6);
- animation: ypgOrbitAnimation 1.5s infinite linear;
- }
-
- @keyframes ypgOrbitAnimation {
- 0% {
- transform: rotate(0deg) translateX(46px) rotate(0deg);
- }
-
- 100% {
- transform: rotate(360deg) translateX(46px) rotate(-360deg);
- }
- }
-
- .ypg-splash-footer {
- position: absolute;
- bottom: 24px;
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: 13px;
- font-weight: 700;
- color: #64748b;
- }
-
- /* --- 2. AUTHENTIC YOUPI PG HEADER --- */
- .ypg-header {
- background: var(--ypg-header-gradient);
- color: #ffffff;
- position: relative;
- display: flex;
- flex-direction: column;
- flex-shrink: 0;
- }
-
- .ypg-header-main-row {
- padding: 12px 16px 10px 16px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 10px;
- }
-
- body.is-embedded .ypg-header-main-row {
- padding-right: 56px;
- /* Avoid collision with parent modal close button at top-right 14px */
- }
-
- .ypg-header-left-group {
- display: flex;
- align-items: center;
- gap: 12px;
- flex: 1;
- overflow: hidden;
- }
-
- .ypg-btn-back {
- background: none;
- border: none;
- color: #ffffff;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 4px;
- border-radius: 6px;
- transition: background 0.15s;
- }
-
- .ypg-btn-back:hover {
- background: rgba(255, 255, 255, 0.15);
- }
-
- /* Teal Merchant Avatar with Initial */
- .ypg-merchant-avatar {
- width: 38px;
- height: 38px;
- border-radius: 10px;
- background: #14b8a6;
- border: 1.5px solid rgba(255, 255, 255, 0.85);
- color: #ffffff;
- font-size: 19px;
- font-weight: 800;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
- flex-shrink: 0;
- overflow: hidden;
- }
-
- .ypg-merchant-avatar img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
-
- .ypg-merchant-text-group {
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
-
- .ypg-merchant-name {
- font-size: 16px;
- font-weight: 700;
- color: #ffffff;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- line-height: 1.25;
- }
-
- /* YouPI PG Verified Business Badge */
- .ypg-trusted-badge {
- display: flex;
- align-items: center;
- gap: 4px;
- font-size: 11.5px;
- font-weight: 600;
- color: rgba(255, 255, 255, 0.95);
- margin-top: 1px;
- }
-
- .ypg-green-shield {
- width: 13px;
- height: 13px;
- flex-shrink: 0;
- }
-
- /* Profile Account Icon */
- .ypg-btn-profile {
- width: 34px;
- height: 34px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.2);
- border: none;
- color: #ffffff;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: background 0.15s;
- flex-shrink: 0;
- }
-
- .ypg-btn-profile:hover {
- background: rgba(255, 255, 255, 0.35);
- }
-
- /* Sub-banner */
- .ypg-header-subbanner {
- background: rgba(0, 0, 0, 0.12);
- padding: 6px 16px;
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: 11.5px;
- font-weight: 500;
- color: #ffffff;
- }
-
- .ypg-header-subbanner svg {
- width: 14px;
- height: 14px;
- flex-shrink: 0;
- }
-
- /* Profile Dropdown Popover */
- .ypg-account-popover {
- position: absolute;
- top: 54px;
- right: 16px;
- background: #ffffff;
- color: var(--ypg-text-dark);
- border-radius: 10px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
- border: 1px solid var(--ypg-border);
- padding: 8px;
- z-index: 50;
- min-width: 190px;
- animation: ypgFadeInDown 0.15s ease-out;
- }
-
- @keyframes ypgFadeInDown {
- from {
- opacity: 0;
- transform: translateY(-6px);
- }
-
- to {
- opacity: 1;
- transform: translateY(0);
- }
- }
-
- .ypg-popover-item {
- width: 100%;
- text-align: left;
- padding: 8px 12px;
- background: none;
- border: none;
- font-size: 12px;
- font-weight: 600;
- color: var(--ypg-text-dark);
- border-radius: 6px;
- cursor: pointer;
- display: flex;
- align-items: center;
- gap: 8px;
- }
-
- .ypg-popover-item:hover {
- background: var(--ypg-bg);
- }
-
- /* --- 3. SCROLLABLE BODY (WHITE SURFACE) --- */
- .ypg-body {
- flex: 1;
- overflow-y: auto;
- background: #ffffff;
- padding: 16px 16px 20px 16px;
- display: flex;
- flex-direction: column;
- position: relative;
- }
-
- .ypg-page-title {
- font-size: 18px;
- font-weight: 700;
- color: var(--ypg-text-dark);
- margin-bottom: 12px;
- letter-spacing: -0.01em;
- }
-
- /* Available Offers Pill */
- .ypg-offers-pill {
- background: var(--ypg-offer-bg);
- border: 1px solid var(--ypg-offer-border);
- border-radius: 9999px;
- padding: 6px 14px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 18px;
- cursor: pointer;
- transition: background 0.15s;
- }
-
- .ypg-offers-pill:hover {
- background: #e2eeff;
- }
-
- .ypg-offers-left {
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 12px;
- font-weight: 600;
- color: #1e3a8a;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
-
- .ypg-offer-icon-badge {
- width: 20px;
- height: 20px;
- border-radius: 50%;
- background: #fee2e2;
- color: #b91c1c;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 11px;
- font-weight: 800;
- flex-shrink: 0;
- }
-
- .ypg-offers-right {
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: 12px;
- font-weight: 600;
- color: var(--ypg-blue);
- flex-shrink: 0;
- }
-
- /* Section Label Row */
- .ypg-section-label-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 8px;
- }
-
- .ypg-section-heading {
- font-size: 13.5px;
- font-weight: 600;
- color: #334155;
- }
-
- .ypg-countdown-pill {
- background: #f1f5f9;
- border: 1px solid #e2e8f0;
- border-radius: 9999px;
- padding: 2px 9px;
- font-size: 11.5px;
- font-weight: 600;
- color: #475569;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- }
-
- /* --- 4. CORE UPI QR CARD (STRICTLY UPI ONLY) --- */
- .ypg-qr-card-container {
- background: #f8fafc;
- border: 1px solid var(--ypg-border-light);
- border-radius: 16px;
- padding: 16px;
- display: flex;
- gap: 16px;
- align-items: center;
- margin-bottom: 18px;
- }
-
- .ypg-qr-image-box {
- width: 130px;
- height: 130px;
- background: #ffffff;
- border: 1px solid #e2e8f0;
- border-radius: 12px;
- padding: 6px;
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- position: relative;
- }
-
- .ypg-qr-image-box svg {
- width: 100%;
- height: 100%;
- }
-
- .ypg-qr-details-col {
- display: flex;
- flex-direction: column;
- gap: 8px;
- flex: 1;
- overflow: hidden;
- }
-
- .ypg-qr-prompt-title {
- font-size: 14px;
- font-weight: 600;
- color: var(--ypg-text-dark);
- line-height: 1.3;
- }
-
- /* UPI Brand Logos */
- .ypg-upi-logos-row {
- display: flex;
- align-items: center;
- gap: 5px;
- flex-wrap: wrap;
- }
-
- .ypg-app-icon {
- width: 22px;
- height: 22px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
- }
-
- .ypg-app-icon img,
- .ypg-app-icon svg {
- width: 100%;
- height: 100%;
- border-radius: 50%;
- }
-
- .ypg-green-pill-badge {
- background: var(--ypg-green-bg);
- color: var(--ypg-green);
- font-size: 11px;
- font-weight: 600;
- padding: 2.5px 8px;
- border-radius: 9999px;
- align-self: flex-start;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- }
-
- /* Payee VPA & Copy Button */
- .ypg-vpa-copy-row {
- display: flex;
- align-items: center;
- gap: 6px;
- margin-top: 2px;
- }
-
- .ypg-vpa-badge {
- font-size: 11px;
- font-weight: 600;
- color: #475569;
- background: #edf2f7;
- padding: 2px 7px;
- border-radius: 6px;
- max-width: 140px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .ypg-btn-mini-copy {
- background: none;
- border: 1px solid #cbd5e1;
- border-radius: 5px;
- font-size: 10px;
- font-weight: 700;
- color: #334155;
- padding: 2px 6px;
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- gap: 3px;
- transition: all 0.15s;
- }
-
- .ypg-btn-mini-copy:hover {
- border-color: var(--ypg-blue);
- color: var(--ypg-blue);
- }
-
- .ypg-btn-mini-copy.copied {
- background: #10b981;
- border-color: #10b981;
- color: #ffffff;
- }
-
- /* Live Observer Radar Strip */
- .ypg-live-observer-strip {
- background: #f0fdf4;
- border: 1px solid #bbf7d0;
- border-radius: 10px;
- padding: 10px 14px;
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 12px;
- font-weight: 600;
- color: #166534;
- margin-bottom: 14px;
- }
-
- .ypg-radar-dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: #16a34a;
- box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
- animation: ypgPulseDot 1.8s infinite;
- flex-shrink: 0;
- }
-
- @keyframes ypgPulseDot {
- 0% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
- }
-
- 70% {
- transform: scale(1);
- box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);
- }
-
- 100% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
- }
- }
-
- /* UPI Instructions Card */
- .ypg-instructions-card {
- background: #ffffff;
- border: 1px solid var(--ypg-border);
- border-radius: 12px;
- padding: 14px 16px;
- margin-bottom: 16px;
- }
-
- .ypg-instruction-step {
- display: flex;
- align-items: flex-start;
- gap: 10px;
- margin-bottom: 8px;
- font-size: 12.5px;
- color: #334155;
- }
-
- .ypg-instruction-step:last-child {
- margin-bottom: 0;
- }
-
- .ypg-step-num {
- width: 18px;
- height: 18px;
- border-radius: 50%;
- background: #eff6ff;
- color: var(--ypg-blue);
- font-size: 11px;
- font-weight: 800;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- margin-top: 1px;
- }
-
- /* Payment Method Selector Bar (Online / Offline Modalities) */
- .ypg-method-selector-bar {
- display: flex;
- gap: 6px;
- background: #f1f5f9;
- padding: 4px;
- border-radius: 10px;
- margin-bottom: 14px;
- border: 1px solid var(--ypg-border);
- }
-
- .ypg-method-tab {
- flex: 1;
- text-align: center;
- padding: 7px 10px;
- border-radius: 8px;
- font-size: 11.5px;
- font-weight: 700;
- cursor: pointer;
- border: none;
- background: transparent;
- color: #64748b;
- transition: all 0.15s ease;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 5px;
- }
-
- .ypg-method-tab:hover {
- color: var(--ypg-navy);
- }
-
- .ypg-method-tab.active {
- background: #ffffff;
- color: var(--ypg-blue);
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
- }
-
- .ypg-tab-icon {
- height: 14px;
- width: auto;
- object-fit: contain;
- display: inline-block;
- vertical-align: middle;
- flex-shrink: 0;
- }
-
- .ypg-tab-icon-svg {
- width: 14px;
- height: 14px;
- display: inline-block;
- vertical-align: middle;
- flex-shrink: 0;
- }
-
- .ypg-card-logos-combo {
- display: inline-flex;
- align-items: center;
- gap: 3px;
- vertical-align: middle;
- flex-shrink: 0;
- }
-
- .ypg-card-logos-combo img {
- height: 13px;
- width: auto;
- object-fit: contain;
- display: inline-block;
- }
-
- /* --- 5. PRE-GATEWAY AUTH VIEW --- */
- .ypg-auth-box {
- background: #ffffff;
- display: flex;
- flex-direction: column;
- gap: 14px;
- margin-top: 4px;
- }
-
- .ypg-auth-sub-desc {
- font-size: 12.5px;
- color: var(--ypg-text-muted);
- margin-bottom: 8px;
- }
-
- .ypg-auth-tab-row {
- display: flex;
- background: #f1f5f9;
- border-radius: 8px;
- padding: 3px;
- }
-
- .ypg-auth-tab-btn {
- flex: 1;
- padding: 8px 12px;
- font-size: 12.5px;
- font-weight: 700;
- border: none;
- border-radius: 6px;
- background: transparent;
- color: var(--ypg-text-muted);
- cursor: pointer;
- transition: all 0.15s;
- }
-
- .ypg-auth-tab-btn.active {
- background: #ffffff;
- color: var(--ypg-navy);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
- }
-
- .ypg-input-group {
- margin-bottom: 12px;
- }
-
- .ypg-input-label {
- display: block;
- font-size: 11px;
- font-weight: 700;
- color: var(--ypg-text-dark);
- margin-bottom: 4px;
- text-transform: uppercase;
- letter-spacing: 0.3px;
- }
-
- .ypg-input-control {
- width: 100%;
- padding: 10px 12px;
- border: 1px solid #cbd5e1;
- border-radius: 8px;
- font-size: 13.5px;
- color: var(--ypg-text-dark);
- outline: none;
- transition: border-color 0.15s;
- }
-
- .ypg-input-control:focus {
- border-color: var(--ypg-blue);
- box-shadow: 0 0 0 3px rgba(11, 99, 229, 0.15);
- }
-
- .ypg-btn-auth-action {
- width: 100%;
- padding: 12px;
- background: var(--ypg-navy);
- color: #ffffff;
- border: none;
- border-radius: 8px;
- font-size: 13.5px;
- font-weight: 700;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 6px;
- transition: background 0.15s;
- }
-
- .ypg-btn-auth-action:hover {
- background: #1e293b;
- }
-
- .ypg-btn-auth-action:disabled {
- opacity: 0.65;
- cursor: not-allowed;
- }
-
- .ypg-phone-input-wrap {
- display: flex;
- align-items: center;
- border: 1px solid #cbd5e1;
- border-radius: 8px;
- overflow: hidden;
- background: #ffffff;
- transition: border-color 0.15s, box-shadow 0.15s;
- }
-
- .ypg-phone-input-wrap:focus-within {
- border-color: var(--ypg-blue);
- box-shadow: 0 0 0 3px rgba(11, 99, 229, 0.15);
- }
-
- .ypg-phone-prefix {
- padding: 10px 12px;
- background: #f8fafc;
- border-right: 1px solid #e2e8f0;
- font-size: 13.5px;
- font-weight: 700;
- color: var(--ypg-navy);
- display: flex;
- align-items: center;
- gap: 6px;
- user-select: none;
- }
-
- .ypg-phone-control {
- border: none !important;
- box-shadow: none !important;
- padding: 10px 12px;
- font-size: 14.5px;
- font-weight: 600;
- letter-spacing: 0.5px;
- flex: 1;
- }
-
- .ypg-auth-badge-banner {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: #f0fdf4;
- border: 1px solid #bbf7d0;
- border-radius: 8px;
- padding: 10px 12px;
- margin-bottom: 12px;
- font-size: 12.5px;
- color: #166534;
- }
-
- .ypg-btn-link {
- background: none;
- border: none;
- color: var(--ypg-blue);
- font-weight: 700;
- cursor: pointer;
- font-size: 12px;
- padding: 0;
- text-decoration: underline;
- }
-
- .ypg-otp-control {
- text-align: center;
- font-size: 24px !important;
- font-weight: 800 !important;
- letter-spacing: 12px !important;
- font-family: monospace;
- padding: 12px !important;
- }
-
- .ypg-autootp-status-box {
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
- border-radius: 8px;
- }
-
- @keyframes ypg-pulse {
- 0%, 100% { opacity: 1; transform: scale(1); }
- 50% { opacity: 0.55; transform: scale(1.12); }
- }
-
- .ypg-pulse {
- animation: ypg-pulse 1.8s infinite ease-in-out;
- }
-
- /* Saved Accounts Carousel */
- .ypg-saved-accs-wrapper {
- background: #f8fafc;
- border: 1px solid var(--ypg-border);
- border-radius: 10px;
- padding: 12px;
- }
-
- .saved-account-row {
- background: #ffffff;
- border: 1px solid var(--ypg-border);
- border-radius: 8px;
- padding: 10px 12px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 8px;
- cursor: pointer;
- transition: all 0.15s;
- }
-
- .saved-account-row:hover {
- border-color: var(--ypg-blue);
- box-shadow: 0 2px 8px rgba(11, 99, 229, 0.12);
- }
-
- /* --- 6. QUEUE SYSTEM VIEW --- */
- .ypg-queue-container {
- background: #eff6ff;
- border: 1px solid #bfdbfe;
- border-radius: 14px;
- padding: 28px 18px;
- text-align: center;
- margin: auto 0;
- }
-
- .ypg-queue-number {
- font-size: 36px;
- font-weight: 900;
- color: #1d4ed8;
- margin: 8px 0;
- }
-
- /* --- 7. PROCESSING / VERIFYING VIEW --- */
- .ypg-processing-box {
- text-align: center;
- padding: 40px 18px;
- margin: auto 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .ypg-double-spinner-box {
- position: relative;
- width: 72px;
- height: 72px;
- margin-bottom: 20px;
- }
-
- .ypg-spin-ring-outer {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- border: 4px solid rgba(11, 99, 229, 0.15);
- border-radius: 50%;
- }
-
- .ypg-spin-ring-inner {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- border: 4px solid transparent;
- border-top-color: var(--ypg-blue);
- border-radius: 50%;
- animation: ypgRotateRing 0.85s linear infinite;
- }
-
- @keyframes ypgRotateRing {
- 0% {
- transform: rotate(0deg);
- }
-
- 100% {
- transform: rotate(360deg);
- }
- }
-
- .ypg-spin-center-icon {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 28px;
- height: 28px;
- color: var(--ypg-blue);
- animation: ypgPulseCenter 1.5s ease-in-out infinite;
- }
-
- @keyframes ypgPulseCenter {
-
- 0%,
- 100% {
- transform: translate(-50%, -50%) scale(0.9);
- }
-
- 50% {
- transform: translate(-50%, -50%) scale(1.1);
- }
- }
-
- .ypg-processing-title {
- font-size: 16px;
- font-weight: 700;
- color: var(--ypg-text-dark);
- margin-bottom: 6px;
- }
-
- .ypg-processing-sub {
- font-size: 12px;
- color: var(--ypg-text-muted);
- line-height: 1.5;
- max-width: 290px;
- margin-bottom: 14px;
- }
-
- .ypg-proc-timer-badge {
- background: #f1f5f9;
- border: 1px solid #e2e8f0;
- border-radius: 9999px;
- padding: 3px 12px;
- font-size: 12px;
- font-weight: 700;
- color: #334155;
- }
-
- /* --- 8. SUCCESS CELEBRATION VIEW --- */
- .ypg-success-box {
- text-align: center;
- padding: 36px 18px;
- margin: auto 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .ypg-success-circle {
- width: 76px;
- height: 76px;
- border-radius: 50%;
- background: #10b981;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
- margin-bottom: 18px;
- animation: ypgSpringPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
- }
-
- @keyframes ypgSpringPop {
- 0% {
- transform: scale(0);
- opacity: 0;
- }
-
- 70% {
- transform: scale(1.15);
- }
-
- 100% {
- transform: scale(1);
- opacity: 1;
- }
- }
-
- .ypg-check-svg {
- width: 42px;
- height: 42px;
- stroke: #ffffff;
- stroke-width: 3.5;
- stroke-linecap: round;
- stroke-linejoin: round;
- fill: none;
- }
-
- .ypg-check-path {
- stroke-dasharray: 40;
- stroke-dashoffset: 40;
- animation: ypgDrawCheck 0.45s 0.25s forwards ease-in-out;
- }
-
- @keyframes ypgDrawCheck {
- to {
- stroke-dashoffset: 0;
- }
- }
-
- .ypg-success-title {
- font-size: 19px;
- font-weight: 800;
- color: #0f172a;
- margin-bottom: 4px;
- }
-
- .ypg-success-amount {
- font-size: 24px;
- font-weight: 900;
- color: #10b981;
- margin-bottom: 8px;
- }
-
- .btn-return-merchant {
- background: var(--ypg-navy);
- color: #ffffff;
- text-decoration: none;
- font-size: 13.5px;
- font-weight: 700;
- padding: 12px 26px;
- border-radius: 8px;
- margin-top: 14px;
- display: inline-block;
- }
-
- /* --- 9. DEDICATED PAYMENT EXPIRED / FAILED VIEW (FIXED & CENTERED) --- */
- .ypg-expired-box {
- text-align: center;
- padding: 32px 18px;
- margin: auto 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- background: #ffffff;
- border-radius: 16px;
- border: 1px solid var(--ypg-border);
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
- }
-
- .ypg-expired-icon-wrap {
- width: 68px;
- height: 68px;
- border-radius: 50%;
- background: #fee2e2;
- color: #ef4444;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 16px;
- box-shadow: 0 8px 16px rgba(239, 68, 68, 0.15);
- }
-
- .ypg-expired-icon-wrap svg {
- width: 34px;
- height: 34px;
- }
-
- .ypg-expired-title {
- font-size: 19px;
- font-weight: 800;
- color: #0f172a;
- margin-bottom: 6px;
- }
-
- .ypg-expired-desc {
- font-size: 12.5px;
- color: var(--ypg-text-muted);
- max-width: 310px;
- margin: 0 auto 20px auto;
- line-height: 1.5;
- }
-
- .ypg-expired-actions {
- display: flex;
- gap: 10px;
- justify-content: center;
- width: 100%;
- max-width: 300px;
- }
-
- .ypg-btn-expired-primary {
- flex: 1;
- padding: 12px;
- background: var(--ypg-navy);
- color: #ffffff;
- border: none;
- border-radius: 8px;
- font-size: 13.5px;
- font-weight: 700;
- cursor: pointer;
- transition: background 0.15s;
- }
-
- .ypg-btn-expired-primary:hover {
- background: #1e293b;
- }
-
- .ypg-btn-expired-secondary {
- padding: 12px 16px;
- background: #f1f5f9;
- color: #475569;
- border: 1px solid #cbd5e1;
- border-radius: 8px;
- font-size: 13.5px;
- font-weight: 700;
- cursor: pointer;
- transition: background 0.15s;
- }
-
- .ypg-btn-expired-secondary:hover {
- background: #e2e8f0;
- }
-
- /* --- 10. DEDICATED FRAUD / SECURITY ALERT & ACCESS BLOCKED VIEW --- */
- .ypg-blocked-box {
- text-align: center;
- padding: 32px 20px;
- margin: auto 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- background: #ffffff;
- border-radius: 16px;
- border: 1.5px solid #fecaca;
- box-shadow: 0 10px 30px rgba(220, 38, 38, 0.08);
- position: relative;
- overflow: hidden;
- }
- .ypg-blocked-box::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- height: 4px;
- background: linear-gradient(90deg, #dc2626, #b91c1c, #991b1b);
- }
- .ypg-blocked-icon-wrap {
- width: 72px;
- height: 72px;
- border-radius: 50%;
- background: #fef2f2;
- border: 2px solid #fee2e2;
- color: #dc2626;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 16px;
- box-shadow: 0 8px 24px rgba(220, 38, 38, 0.16);
- animation: ypgPulseAlert 2s infinite ease-in-out;
- }
- @keyframes ypgPulseAlert {
- 0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(220, 38, 38, 0.16); }
- 50% { transform: scale(1.05); box-shadow: 0 12px 30px rgba(220, 38, 38, 0.28); }
- }
- .ypg-blocked-badge {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- background: #fef2f2;
- color: #b91c1c;
- border: 1px solid #fca5a5;
- font-size: 11px;
- font-weight: 800;
- letter-spacing: 0.06em;
- text-transform: uppercase;
- padding: 4px 10px;
- border-radius: 20px;
- margin-bottom: 10px;
- }
- .ypg-blocked-badge-dot {
- width: 7px;
- height: 7px;
- border-radius: 50%;
- background: #dc2626;
- box-shadow: 0 0 6px #dc2626;
- animation: rzpHaloPulse 1.2s infinite;
- }
- .ypg-blocked-title {
- font-size: 20px;
- font-weight: 800;
- color: #991b1b;
- margin-bottom: 6px;
- letter-spacing: -0.01em;
- }
- .ypg-blocked-subtitle {
- font-size: 13px;
- font-weight: 600;
- color: #475569;
- margin-bottom: 14px;
- }
- .ypg-blocked-card {
- background: #f8fafc;
- border: 1px solid #e2e8f0;
- border-radius: 12px;
- padding: 14px 16px;
- margin-bottom: 18px;
- width: 100%;
- max-width: 340px;
- text-align: left;
- }
- .ypg-blocked-desc {
- font-size: 12px;
- color: #334155;
- line-height: 1.55;
- margin: 0;
- }
- .ypg-blocked-investigation {
- margin-top: 10px;
- padding-top: 10px;
- border-top: 1px dashed #cbd5e1;
- display: flex;
- align-items: flex-start;
- gap: 8px;
- font-size: 11.5px;
- color: #64748b;
- line-height: 1.45;
- }
- .ypg-blocked-details {
- background: #0f172a;
- border-radius: 8px;
- padding: 10px 14px;
- margin-bottom: 18px;
- width: 100%;
- max-width: 340px;
- display: grid;
- grid-template-columns: auto 1fr;
- gap: 4px 10px;
- font-size: 11px;
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
- }
- .ypg-blocked-details-label {
- color: #94a3b8;
- }
- .ypg-blocked-details-val {
- color: #f8fafc;
- text-align: right;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .ypg-btn-blocked-exit {
- background: #0f172a;
- color: #ffffff;
- border: none;
- padding: 11px 20px;
- border-radius: 10px;
- font-weight: 700;
- font-size: 13px;
- cursor: pointer;
- width: 100%;
- max-width: 340px;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 6px;
- transition: all 0.2s;
- }
- .ypg-btn-blocked-exit:hover {
- background: #1e293b;
- }
-
- /* --- 10b. DEDICATED DUPLICATE SESSION DETECTED VIEW (DEVICE BINDING SECURITY) --- */
- .ypg-duplicate-box {
- display: flex;
- flex-direction: column;
- align-items: center;
- text-align: center;
- padding: 24px 20px;
- animation: rzpFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
- width: 100%;
- box-sizing: border-box;
- position: relative;
- }
- .ypg-duplicate-badge {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- background: #fef3c7;
- color: #92400e;
- border: 1px solid #fde68a;
- padding: 4px 12px;
- border-radius: 20px;
- font-size: 11px;
- font-weight: 700;
- text-transform: uppercase;
- letter-spacing: 0.05em;
- margin-bottom: 16px;
- }
- .ypg-duplicate-badge-dot {
- width: 7px;
- height: 7px;
- border-radius: 50%;
- background: #d97706;
- box-shadow: 0 0 6px #d97706;
- animation: rzpHaloPulse 1.2s infinite;
- }
- .ypg-duplicate-icon-wrap {
- width: 64px;
- height: 64px;
- border-radius: 50%;
- background: radial-gradient(circle, #fef3c7 0%, #fffbeb 100%);
- border: 2px solid #fcd34d;
- color: #b45309;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 14px;
- box-shadow: 0 4px 16px rgba(217, 119, 6, 0.15);
- }
- .ypg-duplicate-title {
- font-size: 20px;
- font-weight: 800;
- color: #1e293b;
- margin-bottom: 6px;
- letter-spacing: -0.01em;
- }
- .ypg-duplicate-subtitle {
- font-size: 13px;
- font-weight: 600;
- color: #64748b;
- margin-bottom: 16px;
- }
- .ypg-duplicate-card {
- background: #fffbeb;
- border: 1px solid #fef08a;
- border-radius: 12px;
- padding: 16px 18px;
- margin-bottom: 22px;
- width: 100%;
- max-width: 360px;
- text-align: center;
- }
- .ypg-duplicate-desc {
- font-size: 13px;
- color: #1e293b;
- line-height: 1.55;
- margin: 0;
- font-weight: 500;
- }
- .ypg-btn-duplicate-action {
- background: #0f172a;
- color: #ffffff;
- border: none;
- padding: 13px 20px;
- border-radius: 10px;
- font-weight: 700;
- font-size: 13px;
- cursor: pointer;
- width: 100%;
- box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
- transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
- display: flex;
- align-items: center;
- justify-content: center;
- letter-spacing: 0.02em;
- }
- .ypg-btn-duplicate-action:hover {
- background: #1e293b;
- transform: translateY(-1px);
- box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
- }
- .ypg-btn-duplicate-action:active {
- transform: translateY(0);
- }
-
- /* --- 11. AUTHENTIC STICKY BOTTOM FOOTER --- */
- .ypg-sticky-footer {
- background: #ffffff;
- border-top: 1px solid #f1f5f9;
- display: flex;
- flex-direction: column;
- flex-shrink: 0;
- position: relative;
- z-index: 20;
- }
-
- /* Legal Disclaimer */
- .ypg-legal-disclaimer {
- font-size: 11px;
- color: #64748b;
- text-align: center;
- padding: 4px 16px;
- line-height: 1.35;
- }
-
- /* Bottom Action Row (₹5,500 View Details | Continue Button) */
- .ypg-action-bottom-bar {
- padding: 10px 16px 14px 16px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- }
-
- .ypg-amount-view-group {
- display: flex;
- flex-direction: column;
- }
-
- .ypg-bottom-price {
- font-size: 18px;
- font-weight: 800;
- color: #0f172a;
- letter-spacing: -0.01em;
- line-height: 1.2;
- }
-
- .ypg-btn-view-details {
- background: none;
- border: none;
- font-size: 11px;
- font-weight: 600;
- color: #64748b;
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- gap: 3px;
- padding: 0;
- margin-top: 2px;
- }
-
- .ypg-btn-view-details:hover {
- color: var(--ypg-blue);
- }
-
- .ypg-btn-continue {
- background: var(--ypg-navy);
- color: #ffffff;
- border: none;
- border-radius: 8px;
- padding: 12px 34px;
- font-size: 14.5px;
- font-weight: 700;
- cursor: pointer;
- transition: background 0.15s, transform 0.1s;
- }
-
- .ypg-btn-continue:hover {
- background: #1e293b;
- }
-
- .ypg-btn-continue:active {
- transform: scale(0.98);
- }
-
- /* --- ORDER BREAKDOWN POPUP DRAWER --- */
- .ypg-details-drawer {
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- background: #ffffff;
- border-top-left-radius: 16px;
- border-top-right-radius: 16px;
- box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.15);
- border-top: 1px solid var(--ypg-border);
- padding: 16px 18px;
- z-index: 30;
- transform: translateY(100%);
- transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
- }
-
- .ypg-details-drawer.open {
- transform: translateY(0);
- }
-
- .ypg-details-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 12px;
- font-size: 14px;
- font-weight: 700;
- }
-
- .ypg-details-row {
- display: flex;
- justify-content: space-between;
- font-size: 12.5px;
- color: #475569;
- margin-bottom: 6px;
- }
-
- .ypg-details-row.total {
- border-top: 1px dashed var(--ypg-border);
- padding-top: 8px;
- font-size: 14px;
- font-weight: 800;
- color: #0f172a;
- }
-
- /* Toast Notification */
- .ypg-toast {
- position: absolute;
- top: 16px;
- left: 50%;
- transform: translateX(-50%) translateY(-20px);
- background: #1e293b;
- color: #ffffff;
- padding: 8px 16px;
- border-radius: 9999px;
- font-size: 12px;
- font-weight: 600;
- opacity: 0;
- pointer-events: none;
- transition: all 0.25s ease-out;
- z-index: 1000;
- white-space: nowrap;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
- }
-
- .ypg-toast.show {
- transform: translateX(-50%) translateY(0);
- opacity: 1;
- }
-
- /* Help Modal Overlay */
- .ypg-dialog-overlay {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(15, 23, 42, 0.6);
- backdrop-filter: blur(4px);
- z-index: 200;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 16px;
- }
-
- .ypg-dialog-overlay[hidden] {
- display: none !important;
- }
-
- .ypg-dialog-card {
- background: #ffffff;
- border-radius: 12px;
- width: 100%;
- max-width: 360px;
- padding: 18px;
- }
-
- /* --- AUTHENTIC RAZORPAY 3D RUNNING COIN & MODAL SHEETS --- */
- .rzp-coin-stage {
- position: relative;
- width: 84px;
- height: 84px;
- margin: 8px auto;
- display: flex;
- align-items: center;
- justify-content: center;
- perspective: 600px;
- }
-
- .rzp-halo-ring {
- position: absolute;
- width: 76px;
- height: 76px;
- border-radius: 50%;
- border: 2px solid rgba(254, 240, 138, 0.45);
- box-shadow: 0 0 16px rgba(250, 204, 21, 0.28), inset 0 0 10px rgba(250, 204, 21, 0.18);
- animation: rzpHaloPulse 2.2s ease-in-out infinite;
- }
-
- @keyframes rzpHaloPulse {
-
- 0%,
- 100% {
- transform: scale(0.95);
- opacity: 0.55;
- }
-
- 50% {
- transform: scale(1.05);
- opacity: 0.95;
- }
- }
-
- .rzp-3d-coin {
- width: 54px;
- height: 54px;
- position: relative;
- transform-style: preserve-3d;
- animation: rzpCoinSpin 1.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
- }
-
- @keyframes rzpCoinSpin {
- 0% {
- transform: rotateY(0deg);
- }
-
- 50% {
- transform: rotateY(180deg);
- }
-
- 100% {
- transform: rotateY(360deg);
- }
- }
-
- .rzp-coin-face {
- position: absolute;
- inset: 0;
- border-radius: 50%;
- backface-visibility: hidden;
- background: radial-gradient(circle at 35% 35%, #fff9c4 0%, #fbc02d 42%, #f57f17 82%, #d97706 100%);
- border: 3.5px solid #fff59d;
- box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3), inset 0 1.5px 3px rgba(255, 255, 255, 0.7);
- display: flex;
- align-items: center;
- justify-content: center;
- }
-
- .rzp-coin-back {
- transform: rotateY(180deg);
- }
-
- .rzp-coin-inner-rim {
- width: 38px;
- height: 38px;
- border-radius: 50%;
- background: radial-gradient(circle at 38% 38%, #ffd54f 0%, #fbc02d 55%, #f57f17 100%);
- box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
- position: relative;
- overflow: hidden;
- }
-
- .rzp-coin-sheen {
- position: absolute;
- inset: 0;
- border-radius: 50%;
- background: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 50%);
- pointer-events: none;
- }
-
- /* Compact Coin for Inline Waiting Card */
- .rzp-coin-stage-inline {
- position: relative;
- width: 54px;
- height: 54px;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- perspective: 500px;
- }
-
- .rzp-coin-stage-inline .rzp-halo-ring {
- width: 50px;
- height: 50px;
- border-width: 1.5px;
- }
-
- .rzp-coin-stage-inline .rzp-3d-coin {
- width: 36px;
- height: 36px;
- }
-
- .rzp-coin-stage-inline .rzp-coin-face {
- border-width: 2.5px;
- }
-
- .rzp-coin-stage-inline .rzp-coin-inner-rim {
- width: 24px;
- height: 24px;
- }
-
- /* Inline Waiting Card (on UPI QR page) */
- .rzp-inline-waiting-card {
- margin: 14px 0;
- padding: 14px 16px;
- background: #ffffff;
- border: 1.5px solid #fde047;
- border-radius: 14px;
- display: flex;
- align-items: center;
- gap: 14px;
- box-shadow: 0 4px 14px rgba(234, 179, 8, 0.15);
- position: relative;
- overflow: hidden;
- text-align: left;
- }
-
- .rzp-inline-waiting-card::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- height: 3px;
- background: linear-gradient(90deg, #f59e0b, #eab308, #f59e0b);
- background-size: 200% 100%;
- animation: rzpGlowBar 2s linear infinite;
- }
-
- @keyframes rzpGlowBar {
- 0% {
- background-position: 0% 50%;
- }
-
- 100% {
- background-position: 200% 50%;
- }
- }
-
- /* Full-Screen Bottom Sheet / Dialog Modals */
- .rzp-sheet-backdrop {
- position: fixed;
- inset: 0;
- width: 100%;
- height: 100%;
- height: 100dvh;
- background: rgba(15, 23, 42, 0.65);
- backdrop-filter: blur(5px);
- -webkit-backdrop-filter: blur(5px);
- z-index: 99999;
- display: flex;
- align-items: flex-end;
- justify-content: center;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.25s ease-out;
- overflow: hidden;
- }
-
- @media (min-width: 601px) {
- .rzp-sheet-backdrop {
- align-items: center;
- }
- }
-
- .rzp-sheet-backdrop.active {
- opacity: 1;
- pointer-events: auto;
- }
-
- .rzp-sheet-dialog {
- width: 100%;
- max-width: 440px;
- max-height: 88dvh;
- max-height: 88vh;
- background: #ffffff;
- border-top-left-radius: 20px;
- border-top-right-radius: 20px;
- box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
- overflow-y: auto !important;
- -webkit-overflow-scrolling: touch !important;
- overscroll-behavior-y: contain !important;
- transform: translateY(100%);
- transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
- display: flex;
- flex-direction: column;
- position: relative;
- }
-
- @media (min-width: 601px) {
- .rzp-sheet-dialog {
- border-radius: 20px;
- max-height: 85vh;
- transform: translateY(20px) scale(0.98);
- }
-
- .rzp-sheet-backdrop.active .rzp-sheet-dialog {
- transform: translateY(0) scale(1);
- }
- }
-
- .rzp-sheet-backdrop.active .rzp-sheet-dialog {
- transform: translateY(0);
- }
-
- .rzp-sheet-content {
- padding: 16px 20px 20px;
- display: flex;
- flex-direction: column;
- align-items: center;
- text-align: center;
- width: 100%;
- box-sizing: border-box;
- }
-
- .rzp-sheet-title {
- font-size: 19px;
- font-weight: 800;
- color: #0f172a;
- letter-spacing: -0.3px;
- margin-bottom: 4px;
- }
-
- .rzp-sheet-subtitle {
- font-size: 13px;
- color: #64748b;
- margin-bottom: 6px;
- line-height: 1.4;
- }
-
- .rzp-sheet-cancel-btn {
- width: 100%;
- height: 42px;
- background: #ffffff;
- border: 1.5px solid #e2e8f0;
- border-radius: 10px;
- font-size: 14px;
- font-weight: 700;
- color: #0b63e5;
- cursor: pointer;
- margin-top: 14px;
- transition: all 0.2s;
- }
-
- .rzp-sheet-cancel-btn:hover {
- background: #f8fafc;
- border-color: #cbd5e1;
- }
-
- /* Cancel Modal Header Arc with Doors */
- .rzp-cancel-header-arc {
- width: 120%;
- height: 80px;
- background: #dbeafe;
- border-bottom-left-radius: 50% 28px;
- border-bottom-right-radius: 50% 28px;
- display: flex;
- align-items: flex-end;
- justify-content: center;
- padding-bottom: 6px;
- position: relative;
- margin-left: -10%;
- margin-right: -10%;
- }
-
- .rzp-btn-sheet-close {
- position: absolute;
- top: 12px;
- right: calc(10% + 12px);
- width: 30px;
- height: 30px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.7);
- border: none;
- color: #334155;
- font-size: 15px;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- transition: background 0.15s;
- }
-
- .rzp-btn-sheet-close:hover {
- background: rgba(255, 255, 255, 0.95);
- }
-
- .rzp-btn-wait {
- width: 100%;
- height: 42px;
- background: #ffffff;
- border: 1.5px solid #e2e8f0;
- border-radius: 10px;
- font-size: 14px;
- font-weight: 700;
- color: #0f172a;
- cursor: pointer;
- margin-top: 14px;
- transition: all 0.2s;
- }
-
- .rzp-btn-wait:hover {
- background: #f8fafc;
- }
-
- .rzp-btn-confirm-cancel {
- width: 100%;
- height: 42px;
- background: #0f172a;
- border: none;
- border-radius: 10px;
- font-size: 14px;
- font-weight: 700;
- color: #ffffff;
- cursor: pointer;
- margin-top: 8px;
- transition: all 0.2s;
- }
-
- .rzp-btn-confirm-cancel:hover {
- background: #1e293b;
- }
-
- .rzp-secured-by {
- font-size: 12px;
- color: #64748b;
- margin-top: 22px;
- display: flex;
- align-items: center;
- gap: 5px;
- }
-
- /* --- PSYCHOLOGICAL TIME-SAVING CONVERSION BANNER --- */
- .ypg-time-saving-banner {
- background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
- border: 1px solid #86efac;
- border-radius: 10px;
- padding: 10px 14px;
- margin-bottom: 14px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
- }
-
- .ypg-time-saving-text {
- font-size: 12px;
- font-weight: 700;
- color: #14532d;
- line-height: 1.4;
- flex: 1;
- }
-
- .ypg-banner-running-timer {
- font-family: monospace;
- font-size: 13px;
- font-weight: 800;
- color: #15803d;
- background: rgba(255, 255, 255, 0.85);
- padding: 1px 6px;
- border-radius: 4px;
- border: 1px solid #bbf7d0;
- display: inline-block;
- letter-spacing: 0.5px;
- }
-
- .ypg-btn-fast-switch {
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
- color: #ffffff;
- border: none;
- border-radius: 8px;
- padding: 8px 12px;
- font-size: 11.5px;
- font-weight: 700;
- cursor: pointer;
- white-space: nowrap;
- flex-shrink: 0;
- box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
- transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- }
-
- .ypg-btn-fast-switch:hover {
- background: linear-gradient(135deg, #059669 0%, #047857 100%);
- transform: translateY(-1px);
- box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35);
- }
-
- /* Dedicated Psychological Conversion Card in UPI Queue View */
- .ypg-queue-conversion-card {
- background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
- border: 1px solid #86efac;
- border-radius: 12px;
- padding: 14px 16px;
- margin-bottom: 14px;
- box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
- text-align: left;
- }
-
- .ypg-queue-conversion-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 10px;
- margin-bottom: 8px;
- }
-
- .ypg-queue-conversion-badge {
- font-size: 11.5px;
- font-weight: 800;
- color: #065f46;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- display: flex;
- align-items: center;
- gap: 4px;
- }
-
- .ypg-queue-conversion-pill {
- font-size: 11.5px;
- font-weight: 700;
- color: #15803d;
- background: rgba(255, 255, 255, 0.9);
- padding: 2px 8px;
- border-radius: 12px;
- border: 1px solid #bbf7d0;
- white-space: nowrap;
- }
-
- .ypg-queue-conversion-text {
- font-size: 12.5px;
- line-height: 1.45;
- color: #14532d;
- margin-bottom: 12px;
- }
-
- .ypg-btn-queue-switch {
- width: 100%;
- height: 42px;
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
- color: #ffffff;
- border: none;
- border-radius: 9px;
- font-size: 13px;
- font-weight: 700;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
- transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
- }
-
- .ypg-btn-queue-switch:hover {
- background: linear-gradient(135deg, #059669 0%, #047857 100%);
- transform: translateY(-1px);
- box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
- }
-
- /* --- DESKTOP / PC SPECIFIC 2-COLUMN RAZORPAY REDESIGN --- */
- @media (min-width: 768px) {
- body {
- padding: 0;
- margin: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #0b0f19;
- }
-
- body:not(.is-embedded) {
- padding: 20px;
- }
-
- .ypg-wrapper {
- width: 900px !important;
- max-width: 95vw !important;
- height: 600px !important;
- max-height: 92vh !important;
- border-radius: 16px !important;
- display: flex !important;
- flex-direction: row !important;
- box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5) !important;
- overflow: hidden !important;
- position: relative !important;
- }
-
- body.is-embedded .ypg-wrapper {
- width: 100% !important;
- max-width: 100% !important;
- height: 100% !important;
- min-height: 100% !important;
- border-radius: 16px !important;
- }
-
- .ypg-header {
- display: none !important;
- }
-
- .ypg-drag-handle-bar {
- display: none !important;
- }
-
- .ypg-action-bottom-bar {
- display: none !important;
- }
-
- .ypg-footer {
- display: none !important;
- }
-
- /* PC Left Sidebar (Blue Branding Panel - ~310px width) */
- .ypg-pc-sidebar {
- width: 310px;
- min-width: 310px;
- max-width: 310px;
- height: 100%;
- background: linear-gradient(180deg, var(--ypg-blue, #0b63e5) 0%, var(--ypg-blue-dark, #0854c6) 100%);
- padding: 22px 20px;
- display: flex !important;
- flex-direction: column;
- justify-content: space-between;
- color: #ffffff;
- position: relative;
- overflow: hidden;
- box-sizing: border-box;
- }
-
- .ypg-pc-brand-header {
- display: flex;
- align-items: center;
- gap: 12px;
- margin-bottom: 12px;
- }
-
- .ypg-pc-avatar {
- width: 42px;
- height: 42px;
- border-radius: 10px;
- background: rgba(255, 255, 255, 0.22);
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 20px;
- font-weight: 800;
- color: #ffffff;
- overflow: hidden;
- flex-shrink: 0;
- }
-
- .ypg-pc-avatar img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
-
- .ypg-pc-brand-info {
- display: flex;
- flex-direction: column;
- gap: 3px;
- min-width: 0;
- }
-
- .ypg-pc-merchant-name {
- font-size: 16px;
- font-weight: 800;
- color: #ffffff;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- line-height: 1.2;
- }
-
- .ypg-pc-trust-badge {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- background: rgba(255, 255, 255, 0.16);
- border-radius: 20px;
- padding: 2px 8px;
- font-size: 11px;
- font-weight: 600;
- color: #ffffff;
- width: fit-content;
- }
-
- .ypg-pc-green-shield {
- width: 13px;
- height: 13px;
- }
-
- /* Social Proof Pill */
- .ypg-pc-social-proof {
- background: rgba(255, 255, 255, 0.12);
- border-radius: 8px;
- padding: 8px 12px;
- margin-top: 6px;
- font-size: 11.5px;
- color: rgba(255, 255, 255, 0.95);
- display: flex;
- align-items: center;
- gap: 8px;
- }
-
- /* Price Summary White Card - NO UPI ID VISIBLE */
- .ypg-pc-price-card {
- background: #ffffff;
- border-radius: 10px;
- padding: 14px 16px;
- margin-top: 14px;
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
- color: #0f172a;
- }
-
- .ypg-pc-price-label {
- font-size: 12px;
- font-weight: 600;
- color: #64748b;
- letter-spacing: 0.2px;
- }
-
- .ypg-pc-price-val {
- font-size: 26px;
- font-weight: 800;
- color: #0f172a;
- margin-top: 4px;
- letter-spacing: -0.5px;
- }
-
- /* User Profile Row Button */
- .ypg-pc-row-btn {
- background: rgba(255, 255, 255, 0.12);
- border-radius: 8px;
- padding: 10px 12px;
- margin-top: 10px;
- font-size: 12px;
- color: #ffffff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- cursor: pointer;
- transition: background 0.15s;
- }
-
- .ypg-pc-row-btn:hover {
- background: rgba(255, 255, 255, 0.18);
- }
-
- .ypg-pc-row-left {
- display: flex;
- align-items: center;
- gap: 8px;
- min-width: 0;
- overflow: hidden;
- }
-
- #pcCustomerProfileText {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
-
- .ypg-pc-chevron {
- font-size: 16px;
- opacity: 0.75;
- flex-shrink: 0;
- }
-
- /* Shopping Bags Graphic */
- .ypg-pc-bags-wrap {
- width: 100%;
- display: flex;
- justify-content: center;
- margin-top: auto;
- padding-top: 14px;
- padding-bottom: 4px;
- }
-
- /* PC Right Column / Workspace */
- .ypg-pc-workspace {
- flex: 1;
- height: 100%;
- display: flex !important;
- flex-direction: column;
- background: #ffffff;
- overflow: hidden;
- min-width: 0;
- }
-
- .ypg-pc-topbar {
- height: 48px;
- border-bottom: 1px solid #f1f5f9;
- display: flex !important;
- align-items: center;
- justify-content: space-between;
- padding: 0 20px;
- background: #ffffff;
- flex-shrink: 0;
- position: relative;
- z-index: 60;
- }
-
- .ypg-pc-topbar-title {
- font-size: 15px;
- font-weight: 700;
- color: #0f172a;
- }
-
- .ypg-pc-topbar-actions {
- display: flex;
- align-items: center;
- gap: 12px;
- position: relative;
- z-index: 61;
- }
-
- .ypg-pc-btn-more,
- .ypg-pc-btn-close {
- background: none;
- border: none;
- font-size: 16px;
- color: #64748b;
- cursor: pointer;
- padding: 4px 6px;
- border-radius: 4px;
- line-height: 1;
- transition: color 0.15s, background 0.15s;
- }
-
- .ypg-pc-btn-close {
- font-size: 18px;
- font-weight: 600;
- }
-
- .ypg-pc-btn-more:hover,
- .ypg-pc-btn-close:hover {
- color: #0f172a;
- background: #f1f5f9;
- }
-
- /* PC Body Container - Bounded to viewport height */
- .ypg-body {
- flex: 1 !important;
- height: calc(100% - 48px) !important;
- max-height: calc(100% - 48px) !important;
- display: flex !important;
- flex-direction: column !important;
- padding: 0 !important;
- overflow: hidden !important;
- min-height: 0 !important;
- }
-
- #paymentGatewayInterface:not([hidden]) {
- flex: 1 !important;
- height: 100% !important;
- max-height: 100% !important;
- display: flex !important;
- flex-direction: column !important;
- min-height: 0 !important;
- overflow: hidden !important;
- }
-
- #paymentGatewayInterface[hidden] {
- display: none !important;
- }
-
- #preGatewayAuthView:not([hidden]) {
- flex: 1 !important;
- height: 100% !important;
- max-height: 100% !important;
- display: flex !important;
- flex-direction: column !important;
- overflow-y: auto !important;
- padding: 24px 32px !important;
- box-sizing: border-box !important;
- }
-
- #preGatewayAuthView[hidden] {
- display: none !important;
- }
-
- /* Clean PC layout */
- .ypg-pc-columns {
- display: flex !important;
- flex-direction: row !important;
- flex: 1 !important;
- height: 100% !important;
- max-height: 100% !important;
- min-height: 0 !important;
- overflow: hidden !important;
- }
-
- .ypg-pc-methods-list {
- width: 220px !important;
- min-width: 220px !important;
- height: 100% !important;
- max-height: 100% !important;
- border-right: 1px solid #f1f5f9 !important;
- padding: 14px 12px !important;
- display: flex !important;
- flex-direction: column !important;
- gap: 8px !important;
- overflow-y: auto !important;
- background: #ffffff !important;
- scrollbar-width: thin !important;
- scrollbar-color: #e2e8f0 transparent !important;
- }
-
- .ypg-pc-methods-list::-webkit-scrollbar {
- width: 4px;
- }
-
- .ypg-pc-methods-list::-webkit-scrollbar-thumb {
- background: #e2e8f0;
- border-radius: 4px;
- }
-
- .ypg-pc-method-card {
- border: 1.5px solid #e2e8f0;
- border-radius: 10px;
- padding: 10px 12px;
- cursor: pointer;
- transition: all 0.2s ease;
- background: #ffffff;
- }
-
- .ypg-pc-method-card:hover {
- border-color: #cbd5e1;
- background: #f8fafc;
- }
-
- .ypg-pc-method-card.is-active {
- border-color: var(--ypg-blue, #0b63e5);
- background: #eff6ff;
- box-shadow: 0 0 0 1px var(--ypg-blue, #0b63e5);
- }
-
- .ypg-pc-method-card.disabled {
- opacity: 0.6;
- cursor: default;
- }
-
- .ypg-pc-method-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 2px;
- }
-
- .ypg-pc-method-title {
- font-size: 13px;
- font-weight: 700;
- color: #0f172a;
- }
-
- .ypg-pc-cash-pill {
- font-size: 10px;
- font-weight: 700;
- color: #0369a1;
- background: #e0f2fe;
- padding: 2px 6px;
- border-radius: 10px;
- }
-
- .ypg-pc-method-sub {
- font-size: 11px;
- color: #64748b;
- }
-
- .ypg-pc-method-icons {
- display: flex;
- align-items: center;
- gap: 4px;
- margin-top: 6px;
- }
-
- .ypg-pc-mini-icon {
- width: 18px;
- height: 18px;
- border-radius: 4px;
- object-fit: cover;
- }
-
- /* Right active workspace - Bounded height with buttery-smooth scrolling */
- .ypg-pc-active-view {
- flex: 1 !important;
- height: 100% !important;
- max-height: 100% !important;
- padding: 16px 22px !important;
- overflow-y: auto !important;
- display: flex !important;
- flex-direction: column !important;
- min-width: 0 !important;
- scrollbar-width: thin !important;
- scrollbar-color: #cbd5e1 transparent !important;
- }
-
- .ypg-pc-active-view::-webkit-scrollbar {
- width: 6px;
- }
-
- .ypg-pc-active-view::-webkit-scrollbar-track {
- background: transparent;
- }
-
- .ypg-pc-active-view::-webkit-scrollbar-thumb {
- background: #cbd5e1;
- border-radius: 4px;
- }
-
- .ypg-pc-active-view::-webkit-scrollbar-thumb:hover {
- background: #94a3b8;
- }
-
- /* Desktop: Hide redundant step cards since QR details column has instructions */
- .ypg-instructions-card {
- display: none !important;
- }
-
- /* Desktop method selector override */
- .ypg-method-selector-bar {
- display: none !important;
- }
-
- /* PC Exit Modal Styling (Razorpay desktop modal) */
- .mob-only-title,
- .mob-only-sub,
- .mob-only-btn {
- display: none !important;
- }
-
- .pc-only-title,
- .pc-only-sub,
- .pc-only-btn {
- display: inline !important;
- }
-
- .rzp-sheet-dialog {
- width: 420px !important;
- border-radius: 16px !important;
- box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4) !important;
- animation: rzpModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
- }
- }
-
- /* MOBILE SPECIFIC RULES - PINNED HEADER WITH CONTENT SCROLLING BEHIND IT */
- @media (max-width: 767px) {
- .ypg-pc-sidebar {
- display: none !important;
- }
-
- .ypg-pc-topbar {
- display: none !important;
- }
-
- .ypg-wrapper {
- height: 100% !important;
- height: 100dvh !important;
- min-height: 100% !important;
- min-height: 100dvh !important;
- max-height: 100% !important;
- max-height: 100dvh !important;
- display: flex !important;
- flex-direction: column !important;
- overflow: hidden !important;
- width: 100vw !important;
- max-width: 100vw !important;
- border-radius: 0 !important;
- }
-
- .ypg-pc-workspace {
- height: 100% !important;
- max-height: 100% !important;
- display: flex !important;
- flex-direction: column !important;
- overflow: hidden !important;
- flex: 1 !important;
- position: relative !important;
- }
-
- /* Pinned/Sticky Header: Store name sits firmly at top */
- .ypg-header {
- position: sticky !important;
- top: 0 !important;
- z-index: 50 !important;
- flex-shrink: 0 !important;
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
- }
-
- /* Body is the single fluid scroll container that flows behind the header */
- .ypg-body {
- display: block !important;
- flex: 1 !important;
- height: auto !important;
- min-height: 0 !important;
- overflow-y: auto !important;
- -webkit-overflow-scrolling: touch !important;
- overscroll-behavior-y: contain !important;
- padding: 14px 16px 140px 16px !important;
- scrollbar-width: none !important;
- }
-
- .ypg-body::-webkit-scrollbar {
- display: none !important;
- }
-
- /* Method tabs scroll smoothly under the header */
- .ypg-method-selector-bar {
- position: sticky !important;
- top: -14px !important;
- z-index: 30 !important;
- background: #ffffff !important;
- padding-top: 4px !important;
- padding-bottom: 8px !important;
- }
-
- /* Inner wrappers must NOT have conflicting overflow or height */
- #paymentGatewayInterface:not([hidden]) {
- display: block !important;
- height: auto !important;
- max-height: none !important;
- overflow: visible !important;
- flex: none !important;
- }
-
- #paymentGatewayInterface[hidden] {
- display: none !important;
- }
-
- #preGatewayAuthView:not([hidden]) {
- display: block !important;
- width: 100% !important;
- padding: 16px 16px 24px !important;
- box-sizing: border-box !important;
- }
-
- #preGatewayAuthView[hidden] {
- display: none !important;
- }
-
- .ypg-pc-columns {
- display: block !important;
- height: auto !important;
- max-height: none !important;
- overflow: visible !important;
- flex: none !important;
- }
-
- .ypg-pc-methods-list {
- display: none !important;
- }
-
- .ypg-pc-active-view {
- display: block !important;
- height: auto !important;
- max-height: none !important;
- overflow: visible !important;
- padding: 0 !important;
- width: 100% !important;
- flex: none !important;
- }
-
- /* Fixed Bottom Footer Bar */
- .ypg-sticky-footer {
- position: fixed !important;
- bottom: 0 !important;
- left: 0 !important;
- right: 0 !important;
- z-index: 45 !important;
- background: #ffffff !important;
- box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08) !important;
- }
-
- .pc-only-title,
- .pc-only-sub,
- .pc-only-btn {
- display: none !important;
- }
-
- .mob-only-title,
- .mob-only-sub,
- .mob-only-btn {
- display: inline !important;
- }
- }
-
- /* --- OFFICIAL GOOGLE PLAY STORE APP ICONS --- */
- .ypg-upi-logos-row {
- display: flex;
- align-items: center;
- gap: 6px;
- flex-wrap: wrap;
- }
-
- .ypg-app-icon {
- width: 26px;
- height: 26px;
- border-radius: 6px;
- overflow: hidden;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
- display: flex;
- align-items: center;
- justify-content: center;
- background: #ffffff;
- border: 1px solid #e2e8f0;
- flex-shrink: 0;
- }
-
- .ypg-app-icon img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- border-radius: 5px;
- display: block;
- }
-
- /* --- UPI SERVER HEALTH INDICATOR & DOWNTIME ALERT --- */
- .ypg-server-health-indicator {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 4px 10px;
- border-radius: 20px;
- font-size: 11px;
- font-weight: 700;
- letter-spacing: 0.2px;
- margin: 0 auto 10px auto;
- transition: all 0.25s ease;
- width: fit-content;
- }
-
- .ypg-server-health-indicator.is-working {
- background: #f0fdf4;
- color: #15803d;
- border: 1px solid #bbf7d0;
- }
-
- .ypg-server-health-indicator.is-busy {
- background: #fefce8;
- color: #854d0e;
- border: 1px solid #fef08a;
- }
-
- .ypg-server-health-indicator.is-issues {
- background: #fef2f2;
- color: #b91c1c;
- border: 1px solid #fecaca;
- }
-
- .ypg-pulse-dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- display: inline-block;
- }
-
- .ypg-server-health-indicator.is-working .ypg-pulse-dot {
- background: #22c55e;
- box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
- animation: pulse-green 1.8s infinite;
- }
-
- .ypg-server-health-indicator.is-busy .ypg-pulse-dot {
- background: #eab308;
- box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
- animation: pulse-yellow 1.8s infinite;
- }
-
- .ypg-server-health-indicator.is-issues .ypg-pulse-dot {
- background: #ef4444;
- box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
- animation: pulse-red 1.8s infinite;
- }
-
- @keyframes pulse-yellow {
- 0% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
- }
-
- 70% {
- transform: scale(1);
- box-shadow: 0 0 0 6px rgba(234, 179, 8, 0);
- }
-
- 100% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(234, 179, 8, 0);
- }
- }
-
- @keyframes pulse-green {
- 0% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
- }
-
- 70% {
- transform: scale(1);
- box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
- }
-
- 100% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
- }
- }
-
- @keyframes pulse-red {
- 0% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
- }
-
- 70% {
- transform: scale(1);
- box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
- }
-
- 100% {
- transform: scale(0.95);
- box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
- }
- }
-
- .ypg-downtime-alert {
- background: #fff5f5;
- border: 1px solid #fed7d7;
- border-left: 4px solid #e53e3e;
- border-radius: 8px;
- padding: 10px 14px;
- margin: 10px 0;
- display: flex;
- gap: 10px;
- align-items: flex-start;
- text-align: left;
- }
-
- .ypg-downtime-alert.is-warning {
- background: #fffbeb;
- border: 1px solid #fef3c7;
- border-left: 4px solid #f59e0b;
- }
-
- .ypg-downtime-alert.is-warning .ypg-downtime-heading {
- color: #92400e;
- }
-
- .ypg-downtime-alert.is-warning .ypg-downtime-msg {
- color: #78350f;
- }
-
- .ypg-downtime-icon {
- font-size: 18px;
- line-height: 1;
- flex-shrink: 0;
- }
-
- .ypg-downtime-heading {
- font-size: 12px;
- font-weight: 800;
- color: #991b1b;
- margin-bottom: 3px;
- }
-
- .ypg-downtime-msg {
- font-size: 11.5px;
- color: #7f1d1d;
- line-height: 1.4;
- margin-bottom: 6px;
- }
-
- .ypg-btn-downtime-alt {
- background: #0f172a;
- color: #ffffff;
- border: none;
- border-radius: 6px;
- font-size: 11px;
- font-weight: 700;
- padding: 6px 12px;
- cursor: pointer;
- transition: opacity 0.2s;
- }
-
- .ypg-btn-downtime-alt:hover {
- opacity: 0.9;
- }
- </style>
-</head>
-
-<body>
-
- <!-- TOAST NOTIFICATION -->
- <div id="ypgToast" class="ypg-toast"><img src="/icons/upi.svg" alt="UPI" style="height:12px; vertical-align:middle; filter:brightness(0) invert(1); margin-right:4px;" /> Direct UPI QR is active for instant banking verification</div>
-
- <!-- YOUPI PG CHECKOUT CARD / DRAWER WRAPPER -->
- <div class="ypg-wrapper">
-
- <!-- 1. INITIAL YOUPI PG LOADING SPLASH -->
- <div id="ypgSplashScreen" class="ypg-splash-screen">
- <div class="ypg-splash-center">
- <div class="ypg-shield-orbit-box">
- <img id="splashBrandLogo" alt="Logo"
- style="display:none; max-width:82px; max-height:82px; border-radius:16px; object-fit:contain; box-shadow:0 8px 24px rgba(0,0,0,0.12);" />
- <!-- Authentic YouPI PG Shield with 'Y' Monogram -->
- <svg class="ypg-shield-icon-svg" id="splashDefaultShield" viewBox="0 0 100 120" fill="none">
- <defs>
- <linearGradient id="ypgShieldGrad" x1="0" y1="0" x2="1" y2="1">
- <stop offset="0%" stop-color="#0b63e5" />
- <stop offset="100%" stop-color="#0747a6" />
- </linearGradient>
- </defs>
- <path d="M50 4 L92 22 C92 72, 50 116, 50 116 C50 116, 8 72, 8 22 Z" fill="url(#ypgShieldGrad)" />
- <!-- Sharp white & cyan 'Y' monogram -->
- <path d="M33 32 L46 54 L46 84 L54 84 L54 54 L67 32 L56 32 L50 44 L44 32 Z" fill="#ffffff" />
- <polygon points="50,44 56,32 61,32 54,49" fill="#38bdf8" />
- </svg>
- <div class="ypg-orbit-dot"></div>
- </div>
- </div>
- <div class="ypg-splash-footer" id="splashFooterWrap">
- <span>Secured By</span>
- <strong id="splashSecuredByText" style="color:var(--ypg-blue); font-size:15px; letter-spacing:-0.2px;">YouPI
- PG</strong>
- </div>
- </div>
-
-
- <!-- PC LEFT SIDEBAR (Razorpay 2-Column Exact Layout for Desktop) -->
- <aside class="ypg-pc-sidebar">
- <div>
- <!-- Merchant Brand Header -->
- <div class="ypg-pc-brand-header">
- <div class="ypg-pc-avatar" id="pcMerchantAvatarBox">
- <span id="pcMerchantAvatarLetter">M</span>
- <img id="pcMerchantAvatarImg" alt="Logo" style="display:none;" />
- </div>
- <div class="ypg-pc-brand-info">
- <div class="ypg-pc-merchant-name" id="pcMerchantName">{{MERCHANT_NAME}}</div>
- <div class="ypg-pc-trust-badge" id="pcTrustBadge">
- <svg class="ypg-pc-green-shield" viewBox="0 0 24 24" fill="none">
- <path d="M12 2L3 6v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6l-9-4z" fill="#10b981" />
- <path d="M8.5 12l2.5 2.5 5-5" stroke="#ffffff" stroke-width="2.2" stroke-linecap="round"
- stroke-linejoin="round" />
- </svg>
- <span id="pcTrustBadgeText">YouPI PG Trusted Business</span>
- </div>
- </div>
- </div>
-
- <!-- Social Proof Banner -->
- <div class="ypg-pc-social-proof" id="pcSocialProofWrap">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <circle cx="9" cy="21" r="1" />
- <circle cx="20" cy="21" r="1" />
- <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
- </svg>
- <span id="pcSocialProofText">500+ orders last month from {{MERCHANT_NAME}}</span>
- </div>
-
- <!-- Price Summary Card (STRICTLY NO UPI ID VISIBLE) -->
- <div class="ypg-pc-price-card">
- <div class="ypg-pc-price-label">Price Summary</div>
- <div class="ypg-pc-price-val" id="pcPriceSummaryAmount">₹{{AMOUNT}}</div>
- </div>
-
- <!-- User Identity Row -->
- <div class="ypg-pc-row-btn" id="pcCustomerProfileRow" onclick="toggleAccountMenu(event)">
- <div class="ypg-pc-row-left">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
- <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
- <circle cx="12" cy="7" r="4" />
- </svg>
- <span id="pcCustomerProfileText">Using as Guest User</span>
- </div>
- <span class="ypg-pc-chevron">&rsaquo;</span>
- </div>
- </div>
-
- <!-- Bottom Isometric Shopping Bags Graphic -->
- <div style="margin-top:auto;">
- <div class="ypg-pc-bags-wrap">
- <svg viewBox="0 0 260 160" width="220" height="135" fill="none">
- <ellipse cx="130" cy="145" rx="100" ry="12" fill="rgba(0,0,0,0.18)" />
- <!-- White / Cyan shopping bag with blue handles -->
- <path d="M100 65 L135 60 L145 135 L90 140 Z" fill="#ffffff" stroke="#cbd5e1" stroke-width="1.5" />
- <path d="M100 65 L135 60 L140 85 L95 90 Z" fill="#f1f5f9" />
- <path d="M110 63 C110 48, 125 48, 125 61" stroke="#0284c7" stroke-width="3" fill="none"
- stroke-linecap="round" />
- <!-- Green shopping bag with % badge -->
- <path d="M140 75 L180 70 L195 135 L135 140 Z" fill="#10b981" stroke="#059669" stroke-width="1.5" />
- <path d="M150 73 C150 58, 168 58, 168 71" stroke="#047857" stroke-width="3" fill="none"
- stroke-linecap="round" />
- <circle cx="160" cy="98" r="14" fill="#34d399" />
- <text x="160" y="103" font-size="12" font-weight="900" fill="#064e3b" text-anchor="middle">%</text>
- <!-- Blue gift box with white ribbon -->
- <path d="M55 100 L95 95 L105 140 L50 142 Z" fill="#0284c7" />
- <path d="M50 100 L95 95 L95 105 L48 108 Z" fill="#38bdf8" />
- <rect x="71" y="96" width="7" height="45" fill="#ffffff" />
- </svg>
- </div>
- </div>
- </aside>
-
- <!-- PC RIGHT WORKSPACE WRAPPER -->
- <div class="ypg-pc-workspace">
- <!-- PC TOPBAR -->
- <div class="ypg-pc-topbar">
- <div class="ypg-pc-topbar-title">Payment Options</div>
- <div class="ypg-pc-topbar-actions" style="position: relative;">
- <button type="button" class="ypg-pc-btn-more" id="btnPcMore" onclick="toggleAccountMenu(event)" title="Options">•••</button>
- <button type="button" class="ypg-pc-btn-close" onclick="openCancelPaymentModal()"
- title="Close Checkout">✕</button>
-
- <!-- PC Account Popover Menu -->
- <div class="ypg-account-popover" id="accountMenuPopoverPc" hidden style="position: absolute; top: 40px; right: 0; background: #ffffff; color: var(--ypg-text-dark); border-radius: 12px; box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18); border: 1px solid var(--ypg-border); padding: 8px; z-index: 1000; min-width: 220px;">
- <div class="popoverCustomerName" id="popoverCustomerNamePc"
- style="padding:6px 10px 8px 10px; font-weight:700; font-size:12px; border-bottom:1px solid #f1f5f9; color:#0f172a; word-break:break-word;">
- Guest User</div>
- <button type="button" class="ypg-popover-item" onclick="openHelpModal()">
- <span>❓</span> Help & Support
- </button>
- <button type="button" class="ypg-popover-item" onclick="handleCustomerLogout()"
- style="color:var(--ypg-danger);">
- <span>🚪</span> Sign Out / Change Number
- </button>
- </div>
- </div>
- </div>
-
- <!-- 2. AUTHENTIC YOUPI PG HEADER -->
- <header class="ypg-header">
- <!-- Mobile Top Drag Handle -->
- <div class="ypg-drag-handle-bar"></div>
-
- <!-- Main Header Row -->
- <div class="ypg-header-main-row">
- <div class="ypg-header-left-group">
- <!-- Back Button -->
- <button type="button" class="ypg-btn-back" id="btnHeaderBack" onclick="cancelPayment()" title="Back">
- <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4"
- stroke-linecap="round" stroke-linejoin="round">
- <path d="M19 12H5M12 19l-7-7 7-7" />
- </svg>
- </button>
-
- <!-- Teal Merchant Avatar with White Initial -->
- <div class="ypg-merchant-avatar" id="merchantAvatarBox">
- <span id="merchantAvatarLetter">M</span>
- <img id="merchantAvatarImg" alt="Logo" style="display:none;" />
- </div>
-
- <!-- Merchant Name & YouPI PG Verified Business Badge -->
- <div class="ypg-merchant-text-group">
- <div class="ypg-merchant-name" id="headerMerchantName">{{MERCHANT_NAME}}</div>
- <div class="ypg-trusted-badge" id="headerTrustBadge">
- <svg class="ypg-green-shield" viewBox="0 0 24 24" fill="none">
- <path d="M12 2L3 6v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6l-9-4z" fill="#10b981" />
- <path d="M8.5 12l2.5 2.5 5-5" stroke="#ffffff" stroke-width="2.2" stroke-linecap="round"
- stroke-linejoin="round" />
- </svg>
- <span id="headerTrustBadgeText">YouPI PG Verified Business</span>
- </div>
- </div>
- </div>
-
- <!-- Right Profile Button (Toggles User Details Popover) -->
- <button type="button" class="ypg-btn-profile" id="btnProfileMenu" onclick="toggleAccountMenu(event)"
- title="User Profile">
- <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"
- stroke-linecap="round" stroke-linejoin="round">
- <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
- <circle cx="12" cy="7" r="4" />
- </svg>
- </button>
- </div>
-
- <!-- Header Sub-banner -->
- <div class="ypg-header-subbanner" id="headerSubbanner">
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
- stroke-linejoin="round">
- <circle cx="9" cy="21" r="1" />
- <circle cx="20" cy="21" r="1" />
- <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
- </svg>
- <span id="subbannerText">200+ orders verified this month by YouPI PG</span>
- </div>
-
- <!-- Account Popover Menu -->
- <div class="ypg-account-popover" id="accountMenuPopover" hidden>
- <div id="popoverCustomerName"
- style="padding:4px 8px 8px 8px; font-weight:700; font-size:12px; border-bottom:1px solid #f1f5f9; color:#0f172a;">
- Guest User</div>
- <button type="button" class="ypg-popover-item" onclick="openHelpModal()">
- <span>❓</span> Help & Support
- </button>
- <button type="button" class="ypg-popover-item" onclick="handleCustomerLogout()"
- style="color:var(--ypg-danger);">
- <span>🚪</span> Sign Out / Change Number
- </button>
- </div>
- </header>
-
- <!-- 3. SCROLLABLE BODY -->
- <main class="ypg-body">
-
- <!-- PRE-GATEWAY CUSTOMER AUTHENTICATION VIEW (WHATSAPP BERRY PROTOCOL OTP FLOW) -->
- <div id="preGatewayAuthView" hidden>
- <h2 class="ypg-page-title" id="authViewMainTitle">Sign in to Pay</h2>
- <div class="ypg-auth-box">
- <div class="ypg-auth-sub-desc" id="authViewSubTitle">Enter your 10-digit WhatsApp mobile number to continue
- </div>
-
- <!-- Saved Account (1-Tap Selection) -->
- <div class="ypg-saved-accs-wrapper" id="preAuthSavedAccountsContainer" hidden>
- <div
- style="font-size:11px; font-weight:800; color:var(--ypg-text-muted); text-transform:uppercase; margin-bottom:8px;">
- Saved Account
- </div>
- <div id="savedAccountsList"></div>
- </div>
-
- <!-- STEP 1: ENTER MOBILE NUMBER -->
- <div id="authStepMobile">
- <div class="ypg-input-group">
- <label class="ypg-input-label">WhatsApp Mobile Number</label>
- <div class="ypg-phone-input-wrap">
- <div class="ypg-phone-prefix">
- <span>🇮🇳</span>
- <span>+91</span>
- </div>
- <input type="tel" class="ypg-phone-control" id="authMobileInput" placeholder="10-digit mobile number"
- maxlength="10" inputmode="numeric" />
- </div>
- </div>
-
- <div
- style="font-size:12px; color:var(--ypg-text-muted); margin-bottom:14px; display:flex; align-items:center; gap:6px;">
- <span>💬</span>
- <span>We'll verify your mobile via WhatsApp OTP</span>
- </div>
-
- <button type="button" class="ypg-btn-auth-action" id="btnAuthContinue" onclick="handleAuthMobileSubmit()">
- <span>Continue</span> &rsaquo;
- </button>
- </div>
-
- <!-- STEP 2: NEW CUSTOMER SIGN UP (Shown only if user does NOT exist) -->
- <div id="authStepSignup" hidden>
- <div class="ypg-auth-badge-banner">
- <div>
- <span>Mobile: </span>
- <strong id="authSignupPhoneBadge">+91 </strong>
- </div>
- <button type="button" class="ypg-btn-link" onclick="goToAuthStep('mobile')">Change</button>
- </div>
-
- <div style="font-size:12.5px; color:var(--ypg-text-dark); font-weight:600; margin-bottom:12px;">
- New to YOUPI PG? Please enter your name and email to proceed:
- </div>
-
- <div class="ypg-input-group">
- <label class="ypg-input-label">Full Name</label>
- <input type="text" class="ypg-input-control" id="authSignupName" placeholder="e.g. Alex Sharma" />
- </div>
-
- <div class="ypg-input-group">
- <label class="ypg-input-label">Email Address</label>
- <input type="email" class="ypg-input-control" id="authSignupEmail"
- placeholder="e.g. [email protected]" />
- </div>
-
- <button type="button" class="ypg-btn-auth-action" id="btnAuthSignup" onclick="handleAuthSignupSubmit()">
- <span>Sign Up &amp; Send WhatsApp OTP</span> &rsaquo;
- </button>
- </div>
-
- <!-- STEP 3: OTP VERIFICATION (Shown for existing user login OR after signup) -->
- <div id="authStepOtp" hidden>
- <div class="ypg-auth-badge-banner" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
- <div>
- <span>Code sent to WhatsApp / SMS: </span>
- <strong id="authOtpPhoneBadge">+91 </strong>
- </div>
- <button type="button" class="ypg-btn-link" onclick="goToAuthStep('mobile')">Edit</button>
- </div>
-
- <div id="authOtpGreeting"
- style="font-size:12.5px; color:var(--ypg-text-dark); font-weight:600; margin-bottom:8px;">
- Enter the 6-digit code sent to your phone:
- </div>
-
- <div class="ypg-input-group">
- <input type="text" class="ypg-input-control ypg-otp-control" id="authOtpInput" placeholder="••••••"
- maxlength="6" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code"
- autocorrect="off" autocapitalize="off" spellcheck="false" />
- </div>
-
- <button type="button" class="ypg-btn-auth-action" id="btnAuthVerifyOtp"
- onclick="handleAuthVerifyOtpSubmit()">
- <span>Verify &amp; Continue to Pay</span> &rsaquo;
- </button>
-
- <div
- style="display:flex; justify-content:space-between; align-items:center; margin-top:14px; font-size:12px; color:var(--ypg-text-muted);">
- <div>
- Didn't receive code?
- <button type="button" class="ypg-btn-link" id="btnResendOtp" onclick="handleResendOtp()"
- style="margin-left:4px;">Resend OTP</button>
- </div>
- <span id="otpCountdownTimer" style="font-weight:600; color:#64748b;"></span>
- </div>
- </div>
-
- </div>
- </div>
-
- <!-- MAIN PAYMENT GATEWAY INTERFACE -->
- <div id="paymentGatewayInterface" hidden>
-
- <!-- DYNAMIC PAYMENT METHOD SELECTOR BAR (ONLINE / OFFLINE MODALITY TABS) -->
- <div id="paymentMethodSelectorBar" class="ypg-method-selector-bar" style="display:{{METHOD_SELECTOR_DISPLAY}};">
- <button type="button" class="ypg-method-tab active" id="tabMethodUpi" onclick="selectPaymentMethod('UPI')">
- <img src="/icons/upi.svg" alt="UPI" class="ypg-tab-icon" style="height:15px;" />
- <span>UPI QR</span>
- </button>
- <button type="button" class="ypg-method-tab" id="tabMethodCod" onclick="selectPaymentMethod('COD')"
- style="{{TAB_COD_STYLE}}">
- <img src="/icons/cash.svg" alt="COD" class="ypg-tab-icon" style="height:14px; width:14px;" />
- <span>Cash on Delivery</span>
- </button>
- <button type="button" class="ypg-method-tab" id="tabMethodCash"
- onclick="selectPaymentMethod('CASH_COUNTER')" style="{{TAB_CASH_STYLE}}">
- <img src="/icons/cash.svg" alt="Cash" class="ypg-tab-icon" style="height:14px; width:14px;" />
- <span>Cash</span>
- </button>
- <button type="button" class="ypg-method-tab" id="tabMethodCard"
- onclick="selectPaymentMethod('CARD_COUNTER')" style="{{TAB_CARD_STYLE}}">
- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:4px; vertical-align:middle;"><rect x="2" y="5" width="20" height="14" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>
- <span>Card</span>
- </button>
- </div>
-
- <!-- PC 2-SUB-COLUMN CONTAINER (Exact Razorpay Frame 002 layout on Desktop) -->
- <div class="ypg-pc-columns">
- <!-- PC LEFT METHODS SUB-COLUMN -->
- <div class="ypg-pc-methods-list" id="pcMethodsList">
- <!-- UPI Card -->
- <div class="ypg-pc-method-card is-active" id="pcMethodCardUpi" onclick="selectPaymentMethod('UPI')">
- <div class="ypg-pc-method-header">
- <img src="/icons/upi.svg" alt="UPI" style="height:15px; margin-right:6px; vertical-align:middle;" />
- <div class="ypg-pc-method-title">UPI QR</div>
- </div>
- <div class="ypg-pc-method-sub">Scan &amp; Pay via UPI Apps</div>
- <div class="ypg-pc-method-icons">
- <img class="ypg-pc-mini-icon" src="/icons/gpay.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.gpay" alt="GPay" />
- <img class="ypg-pc-mini-icon" src="/icons/phonepe.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.phonepe" alt="PhonePe" />
- <img class="ypg-pc-mini-icon" src="/icons/paytm.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.paytm" alt="Paytm" />
- <img class="ypg-pc-mini-icon" src="/icons/cred.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.cred" alt="CRED" />
- </div>
- </div>
-
- <!-- Cash at Till Card (Offline Mode) -->
- <div class="ypg-pc-method-card" id="pcMethodCardCash" onclick="selectPaymentMethod('CASH_COUNTER')" style="{{PC_CASH_STYLE}}">
- <div class="ypg-pc-method-header">
- <img src="/icons/cash.svg" alt="Cash" style="width:16px; height:16px; margin-right:6px; vertical-align:middle;" />
- <div class="ypg-pc-method-title">Cash at Till</div>
- <span class="ypg-pc-cash-pill">Counter</span>
- </div>
- <div class="ypg-pc-method-sub">Pay cash directly to cashier</div>
- <div class="ypg-pc-method-icons" style="margin-top:6px;">
- <span style="font-size:10.5px; font-weight:700; color:#15803d; background:#dcfce7; padding:2px 8px; border-radius:5px; display:inline-flex; align-items:center; gap:4px; border:1px solid #bbf7d0;">
- <img src="/icons/cash.svg" alt="Cash" style="width:12px; height:12px;" />
- Physical Cash
- </span>
- </div>
- </div>
-
- <!-- Card at Counter (Offline Mode) -->
- <div class="ypg-pc-method-card" id="pcMethodCardCard" onclick="selectPaymentMethod('CARD_COUNTER')" style="{{PC_CARD_STYLE}}">
- <div class="ypg-pc-method-header">
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:6px; vertical-align:middle; color:#475569;"><rect x="2" y="5" width="20" height="14" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>
- <div class="ypg-pc-method-title">Card at Counter</div>
- <span class="ypg-pc-cash-pill" style="background:#f1f5f9; color:#475569;">POS</span>
- </div>
- <div class="ypg-pc-method-sub">Swipe or tap card at POS desk</div>
- <div class="ypg-pc-method-icons" style="gap:5px; margin-top:6px; display:flex; align-items:center;">
- <img src="/icons/visa.svg" alt="Visa" style="height:15px; width:auto; object-fit:contain;" />
- <img src="/icons/mastercard.svg" alt="Mastercard" style="height:15px; width:auto; object-fit:contain;" />
- <img src="/icons/rupay.svg" alt="RuPay" style="height:15px; width:auto; object-fit:contain;" />
- </div>
- </div>
-
- <!-- Cash on Delivery (COD) Card (Online Mode) -->
- <div class="ypg-pc-method-card" id="pcMethodCardCod" onclick="selectPaymentMethod('COD')" style="{{PC_COD_STYLE}}">
- <div class="ypg-pc-method-header">
- <img src="/icons/cash.svg" alt="COD" style="width:16px; height:16px; margin-right:6px; vertical-align:middle;" />
- <div class="ypg-pc-method-title">Cash on Delivery</div>
- <span class="ypg-pc-cash-pill" style="background:#fef3c7; color:#92400e;">COD</span>
- </div>
- <div class="ypg-pc-method-sub">Pay physical cash at doorstep</div>
- <div class="ypg-pc-method-icons" style="margin-top:6px;">
- <span style="font-size:10.5px; font-weight:700; color:#b45309; background:#fef3c7; padding:2px 8px; border-radius:5px; display:inline-flex; align-items:center; gap:4px; border:1px solid #fde68a;">
- <img src="/icons/cash.svg" alt="COD" style="width:12px; height:12px;" />
- Doorstep Cash
- </span>
- </div>
- </div>
- </div>
-
- <!-- PC RIGHT ACTIVE PAYMENT WORKSPACE -->
- <div class="ypg-pc-active-view">
- <!-- VIEW A: PURE UPI QR INTERFACE -->
- <div id="viewUpiContent">
- <h2 class="ypg-page-title">UPI QR Payment</h2>
-
- <!-- Section Label & Countdown Timer -->
- <div class="ypg-section-label-row">
- <span class="ypg-section-heading">Scan &amp; Pay via UPI</span>
- <div class="ypg-countdown-pill" id="activeTimerBadge">
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
- stroke-width="2.2">
- <circle cx="12" cy="12" r="10" />
- <polyline points="12 6 12 12 16 14" />
- </svg>
- <span id="activeTimerText">05:00</span>
- </div>
- </div>
-
- <!-- UPI Server Health Indicator & Downtime Warning -->
- <div class="ypg-server-health-indicator {{SERVER_HEALTH_CLASS}}" id="upiServerHealthIndicator">
- <span class="ypg-pulse-dot" id="serverPulseDot"></span>
- <span id="serverStatusLabel">{{SERVER_HEALTH_LABEL}}</span>
- </div>
-
- <div class="{{DOWNTIME_ALERT_CLASS}}" id="serverDowntimeAlert" style="display:{{DOWNTIME_ALERT_STYLE}};">
- <div class="ypg-downtime-icon">
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
- </div>
- <div class="ypg-downtime-info">
- <div class="ypg-downtime-heading">{{DOWNTIME_HEADING}}</div>
- <div class="ypg-downtime-msg" id="serverDowntimeMsg">
- {{DOWNTIME_MSG}}
- </div>
- <button type="button" class="ypg-btn-downtime-alt" id="btnDowntimeCashAlt"
- onclick="switchMethodFromDowntime()" style="display:{{DOWNTIME_ALT_BTN_DISPLAY}};">
- {{DOWNTIME_ALT_BTN_LABEL}}
- </button>
- </div>
- </div>
-
- <!-- Core UPI QR Card -->
- <div class="ypg-qr-card-container">
- <!-- Left: QR Box -->
- <div class="ypg-qr-image-box" id="qrImageContainer">
- <div style="font-size:11px; color:#94a3b8; text-align:center;">Loading QR...</div>
- </div>
-
- <!-- Right: Prompt, UPI App Logos -->
- <div class="ypg-qr-details-col">
- <div class="ypg-qr-prompt-title">Scan the QR using any UPI App</div>
-
- <!-- Brand Logos Row (Zero Fake Offers) -->
- <div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:3px 0 6px 0;">
- <div class="ypg-upi-logos-row">
- <div class="ypg-app-icon" title="Google Pay"><img src="/icons/gpay.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.gpay" alt="GPay" /></div>
- <div class="ypg-app-icon" title="PhonePe"><img src="/icons/phonepe.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.phonepe" alt="PhonePe" />
- </div>
- <div class="ypg-app-icon" title="Paytm"><img src="/icons/paytm.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.paytm" alt="Paytm" /></div>
- <div class="ypg-app-icon" title="CRED"><img src="/icons/cred.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.cred" alt="CRED" /></div>
- <div class="ypg-app-icon" title="BHIM UPI"><img src="/icons/bhim.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.bhim" alt="BHIM" /></div>
- <div class="ypg-app-icon" title="Amazon Pay"><img src="/icons/amazonpay.png"
- onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.amazonpay"
- alt="Amazon Pay" /></div>
- </div>
- </div>
-
- <div style="font-size:12px; color:#64748b; line-height:1.4;">
- Open any UPI app on your phone to scan and pay directly.
- </div>
- </div>
- </div>
- <!-- UPI Payment Instructions Guide -->
- <div class="ypg-instructions-card">
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">1</div>
- <div>Open any UPI App on your phone (Google Pay, PhonePe, Paytm, CRED).</div>
- </div>
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">2</div>
- <div>Scan the QR code above and complete the payment of <strong>₹{{AMOUNT}}</strong>.</div>
- </div>
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">3</div>
- <div>Payment is detected automatically, or tap <strong>Continue</strong> below after paying.</div>
- </div>
- </div>
- </div>
-
- <!-- VIEW COD: CASH ON DELIVERY (ONLINE SELLING MODE) -->
- <div id="viewCodContent" hidden>
- <div class="ypg-section-label-row" style="margin-top:0; margin-bottom:12px;">
- <h2 class="ypg-page-title" style="margin-bottom:0;">Cash on Delivery (COD)</h2>
- <div class="ypg-countdown-pill" id="codTimerBadge">
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
- stroke-width="2.2">
- <circle cx="12" cy="12" r="10" />
- <polyline points="12 6 12 12 16 14" />
- </svg>
- <span id="codTimerText">05:00</span>
- </div>
- </div>
-
- <!-- COD Notice Pill -->
- <div class="ypg-offers-pill" style="background:#fef3c7; border-color:#fde68a;">
- <div class="ypg-offers-left">
- <div class="ypg-offer-icon-badge" style="background:#d97706; color:#fff; display:flex; align-items:center; justify-content:center;">
- <img src="/icons/cash.svg" alt="Cash" style="width:14px; height:14px;" />
- </div>
- <span style="color:#92400e; font-weight:700;">Pay Cash at Doorstep</span>
- </div>
- <div class="ypg-offers-right">
- <span style="color:#b45309;">Verified Purchase</span>
- </div>
- </div>
-
- <!-- Order Summary Card -->
- <div
- style="background:#ffffff; border:1px solid var(--ypg-border); border-radius:12px; padding:16px; margin:14px 0;">
- <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
- <span style="font-size:12px; color:#64748b; font-weight:600;">Payable on Delivery</span>
- <strong style="font-size:20px; font-weight:800; color:#0f172a;">₹{{AMOUNT}}</strong>
- </div>
- <div
- style="font-size:12px; color:#334155; line-height:1.5; border-top:1px dashed var(--ypg-border); padding-top:10px;">
- <div>Recipient: <strong id="codCustomerName">Customer</strong></div>
- <div>Contact: <span id="codCustomerPhone" style="font-family:monospace;">-</span></div>
- </div>
- </div>
-
- <!-- Doorstep Delivery Guide -->
- <div class="ypg-instructions-card">
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">1</div>
- <div>Review and confirm your Cash on Delivery order below.</div>
- </div>
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">2</div>
- <div>Merchant processes and ships your package directly to your destination.</div>
- </div>
- <div class="ypg-instruction-step">
- <div class="ypg-step-num">3</div>
- <div>Hand over <strong>₹{{AMOUNT}}</strong> in physical cash to the courier agent upon arrival.
- </div>
- </div>
- </div>
-
- <!-- Action Button with Pre-Purchase Confirmation -->
- <button type="button" class="ypg-btn-auth-action" id="btnConfirmCod" onclick="promptConfirmCodOrder()"
- style="background:#0d9f67; font-size:14px; padding:12px;">
- <span>Confirm &amp; Place COD Order (₹{{AMOUNT}})</span> &rsaquo;
- </button>
- </div>
-
- <!-- VIEW CASH: CASH AT BILLING TILL (OFFLINE SELLING MODE) -->
- <div id="viewCashContent" hidden>
- <h2 class="ypg-page-title">Pay with Cash at Till</h2>
-
- <div
- style="background:#f0fdf4; border:1px solid #bbf7d0; border-radius:12px; padding:16px; margin:14px 0; text-align:center;">
- <div
- style="font-size:12px; font-weight:700; color:#166534; text-transform:uppercase; letter-spacing:0.5px; margin-bottom:4px;">
- Amount Payable to Cashier</div>
- <div style="font-size:28px; font-weight:800; color:#15803d;">₹{{AMOUNT}}</div>
-
- <!-- Prominent Cashier Order ID Display -->
- <div
- style="margin-top:12px; padding-top:10px; border-top:1px dashed #86efac; display:flex; align-items:center; justify-content:center; gap:8px;">
- <span style="font-size:12px; font-weight:700; color:#166534;">Store Order ID:</span>
- <span class="cashierOrderIdDisplay"
- style="font-family:monospace; font-size:14.5px; font-weight:900; color:#0f172a; background:#ffffff; padding:3px 10px; border-radius:6px; border:1.5px solid #86efac; letter-spacing:0.5px;">#{{ORDER_ID}}</span>
- </div>
- </div>
-
- <!-- Counter Desk Instructions -->
- <div class="ypg-instructions-card">
- <div style="font-size:12.5px; font-weight:700; color:#0f172a; margin-bottom:8px;">Counter Desk
- Instructions</div>
- <p style="font-size:12px; color:#475569; line-height:1.5; margin:0;" id="cashCounterDeskNotice">
- {{COUNTER_INSTRUCTIONS}}
- </p>
- </div>
-
- <div class="ypg-live-observer-strip" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
- <div class="ypg-radar-dot" style="background:#2563eb; box-shadow:0 0 0 0 rgba(37,99,235,0.7);"></div>
- <span>Awaiting Cashier Confirmation at Billing Desk...</span>
- </div>
-
- <div style="font-size:12px; color:#64748b; text-align:center; padding:8px;">
- Present this screen and Order ID to the cashier. Your payment will automatically update once confirmed
- by staff.
- </div>
- </div>
-
- <!-- VIEW CARD: CARD AT POS MACHINE (OFFLINE SELLING MODE) -->
- <div id="viewCardContent" hidden>
- <h2 class="ypg-page-title">Pay with Card at Counter</h2>
- <div style="display:flex; align-items:center; justify-content:center; gap:8px; margin:6px 0 12px 0;">
- <img src="/icons/visa.svg" alt="Visa" style="height:16px; width:auto; object-fit:contain;" />
- <img src="/icons/mastercard.svg" alt="Mastercard" style="height:16px; width:auto; object-fit:contain;" />
- <img src="/icons/rupay.svg" alt="RuPay" style="height:16px; width:auto; object-fit:contain;" />
- </div>
-
- <div
- style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:12px; padding:16px; margin:14px 0; text-align:center;">
- <div
- style="font-size:12px; font-weight:700; color:#475569; text-transform:uppercase; letter-spacing:0.5px; margin-bottom:4px;">
- POS Terminal Charge</div>
- <div style="font-size:28px; font-weight:800; color:#0f172a;">₹{{AMOUNT}}</div>
-
- <!-- Prominent Cashier Order ID Display -->
- <div
- style="margin-top:12px; padding-top:10px; border-top:1px dashed #cbd5e1; display:flex; align-items:center; justify-content:center; gap:8px;">
- <span style="font-size:12px; font-weight:700; color:#475569;">Store Order ID:</span>
- <span class="cashierOrderIdDisplay"
- style="font-family:monospace; font-size:14.5px; font-weight:900; color:#0f172a; background:#ffffff; padding:3px 10px; border-radius:6px; border:1.5px solid #cbd5e1; letter-spacing:0.5px;">#{{ORDER_ID}}</span>
- </div>
- </div>
-
- <!-- Counter Desk Instructions -->
- <div class="ypg-instructions-card">
- <div style="font-size:12.5px; font-weight:700; color:#0f172a; margin-bottom:8px;">POS Terminal
- Instructions</div>
- <p style="font-size:12px; color:#475569; line-height:1.5; margin:0;" id="cardCounterDeskNotice">
- Please swipe, insert, or tap your credit or debit card on the store POS terminal at the billing
- desk.
- </p>
- </div>
-
- <div class="ypg-live-observer-strip" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
- <div class="ypg-radar-dot" style="background:#2563eb; box-shadow:0 0 0 0 rgba(37,99,235,0.7);"></div>
- <span>Awaiting Cashier Slip Verification...</span>
- </div>
-
- <div style="font-size:12px; color:#64748b; text-align:center; padding:8px;">
- Present this screen and Order ID to the cashier. Cashier will verify transaction and approve this
- checkout session.
- </div>
- </div>
-
- <!-- VIEW B: QUEUE VIEW (WHEN CHANNELS ARE OCCUPIED) -->
- <div id="viewQueuedContent" hidden>
- <!-- Psychological Time-Saving Conversion Hook in Queue -->
- <div id="queueTimeSavingBanner" class="ypg-time-saving-banner" style="display:none;"></div>
-
- <div class="ypg-queue-container">
- <div style="font-size:16px; font-weight:800; color:#1e3a8a;">You Are In Line for Payment</div>
- <div class="ypg-queue-number" id="queueNumberDisplay">#1</div>
- <div style="font-size:13px; font-weight:700; color:#2563eb;">
- Estimated Wait: <span id="queueTimerText">00:30</span>
- </div>
- <div style="font-size:12px; color:#475569; margin-top:8px; line-height:1.4;">
- Your payment slot is reserved. You will be activated automatically the moment the current
- transaction finishes.
- </div>
- </div>
- </div>
-
- <!-- VIEW C: RAZORPAY AUTHENTIC PROCESSING / VERIFYING VIEW -->
- <div id="viewProcessingContent" hidden>
- <div
- style="padding:28px 16px 20px; display:flex; flex-direction:column; align-items:center; text-align:center;">
- <div class="rzp-sheet-title">Processing your payment</div>
- <div class="rzp-sheet-subtitle">This will only take a few seconds.</div>
- <div class="rzp-coin-stage">
- <div class="rzp-halo-ring"></div>
- <div class="rzp-3d-coin">
- <div class="rzp-coin-face rzp-coin-front">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- <div class="rzp-coin-face rzp-coin-back">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- </div>
- </div>
- <div style="font-size:12px; color:#64748b; margin-top:8px;">
- Bank verification in progress (<span id="procTimerText">30s</span>)
- </div>
- <button type="button" class="rzp-sheet-cancel-btn" onclick="openCancelPaymentModal()"
- style="max-width:320px;">Cancel</button>
- </div>
- </div>
-
- <!-- VIEW D: SUCCESS CELEBRATION VIEW -->
- <div id="viewSuccessContent" hidden>
- <div class="ypg-success-box">
- <div class="ypg-success-circle" id="successIconCircle">
- <svg class="ypg-check-svg" viewBox="0 0 24 24">
- <polyline class="ypg-check-path" points="20 6 9 17 4 12"></polyline>
- </svg>
- </div>
- <div class="ypg-success-title" id="successTitleText">Payment Successful!</div>
- <div class="ypg-success-amount" id="successAmountVal">₹{{AMOUNT}}</div>
- <div style="font-size:12px; color:var(--ypg-text-muted); margin-bottom:14px;" id="successDescText">
- Your payment was automatically verified by YouPI PG banking observers.
- </div>
- <div id="successCodDevApiBox"
- style="display:none; font-size:11.5px; background:#f1f5f9; padding:10px 14px; border-radius:8px; margin-bottom:14px; text-align:left; border:1px solid #e2e8f0;">
- <span style="font-weight:700; color:#334155;">Developer Order API:</span>
- <div
- style="word-break:break-all; font-family:monospace; color:#2563eb; margin-top:3px; font-size:11px;"
- id="successCodDevApiUrl"></div>
- </div>
- <a href="javascript:void(0)" class="btn-return-merchant" id="btnReturnStore">Return to Merchant</a>
- </div>
- </div>
-
- <!-- VIEW E: DEDICATED PAYMENT EXPIRED / FAILED VIEW (CLEAN & CENTERED) -->
- <div id="viewFailedContent" hidden>
- <div class="ypg-expired-box">
- <div class="ypg-expired-icon-wrap">
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"
- stroke-linejoin="round">
- <circle cx="12" cy="12" r="10" />
- <polyline points="12 6 12 12 16 14" />
- </svg>
- </div>
- <div class="ypg-expired-title" id="failedTitleText">Payment Session Expired</div>
- <div class="ypg-expired-desc" id="failedDescriptionText">
- The 5-minute active payment window elapsed before verification was completed. For security, please
- return to the store and initiate a new order.
- </div>
- <div class="ypg-expired-actions">
- <button type="button" class="ypg-btn-expired-primary" id="btnFailedAction"
- onclick="handleRetryNewPayment()">
- Try Again
- </button>
- <button type="button" class="ypg-btn-expired-secondary" onclick="openHelpModal()">
- Help & Support
- </button>
- </div>
- </div>
- </div>
-
- <!-- VIEW F: DEDICATED FRAUD / SECURITY ALERT & ACCESS BLOCKED VIEW -->
- <div id="viewBlockedContent" hidden>
- <div class="ypg-blocked-box">
- <div class="ypg-blocked-badge">
- <span class="ypg-blocked-badge-dot"></span>
- <span>Security Alert &bull; Under Investigation</span>
- </div>
- <div class="ypg-blocked-icon-wrap">
- <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
- <line x1="12" y1="8" x2="12" y2="12"/>
- <line x1="12" y1="16" x2="12.01" y2="16"/>
- </svg>
- </div>
- <div class="ypg-blocked-title" id="blockedTitleText">Fraudulent Activity Detected</div>
- <div class="ypg-blocked-subtitle" id="blockedSubtitleText">Payment Session Terminated &amp; Account Suspended</div>
-
- <div class="ypg-blocked-card">
- <p class="ypg-blocked-desc" id="blockedNoticeText">
- Our automated verification engine detected fraudulent payment activity associated with this transaction. Access has been immediately suspended to protect network integrity.
- </p>
- <div class="ypg-blocked-investigation">
- <span style="font-size:15px; line-height:1;">🔍</span>
- <span><strong>Investigation In Progress:</strong> Our fraud risk &amp; security operations team is reviewing the activity. Store administrator review is required before access can be restored.</span>
- </div>
- </div>
-
- <div class="ypg-blocked-details">
- <span class="ypg-blocked-details-label">Order Ref:</span>
- <span class="ypg-blocked-details-val" id="blockedOrderRefVal">-</span>
- <span class="ypg-blocked-details-label">Session ID:</span>
- <span class="ypg-blocked-details-val" id="blockedSessionIdVal">-</span>
- <span class="ypg-blocked-details-label">Status:</span>
- <span class="ypg-blocked-details-val" style="color:#ef4444; font-weight:800;">ACCOUNT BLOCKED</span>
- <span class="ypg-blocked-details-label">Timestamp:</span>
- <span class="ypg-blocked-details-val" id="blockedTimestampVal">-</span>
- </div>
-
- <div style="display:flex; flex-direction:column; gap:8px; width:100%; max-width:340px;">
- <button type="button" class="ypg-btn-blocked-exit" onclick="handleBlockedExit()">
- <span>Return to Merchant Store</span>
- </button>
- <button type="button" onclick="openHelpModal()" style="background:none; border:none; color:#64748b; font-size:12px; font-weight:600; cursor:pointer; text-decoration:underline; padding:6px;">
- Need help? View Security Case Reference
- </button>
- </div>
- </div>
- </div>
-
- <!-- VIEW G: DEDICATED DUPLICATE SESSION DETECTED VIEW (DEVICE BINDING SECURITY) -->
- <div id="viewDuplicateSessionContent" hidden>
- <div class="ypg-duplicate-box">
- <div class="ypg-duplicate-badge">
- <span class="ypg-duplicate-badge-dot"></span>
- <span>Device Security Check</span>
- </div>
- <div class="ypg-duplicate-icon-wrap">
- <svg viewBox="0 0 24 24" width="34" height="34" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
- <line x1="8" y1="21" x2="16" y2="21"/>
- <line x1="12" y1="17" x2="12" y2="21"/>
- <line x1="12" y1="7" x2="12" y2="10"/>
- <line x1="12" y1="13" x2="12.01" y2="13"/>
- </svg>
- </div>
- <div class="ypg-duplicate-title" id="dupSessionTitleText">Duplicate Session Detected</div>
- <div class="ypg-duplicate-subtitle" id="dupSessionSubtitleText">Payment Session Active on Another Device</div>
-
- <div class="ypg-duplicate-card">
- <p class="ypg-duplicate-desc" style="font-weight:700; color:#0f172a; margin-bottom:6px;">
- This payment session was created on another device.
- </p>
- <p class="ypg-duplicate-desc" style="color:#64748b; font-size:12.5px;">
- For security reasons, this session cannot be continued from this device.
- </p>
- </div>
-
- <div style="display:flex; flex-direction:column; gap:8px; width:100%; max-width:360px;">
- <button type="button" class="ypg-btn-duplicate-action" id="btnEndAndRestartPayment" onclick="handleEndAndStartNewPayment()">
- <span>END SESSION &amp; START NEW PAYMENT</span>
- </button>
- </div>
- </div>
- </div>
- </div>
-
- </div>
- </main>
-
- <!-- 4. AUTHENTIC STICKY BOTTOM FOOTER (SHOWN ONLY WHEN ACTIVE) -->
- <footer class="ypg-sticky-footer" id="ypgStickyFooter">
-
- <!-- Legal Disclaimer -->
- <div class="ypg-legal-disclaimer" id="footerLegalDisclaimer">
- Secured by YouPI PG & 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;"
- onclick="openHelpModal()">Privacy Notice</span>
- </div>
-
- <!-- Bottom Action Row: ₹5,500 View Details | Continue Button -->
- <div class="ypg-action-bottom-bar">
- <div class="ypg-amount-view-group">
- <div class="ypg-bottom-price" id="bottomAmountDisplay">₹{{AMOUNT}}</div>
- <button type="button" class="ypg-btn-view-details" onclick="toggleOrderDetails()">
- <span>View Details</span>
- <span id="chevronDetailsIcon">&#9652;</span>
- </button>
- </div>
-
- <!-- Continue CTA Button (Triggers Verification - only appears after 2 minutes elapsed) -->
- <button type="button" class="ypg-btn-continue" id="btnContinuePayment" onclick="submitPaymentDone()"
- style="display:none;">
- Payment Done — Check My Payment
- </button>
- </div>
-
- <!-- ORDER BREAKDOWN POPUP DRAWER -->
- <div class="ypg-details-drawer" id="orderDetailsDrawer">
- <div class="ypg-details-header">
- <span>Order Summary</span>
- <button type="button" onclick="toggleOrderDetails()"
- style="background:none; border:none; font-size:18px; cursor:pointer; color:#64748b;">✕</button>
- </div>
- <div class="ypg-details-row">
- <span>Order Reference</span>
- <strong id="drawerOrderId">{{ORDER_ID}}</strong>
- </div>
- <div class="ypg-details-row">
- <span>Merchant</span>
- <strong>{{MERCHANT_NAME}}</strong>
- </div>
-
- <div class="ypg-details-row">
- <span>Platform & Processing Fee</span>
- <span style="color:#10b981; font-weight:700;">₹0.00 (Zero Fee)</span>
- </div>
- <div class="ypg-details-row total">
- <span>Total Amount</span>
- <strong id="drawerTotalAmount">₹{{AMOUNT}}</strong>
- </div>
- </div>
- </footer>
-
- </div><!-- END ypg-pc-workspace -->
-
- <!-- HELP MODAL -->
- <div class="ypg-dialog-overlay" id="helpModal" hidden>
- <div class="ypg-dialog-card">
- <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
- <strong style="font-size:15px;" id="helpModalTitle">YouPI PG Help &amp; Support</strong>
- <button type="button" onclick="closeHelpModal()"
- style="background:none; border:none; font-size:18px; cursor:pointer; color:#64748b;">✕</button>
- </div>
- <div style="font-size:12px; color:#64748b; margin-bottom:12px;">For inquiries regarding your order or payment
- status:</div>
- <div id="helpModalEmailsContainer" style="margin-bottom:8px; font-size:12px;"></div>
- <div id="helpModalMobilesContainer" style="margin-bottom:12px; font-size:12px;"></div>
- <div id="helpModalLegalLinks"
- style="display:none; gap:12px; font-size:11.5px; margin-bottom:12px; padding-bottom:8px; border-bottom:1px solid #e2e8f0;">
- </div>
- <div style="font-size:11px; font-weight:700; color:#64748b; text-transform:uppercase; margin-bottom:4px;">
- Payment Case Info</div>
- <pre id="helpModalCaseInfoText"
- style="background:#f1f5f9; padding:8px; border-radius:6px; font-size:10px; color:#334155; white-space:pre-wrap; font-family:monospace; margin-bottom:12px;"></pre>
- <button type="button" class="ypg-btn-auth-action" onclick="copyCaseInfo()">
- <span id="copyCaseText">Copy Payment Case Details</span>
- </button>
- </div>
- </div>
-
- <!-- SINGLE ACTIVE SESSION CONFLICT MODAL -->
- <div class="ypg-dialog-overlay" id="activeConflictModal" hidden>
- <div class="ypg-dialog-card" style="max-width:380px; text-align:center;">
- <div
- style="width:48px; height:48px; border-radius:50%; background:#fef3c7; color:#d97706; display:flex; align-items:center; justify-content:center; font-size:24px; margin:0 auto 12px auto;">
- ⚠️</div>
- <strong style="font-size:16px; color:#0f172a; display:block; margin-bottom:6px;" id="conflictModalTitle">Active Session Detected</strong>
- <p style="font-size:12.5px; color:#475569; line-height:1.5; margin-bottom:16px;" id="conflictModalDesc">
- You already have an active payment session.
- </p>
- <div style="display:flex; flex-direction:column; gap:8px;">
- <button type="button" class="ypg-btn-auth-action" id="btnContinueExistingActive"
- onclick="continueExistingActivePayment()"
- style="background:#2563eb; color:#ffffff; font-size:13px; font-weight:700; padding:11px;">
- CONTINUE ACTIVE SESSION
- </button>
- <button type="button" class="ypg-btn-auth-action" id="btnEndSessionAndStartNew"
- onclick="executeRetryNewPayment()"
- style="background:#f1f5f9; color:#334155; border:1px solid #cbd5e1; font-size:12.5px; font-weight:600; padding:9px;">
- END SESSION &amp; START NEW PAYMENT
- </button>
- </div>
- </div>
- </div>
-
- <!-- RAZORPAY AUTHENTIC "PROCESSING YOUR PAYMENT" MODAL SHEET -->
- <div class="rzp-sheet-backdrop" id="rzpProcessingModal" hidden>
- <div class="rzp-sheet-dialog" style="position:relative;">
- <button type="button" class="rzp-btn-sheet-close" onclick="closeProcessingModal()" title="Back to QR"
- style="position:absolute; top:14px; right:14px; background:none; border:none; font-size:18px; cursor:pointer; color:#64748b; z-index:10; width:30px; height:30px; display:flex; align-items:center; justify-content:center; border-radius:50%; transition:background 0.15s;">✕</button>
- <div class="rzp-sheet-content">
- <div class="rzp-sheet-title" id="rzpProcessingTitle">Verifying Your Payment</div>
- <div class="rzp-sheet-subtitle" id="rzpProcessingSubtitle">Bank verification in progress. Please do not close
- or refresh this window.</div>
- <div class="rzp-coin-stage">
- <div class="rzp-halo-ring"></div>
- <div class="rzp-3d-coin">
- <div class="rzp-coin-face rzp-coin-front">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- <div class="rzp-coin-face rzp-coin-back">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- </div>
- </div>
- <div
- style="font-size:12px; color:#10b981; font-weight:700; display:flex; align-items:center; justify-content:center; gap:6px; margin-top:10px;">
- <span
- style="display:inline-block; width:7px; height:7px; border-radius:50%; background:#10b981; box-shadow:0 0 6px #10b981; animation:rzpHaloPulse 1.2s infinite;"></span>
- Checking UPI transaction in real-time...
- </div>
- <button type="button" class="rzp-sheet-cancel-btn" onclick="openCancelPaymentModal()"
- style="margin-top:12px;">Cancel Payment</button>
- <button type="button" onclick="closeProcessingModal()"
- style="background:none; border:none; color:#64748b; font-size:12px; font-weight:600; cursor:pointer; margin-top:8px; text-decoration:underline;">
- Return to QR Code
- </button>
- </div>
- </div>
- </div>
-
- <!-- RAZORPAY AUTHENTIC "CANCEL PAYMENT" CONFIRMATION MODAL SHEET -->
- <div class="rzp-sheet-backdrop" id="rzpCancelModal" hidden>
- <div class="rzp-sheet-dialog">
- <!-- State 1: Exit Door & Confirm Prompt -->
- <div id="rzpCancelPromptView"
- style="display:flex; flex-direction:column; align-items:center; text-align:center; padding-bottom:16px;">
- <div class="rzp-cancel-header-arc">
- <button type="button" class="rzp-btn-sheet-close" onclick="closeCancelPaymentModal()"
- title="Back">✕</button>
- <!-- Authentic Exit Door Illustration with EXIT sign & footprints -->
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120" width="88" height="62" fill="none">
- <rect x="65" y="10" width="30" height="13" rx="2" fill="#dc2626" stroke="#b91c1c" stroke-width="0.8" />
- <text x="80" y="19.5" font-family="-apple-system, BlinkMacSystemFont, Arial, sans-serif" font-size="7.5"
- font-weight="900" fill="#ffffff" text-anchor="middle" letter-spacing="0.8">EXIT</text>
- <path d="M50 23 H110 V90 H104 V27 H56 V90 H50 Z" fill="#94a3b8" />
- <rect x="54" y="26" width="52" height="64" fill="#f8fafc" opacity="0.6" />
- <path d="M55 27 L38 34 V97 L55 90 Z" fill="rgba(224, 242, 254, 0.75)" stroke="#64748b"
- stroke-width="1.8" />
- <path d="M53 30 L41 35 V93 L53 87 Z" fill="rgba(186, 230, 253, 0.45)" stroke="#94a3b8" stroke-width="1" />
- <rect x="44" y="60" width="3" height="10" rx="1" fill="#334155" />
- <path d="M105 27 L122 34 V97 L105 90 Z" fill="rgba(224, 242, 254, 0.75)" stroke="#64748b"
- stroke-width="1.8" />
- <path d="M107 30 L119 35 V93 L107 87 Z" fill="rgba(186, 230, 253, 0.45)" stroke="#94a3b8"
- stroke-width="1" />
- <rect x="113" y="60" width="3" height="10" rx="1" fill="#334155" />
- <line x1="30" y1="94" x2="130" y2="94" stroke="#cbd5e1" stroke-width="1.5" stroke-dasharray="2 2" />
- <g transform="translate(74, 80) rotate(-10) scale(0.65)" fill="#475569">
- <ellipse cx="4" cy="3" rx="3.5" ry="4.5" />
- <ellipse cx="4" cy="10" rx="2.5" ry="3" />
- </g>
- <g transform="translate(85, 88) rotate(12) scale(0.75)" fill="#334155">
- <ellipse cx="4" cy="3" rx="3.5" ry="4.5" />
- <ellipse cx="4" cy="10" rx="2.5" ry="3" />
- </g>
- <g transform="translate(71, 98) rotate(-8) scale(0.85)" fill="#1e293b">
- <ellipse cx="4" cy="3" rx="3.8" ry="4.8" />
- <ellipse cx="4" cy="11" rx="2.8" ry="3.2" />
- </g>
- <g transform="translate(87, 106) rotate(10) scale(0.95)" fill="#0f172a">
- <ellipse cx="4" cy="3" rx="4" ry="5" />
- <ellipse cx="4" cy="12" rx="3" ry="3.5" />
- </g>
- </svg>
- </div>
- <div
- style="padding:12px 20px 0; width:100%; display:flex; flex-direction:column; align-items:center; box-sizing:border-box;">
- <div class="rzp-sheet-title">
- <span class="pc-only-title">Are you sure you want to exit?</span>
- <span class="mob-only-title">Cancel Payment</span>
- </div>
- <div class="rzp-sheet-subtitle" style="margin-bottom:0; max-width:320px; line-height:1.45;">
- <span class="pc-only-sub">You will be taken back to <span
- class="cancelMerchantNameSpan">{{MERCHANT_NAME}}</span> website</span>
- <span class="mob-only-sub">Your payment is ongoing. Are you sure you want to cancel the payment?</span>
- </div>
- <button type="button" class="rzp-btn-wait" onclick="closeCancelPaymentModal()">
- <span class="pc-only-btn">Continue to payment</span>
- <span class="mob-only-btn">No, wait</span>
- </button>
- <button type="button" class="rzp-btn-confirm-cancel" onclick="confirmCancelPayment()">
- <span class="pc-only-btn">Yes, exit</span>
- <span class="mob-only-btn">Yes, Cancel</span>
- </button>
- </div>
- </div>
-
- <!-- State 2: Cancelling Payment with Running Coin -->
- <div id="rzpCancellingProgressView"
- style="display:none; padding:28px 20px 24px; flex-direction:column; align-items:center; text-align:center;">
- <div class="rzp-sheet-title">Cancelling Payment</div>
- <div class="rzp-sheet-subtitle">This will only take a few seconds.</div>
- <div class="rzp-coin-stage">
- <div class="rzp-halo-ring"></div>
- <div class="rzp-3d-coin">
- <div class="rzp-coin-face rzp-coin-front">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- <div class="rzp-coin-face rzp-coin-back">
- <div class="rzp-coin-inner-rim"></div>
- <div class="rzp-coin-sheen"></div>
- </div>
- </div>
- </div>
- <div class="rzp-secured-by">
- <span>Secured by</span>
- <strong style="color:#0f172a; font-weight:800;">{{APP_NAME}}</strong>
- </div>
- </div>
- </div>
- </div>
-
- </div>
-
- <script id="ypgInitialState" type="application/json">{{INITIAL_STATE_JSON}}</script>
- <script>
- const PAYMENT_ID = "{{PAYMENT_ID}}";
- const API_BASE = "{{API_BASE_URL}}";
-
- let state = null;
- let countdownTimer = null;
- let queuePollTimer = null;
- let sse = null;
- let activeCustomer = null;
- let activeToken = null;
-
- const STORAGE_KEY_IDENTITY = 'youpi.customer.identity';
- const STORAGE_KEY_ACCOUNTS = 'youpi.customer.accounts';
- const STORAGE_KEY_ACTIVE = 'youpi.customer.activeId';
- const MAX_IDENTITY_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days (maximum 1 week)
-
- function getPreservedIdentity() {
- try {
- const raw = localStorage.getItem(STORAGE_KEY_IDENTITY);
- if (!raw) return null;
- const data = JSON.parse(raw);
- if (!data || !data.customer) {
- clearPreservedIdentity();
- return null;
- }
- const now = Date.now();
- const expiry = data.expiresAt || ((data.savedAt || now) + MAX_IDENTITY_AGE_MS);
- if (now > expiry) {
- console.log('[Auth] Preserved identity expired (> 1 week). Purging.');
- clearPreservedIdentity();
- return null;
- }
- return data;
- } catch {
- return null;
- }
- }
-
- function savePreservedIdentity(cust, token) {
- if (!cust || !cust.id) return;
- try {
- const now = Date.now();
- const cleanCust = {
- id: cust.id,
- name: cust.name || cust.fullName || 'Customer',
- email: cust.email || '',
- mobileNumber: cust.mobileNumber || cust.phoneNumber || '',
- status: cust.status || 'ACTIVE'
- };
- const resolvedToken = token || activeToken || localStorage.getItem('ypg_customer_token') || null;
- const payload = {
- customer: cleanCust,
- token: resolvedToken,
- savedAt: now,
- expiresAt: now + MAX_IDENTITY_AGE_MS
- };
- // 1. Preserve 1-week identity
- localStorage.setItem(STORAGE_KEY_IDENTITY, JSON.stringify(payload));
- // 2. Strict single-user saved account store
- localStorage.setItem(STORAGE_KEY_ACCOUNTS, JSON.stringify([cleanCust]));
- localStorage.setItem(STORAGE_KEY_ACTIVE, cust.id);
- if (resolvedToken) {
- localStorage.setItem('ypg_customer_token', resolvedToken);
- }
- } catch { }
- }
-
- function clearPreservedIdentity() {
- try {
- localStorage.removeItem(STORAGE_KEY_IDENTITY);
- localStorage.removeItem(STORAGE_KEY_ACCOUNTS);
- localStorage.removeItem(STORAGE_KEY_ACTIVE);
- localStorage.removeItem('ypg_customer_token');
- } catch { }
- }
-
- // Immediately restore 1-week preserved identity if present
- const initPreserved = getPreservedIdentity();
- if (initPreserved && initPreserved.customer) {
- activeCustomer = initPreserved.customer;
- activeToken = initPreserved.token || null;
- }
-
- // Notify parent if embedded in iframe
- if (window.parent !== window || location.search.includes('embedded=1')) {
- document.body.classList.add('is-embedded');
- try {
- window.parent.postMessage({ event: 'youpi.modal_ready', paymentId: PAYMENT_ID }, '*');
- } catch (e) { }
- }
-
- // Dismiss Initial Splash Screen smoothly after brief intro
- function dismissSplashScreen() {
- const splash = document.getElementById('ypgSplashScreen');
- if (splash && !splash.classList.contains('fade-out')) {
- setTimeout(() => {
- splash.classList.add('fade-out');
- }, 550);
- }
- }
-
- // Toast helper
- let toastTimer = null;
- function showOptionToast(msg) {
- const toast = document.getElementById('ypgToast');
- if (!toast) return;
- toast.textContent = msg;
- toast.classList.add('show');
- if (toastTimer) clearTimeout(toastTimer);
- toastTimer = setTimeout(() => {
- toast.classList.remove('show');
- }, 2500);
- }
-
- // Toggle Order Breakdown Drawer
- function toggleOrderDetails() {
- const drawer = document.getElementById('orderDetailsDrawer');
- const chevron = document.getElementById('chevronDetailsIcon');
- if (!drawer) return;
- const isOpen = drawer.classList.contains('open');
- if (isOpen) {
- drawer.classList.remove('open');
- if (chevron) chevron.innerHTML = '&#9652;';
- } else {
- drawer.classList.add('open');
- if (chevron) chevron.innerHTML = '&#9662;';
- }
- }
-
- // Failure redirect URL resolver
- function getFailedRedirectUrl() {
- const orderId = state?.orderId || '';
- const reason = state?.status || 'FAILED';
- const paymentId = typeof PAYMENT_ID !== 'undefined' ? PAYMENT_ID : (state?.id || '');
-
- let baseOrigin = '';
- if (state && state.returnUrl) {
- try {
- baseOrigin = new URL(state.returnUrl).origin;
- } catch (e) { }
- }
- if (!baseOrigin && document.referrer) {
- try {
- baseOrigin = new URL(document.referrer).origin;
- } catch (e) { }
- }
-
- const query = `orderId=${encodeURIComponent(orderId)}&reason=${encodeURIComponent(reason)}&paymentId=${encodeURIComponent(paymentId)}`;
- return baseOrigin ? `${baseOrigin}/order-failed?${query}` : `/order-failed?${query}`;
- }
-
- // Store return URL resolver (used when user cancels payment or returns to merchant store)
- function getStoreReturnUrl() {
- if (typeof state !== 'undefined' && state) {
- if (state.cancelUrl) {
- return state.cancelUrl;
- }
- if (state.returnUrl) {
- try {
- const parsed = new URL(state.returnUrl);
- return parsed.origin ? `${parsed.origin}/` : state.returnUrl;
- } catch (e) { }
- }
- }
- try {
- const params = new URLSearchParams(window.location.search);
- const cancelParam = params.get('cancelUrl') || params.get('cancel_url');
- if (cancelParam) return cancelParam;
- const qUrl = params.get('returnUrl') || params.get('storeUrl') || params.get('redirectUrl');
- if (qUrl) {
- const parsed = new URL(qUrl, window.location.origin);
- return parsed.origin ? `${parsed.origin}/` : qUrl;
- }
- } catch (e) { }
- if (document.referrer) {
- try {
- const refUrl = new URL(document.referrer);
- if (refUrl.host !== window.location.host) {
- return `${refUrl.origin}/`;
- }
- } catch (e) { }
- }
- if (window.location.port === '7000' || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
- return 'http://localhost:5000/';
- }
- return '/';
- }
-
- // Retry / Close on Expired or Failed session
- function handleRetryNewPayment() {
- const failRedirectUrl = getFailedRedirectUrl();
- const orderId = state?.orderId || '';
- const reason = state?.status || 'FAILED';
- const paymentId = typeof PAYMENT_ID !== 'undefined' ? PAYMENT_ID : (state?.id || '');
-
- const isEmbedded = (window.parent !== window) || location.search.includes('embedded=1');
-
- if (isEmbedded) {
- try {
- window.parent.postMessage({
- event: 'youpi.payment_failed',
- data: {
- orderId,
- reason,
- paymentId,
- status: reason,
- redirectUrl: failRedirectUrl
- },
- orderId,
- reason,
- paymentId,
- status: reason,
- redirectUrl: failRedirectUrl
- }, '*');
- } catch (e) { }
-
- // Fallback postMessage in case parent container only listens for modal_close
- try {
- window.parent.postMessage({
- event: 'youpi.modal_close',
- action: 'payment_failed',
- redirectUrl: failRedirectUrl
- }, '*');
- } catch (e) { }
- } else {
- // Standalone full page checkout
- window.location.href = failRedirectUrl;
- }
- }
-
- // --- ACTION HOOK ENGINE (Dispatches triggers to merchant website and backend telemetry) ---
- function emitTriggerHook(action, details = {}) {
- try {
- window.parent.postMessage({
- type: 'YOUPI_PAYMENT_HOOK',
- action,
- paymentId: PAYMENT_ID,
- orderId: state?.orderId,
- details
- }, '*');
- } catch { }
-
- fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/trigger-hook`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ action, details })
- }).catch(() => { });
- }
-
- // --- SAVED / REMEMBERED CUSTOMER ACCOUNT (STRICT SINGLE USER) ---
- function getRememberedAccounts() {
- try {
- const preserved = getPreservedIdentity();
- if (preserved && preserved.customer) {
- return [preserved.customer];
- }
- const raw = localStorage.getItem(STORAGE_KEY_ACCOUNTS);
- if (!raw) return [];
- const parsed = JSON.parse(raw);
- if (!Array.isArray(parsed) || parsed.length === 0) return [];
- return [parsed[0]]; // Strictly single user only
- } catch {
- return [];
- }
- }
-
- function saveRememberedAccount(cust, token) {
- if (!cust || !cust.id) return;
- savePreservedIdentity(cust, token);
- }
-
- function removeRememberedAccount(customerId, e) {
- if (e) {
- e.stopPropagation();
- e.preventDefault();
- }
- clearPreservedIdentity();
- if (activeCustomer && activeCustomer.id === customerId) {
- activeCustomer = null;
- activeToken = null;
- }
- updateCustomerDisplay(null);
- renderSavedAccountsUI();
- }
-
- function renderSavedAccountsUI() {
- const accounts = getRememberedAccounts();
- const container = document.getElementById('preAuthSavedAccountsContainer');
- const listEl = document.getElementById('savedAccountsList');
- const badge = document.getElementById('savedAccountCountBadge');
-
- if (badge) badge.style.display = 'none';
-
- if (container && listEl) {
- if (accounts.length > 0) {
- container.hidden = false;
- let html = '';
- accounts.slice(0, 1).forEach(acc => {
- const initial = (acc.name || 'U').charAt(0).toUpperCase();
- const isActive = activeCustomer && activeCustomer.id === acc.id;
- html += `
- <div class="saved-account-row ${isActive ? 'active' : ''}" onclick="handleSelectSavedAccount('${acc.id}', event)">
- <div style="display:flex; align-items:center; gap:8px;">
- <div style="width:28px; height:28px; border-radius:50%; background:#e0f2fe; color:#0369a1; font-weight:800; font-size:12px; display:flex; align-items:center; justify-content:center;">${initial}</div>
- <div>
- <div style="font-size:13px; font-weight:700;">${escapeHtml(acc.name)}</div>
- <div style="font-size:11px; color:#64748b;">${escapeHtml(acc.email || '')} ${acc.mobileNumber ? '&bull; ' + escapeHtml(acc.mobileNumber) : ''}</div>
- </div>
- </div>
- <div style="display:flex; align-items:center; gap:6px;">
- <button type="button" class="ypg-btn-select-account" style="background:#eff6ff; border:1px solid #bfdbfe; color:var(--ypg-blue); font-size:11px; font-weight:700; padding:4px 10px; border-radius:6px; cursor:pointer; display:inline-flex; align-items:center; gap:2px; transition:all 0.15s;" onclick="handleSelectSavedAccount('${acc.id}', event)">
- <span>Select</span> &rsaquo;
- </button>
- <button type="button" style="background:none; border:none; color:#94a3b8; font-size:14px; cursor:pointer; padding:2px 6px;" onclick="removeRememberedAccount('${acc.id}', event)" title="Remove Account">✕</button>
- </div>
- </div>
- `;
- });
- listEl.innerHTML = html;
- } else {
- container.hidden = true;
- listEl.innerHTML = '';
- }
- }
- }
-
- let currentAuthMobile = '';
- let currentAuthName = '';
- let currentAuthEmail = '';
- let currentAuthStep = 'mobile';
- let hasAttemptedAutoLogin = false;
- let otpCooldownTimer = null;
- let otpCooldownSec = 0;
-
- function setGatewayAuthMode(isAuthView) {
- const authEl = document.getElementById('preGatewayAuthView');
- const payEl = document.getElementById('paymentGatewayInterface');
- const footerEl = document.getElementById('ypgStickyFooter');
- const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
-
- if (isAuthView) {
- if (authEl) {
- authEl.hidden = false;
- authEl.style.removeProperty('display');
- }
- if (payEl) {
- payEl.hidden = true;
- payEl.style.setProperty('display', 'none', 'important');
- }
- if (footerEl) {
- footerEl.style.display = 'none';
- }
- if (pcTopbarTitle) {
- pcTopbarTitle.textContent = 'Sign in to Pay';
- }
- } else {
- if (authEl) {
- authEl.hidden = true;
- authEl.style.setProperty('display', 'none', 'important');
- }
- if (payEl) {
- payEl.hidden = false;
- payEl.style.removeProperty('display');
- }
- if (footerEl) {
- footerEl.style.display = '';
- }
- if (pcTopbarTitle) {
- pcTopbarTitle.textContent = 'Payment Options';
- }
- }
- }
-
- function goToAuthStep(step) {
- currentAuthStep = step;
- const stepMobile = document.getElementById('authStepMobile');
- const stepSignup = document.getElementById('authStepSignup');
- const stepOtp = document.getElementById('authStepOtp');
- const title = document.getElementById('authViewMainTitle');
- const subtitle = document.getElementById('authViewSubTitle');
- const savedAccountsBox = document.getElementById('preAuthSavedAccountsContainer');
-
- if (step === 'mobile') {
- if (stepMobile) stepMobile.hidden = false;
- if (stepSignup) stepSignup.hidden = true;
- if (stepOtp) stepOtp.hidden = true;
- if (savedAccountsBox && getRememberedAccounts().length > 0) savedAccountsBox.hidden = false;
- if (title) title.innerText = 'Sign in to Pay';
- if (subtitle) subtitle.innerText = 'Enter your 10-digit WhatsApp mobile number to continue';
- const input = document.getElementById('authMobileInput');
- if (input) {
- if (currentAuthMobile && !input.value) {
- input.value = currentAuthMobile;
- }
- if (document.activeElement !== input) {
- setTimeout(() => input.focus(), 50);
- }
- }
- } else if (step === 'signup') {
- if (stepMobile) stepMobile.hidden = true;
- if (stepSignup) stepSignup.hidden = false;
- if (stepOtp) stepOtp.hidden = true;
- if (savedAccountsBox) savedAccountsBox.hidden = true;
- if (title) title.innerText = 'Create Account';
- if (subtitle) subtitle.innerText = 'Complete your profile to proceed with instant checkout';
- const badge = document.getElementById('authSignupPhoneBadge');
- if (badge) badge.innerText = '+91 ' + currentAuthMobile;
- const nameInput = document.getElementById('authSignupName');
- const emailInput = document.getElementById('authSignupEmail');
- if (nameInput && currentAuthName && !nameInput.value) nameInput.value = currentAuthName;
- if (emailInput && currentAuthEmail && !emailInput.value) emailInput.value = currentAuthEmail;
- if (nameInput && document.activeElement !== nameInput && document.activeElement !== emailInput) {
- setTimeout(() => nameInput.focus(), 50);
- }
- } else if (step === 'otp') {
- if (stepMobile) stepMobile.hidden = true;
- if (stepSignup) stepSignup.hidden = true;
- if (stepOtp) stepOtp.hidden = false;
- if (savedAccountsBox) savedAccountsBox.hidden = true;
- if (title) title.innerText = 'Verify Mobile OTP';
- if (subtitle) subtitle.innerText = 'Enter the 6-digit code sent to your WhatsApp number';
- const badge = document.getElementById('authOtpPhoneBadge');
- if (badge) badge.innerText = '+91 ' + currentAuthMobile;
- const otpInput = document.getElementById('authOtpInput');
- if (otpInput) {
- otpInput.value = '';
- setTimeout(() => otpInput.focus(), 50);
- }
- startOtpCooldown(30);
- }
- }
-
- function startOtpCooldown(sec = 30) {
- clearInterval(otpCooldownTimer);
- otpCooldownSec = sec;
- const resendBtn = document.getElementById('btnResendOtp');
- const countdownEl = document.getElementById('otpCountdownTimer');
-
- const updateUI = () => {
- if (otpCooldownSec > 0) {
- if (resendBtn) {
- resendBtn.disabled = true;
- resendBtn.style.opacity = '0.5';
- resendBtn.style.cursor = 'not-allowed';
- }
- if (countdownEl) countdownEl.innerText = `(${otpCooldownSec}s)`;
- otpCooldownSec--;
- } else {
- clearInterval(otpCooldownTimer);
- if (resendBtn) {
- resendBtn.disabled = false;
- resendBtn.style.opacity = '1';
- resendBtn.style.cursor = 'pointer';
- }
- if (countdownEl) countdownEl.innerText = '';
- }
- };
-
- updateUI();
- otpCooldownTimer = setInterval(updateUI, 1000);
- }
-
- async function handleAuthMobileSubmit() {
- const input = document.getElementById('authMobileInput');
- const btn = document.getElementById('btnAuthContinue');
- const raw = input ? input.value : '';
- const clean = String(raw).replace(/\D/g, '').slice(-10);
-
- if (!clean || clean.length !== 10) {
- showOptionToast('Please enter a valid 10-digit mobile number');
- input?.focus();
- return;
- }
-
- currentAuthMobile = clean;
- const oldHtml = btn.innerHTML;
- btn.disabled = true;
- btn.innerHTML = '<span>Checking account...</span>';
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/customer/check-user`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ mobileNumber: clean })
- });
- const data = await res.json();
-
- if (!res.ok) {
- showOptionToast(data.error || 'Failed to check mobile number');
- return;
- }
-
- const accounts = getRememberedAccounts();
- const savedMatch = accounts.find(a => String(a.mobileNumber || '').replace(/\D/g, '').slice(-10) === clean);
-
- if (data.exists && data.customer) {
- // Existing customer in DB -> automatically send OTP and show OTP screen
- currentAuthName = data.customer.name;
- currentAuthEmail = data.customer.email;
- btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
-
- const sendRes = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: clean
- })
- });
- const sendData = await sendRes.json();
- if (sendData && sendData.devOtp) lastReceivedDevOtp = sendData.devOtp;
-
- const greetingEl = document.getElementById('authOtpGreeting');
- if (greetingEl) {
- greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(data.customer.name)}</strong>! Enter the 6-digit WhatsApp OTP:`;
- }
-
- goToAuthStep('otp');
- showOptionToast('OTP sent to your WhatsApp number!');
- } else if (savedMatch) {
- // Known customer in browser saved accounts -> dispatch OTP directly with saved profile
- currentAuthName = savedMatch.name || 'Customer';
- currentAuthEmail = savedMatch.email || '';
- btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
-
- const sendRes = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: clean,
- name: currentAuthName,
- email: currentAuthEmail
- })
- });
- const sendData = await sendRes.json();
- if (sendData && sendData.devOtp) lastReceivedDevOtp = sendData.devOtp;
-
- const greetingEl = document.getElementById('authOtpGreeting');
- if (greetingEl) {
- greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(currentAuthName)}</strong>! Enter the 6-digit WhatsApp OTP:`;
- }
-
- goToAuthStep('otp');
- showOptionToast('OTP sent to your WhatsApp number!');
- } else {
- // New customer -> prompt for name and email
- goToAuthStep('signup');
- }
- } catch (e) {
- showOptionToast('Network error checking mobile number.');
- } finally {
- btn.disabled = false;
- btn.innerHTML = oldHtml;
- }
- }
-
- async function handleAuthSignupSubmit() {
- const nameInput = document.getElementById('authSignupName');
- const emailInput = document.getElementById('authSignupEmail');
- const btn = document.getElementById('btnAuthSignup');
-
- const name = nameInput ? nameInput.value.trim() : '';
- const email = emailInput ? emailInput.value.trim() : '';
-
- if (!name) {
- showOptionToast('Please enter your full name');
- nameInput?.focus();
- return;
- }
- if (!email || !email.includes('@') || !email.includes('.')) {
- showOptionToast('Please enter a valid email address');
- emailInput?.focus();
- return;
- }
-
- currentAuthName = name;
- currentAuthEmail = email;
-
- const oldHtml = btn.innerHTML;
- btn.disabled = true;
- btn.innerHTML = '<span>Sending WhatsApp OTP...</span>';
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: currentAuthMobile,
- name,
- email,
- isNewUser: true
- })
- });
- const data = await res.json();
- if (data && data.devOtp) lastReceivedDevOtp = data.devOtp;
-
- if (res.ok) {
- const greetingEl = document.getElementById('authOtpGreeting');
- if (greetingEl) {
- greetingEl.innerHTML = `Hello <strong>${escapeHtml(name)}</strong>! Enter the 6-digit WhatsApp OTP:`;
- }
- goToAuthStep('otp');
- showOptionToast('WhatsApp verification code sent!');
- } else {
- showOptionToast(data.error || 'Failed to send WhatsApp OTP.');
- }
- } catch (e) {
- showOptionToast('Network error sending WhatsApp OTP.');
- } finally {
- btn.disabled = false;
- btn.innerHTML = oldHtml;
- }
- }
-
- async function handleAuthVerifyOtpSubmit() {
- const otpInput = document.getElementById('authOtpInput');
- const btn = document.getElementById('btnAuthVerifyOtp');
- const otp = otpInput ? otpInput.value.trim() : '';
-
- if (!otp || otp.length < 6) {
- showOptionToast('Please enter the 6-digit WhatsApp OTP');
- otpInput?.focus();
- return;
- }
-
- const oldHtml = btn.innerHTML;
- btn.disabled = true;
- btn.innerHTML = '<span>Verifying OTP...</span>';
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/customer/verify-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: currentAuthMobile,
- otp,
- name: currentAuthName,
- email: currentAuthEmail
- })
- });
- const data = await res.json();
-
- if (res.ok && data.customer) {
- activeCustomer = data.customer;
- activeToken = data.token;
- saveRememberedAccount(activeCustomer, activeToken);
-
- // Bind session
- await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/bind-customer`, {
- method: 'POST',
- headers: getApiHeaders({
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${activeToken}`
- }),
- body: JSON.stringify({ token: activeToken, customerId: activeCustomer.id })
- });
-
- emitTriggerHook('AUTH_COMPLETED', { customerId: activeCustomer.id });
-
- setGatewayAuthMode(false);
- updateCustomerDisplay(activeCustomer);
- loadState();
- showOptionToast(`Welcome, ${activeCustomer.name}! Verified via WhatsApp.`);
- } else {
- showOptionToast(data.error || 'Invalid or expired OTP. Please try again.');
- otpInput.select();
- }
- } catch (e) {
- showOptionToast('Network error verifying OTP.');
- } finally {
- btn.disabled = false;
- btn.innerHTML = oldHtml;
- }
- }
-
- async function handleResendOtp() {
- if (otpCooldownSec > 0) return;
- showOptionToast('Resending WhatsApp OTP...');
- try {
- const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: currentAuthMobile,
- name: currentAuthName,
- email: currentAuthEmail
- })
- });
- const data = await res.json();
- if (res.ok) {
- startOtpCooldown(30);
- showOptionToast('Fresh OTP dispatched to your WhatsApp number!');
- const otpInput = document.getElementById('authOtpInput');
- if (otpInput) {
- otpInput.value = '';
- otpInput.focus();
- }
- } else {
- showOptionToast(data.error || 'Failed to resend OTP.');
- }
- } catch (e) {
- showOptionToast('Network error resending OTP.');
- }
- }
-
- async function handleSelectSavedAccount(accountId, event) {
- if (event) {
- event.stopPropagation();
- }
- const accounts = getRememberedAccounts();
- const account = accounts.find(a => a.id === accountId);
- if (!account) return;
-
- const rawPhone = account.mobileNumber || '';
- const clean = String(rawPhone).replace(/\D/g, '').slice(-10);
-
- if (!clean || clean.length !== 10) {
- showOptionToast('Saved account does not have a valid 10-digit mobile number.');
- const input = document.getElementById('authMobileInput');
- if (input) {
- input.value = rawPhone;
- input.focus();
- }
- return;
- }
-
- currentAuthMobile = clean;
- currentAuthName = account.name || 'Customer';
- currentAuthEmail = account.email || '';
-
- const input = document.getElementById('authMobileInput');
- if (input) input.value = clean;
-
- // Provide visual loading feedback on the clicked button if present
- const selectBtn = event?.currentTarget?.querySelector?.('.ypg-btn-select-account') ||
- (event?.target?.classList?.contains('ypg-btn-select-account') ? event.target : null);
- const oldBtnHtml = selectBtn ? selectBtn.innerHTML : null;
- if (selectBtn) {
- selectBtn.disabled = true;
- selectBtn.innerHTML = '<span>Sending OTP...</span>';
- }
-
- showOptionToast(`Sending WhatsApp OTP to +91 ${clean}...`);
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/customer/send-otp`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- mobileNumber: clean,
- name: currentAuthName,
- email: currentAuthEmail
- })
- });
- const data = await res.json();
- if (data && data.devOtp) lastReceivedDevOtp = data.devOtp;
-
- if (!res.ok) {
- showOptionToast(data.error || 'Failed to send WhatsApp OTP.');
- return;
- }
-
- const greetingEl = document.getElementById('authOtpGreeting');
- if (greetingEl) {
- greetingEl.innerHTML = `Welcome back, <strong>${escapeHtml(account.name || 'Customer')}</strong>! Enter the 6-digit WhatsApp OTP:`;
- }
- const badge = document.getElementById('authOtpPhoneBadge');
- if (badge) badge.innerText = '+91 ' + clean;
-
- goToAuthStep('otp');
- showOptionToast('WhatsApp verification code sent!');
- } catch (err) {
- console.error('[Select Saved Account Error]:', err);
- showOptionToast('Network error sending WhatsApp OTP.');
- } finally {
- if (selectBtn && oldBtnHtml) {
- selectBtn.disabled = false;
- selectBtn.innerHTML = oldBtnHtml;
- }
- }
- }
-
- function updateCustomerDisplay(cust) {
- const displayName = cust
- ? `${cust.fullName || cust.name || 'Customer'} (${cust.mobileNumber || cust.phoneNumber || cust.email || ''})`
- : 'Guest User';
- const nameElMobile = document.getElementById('popoverCustomerName');
- if (nameElMobile) nameElMobile.textContent = displayName;
- const nameElPc = document.getElementById('popoverCustomerNamePc');
- if (nameElPc) nameElPc.textContent = displayName;
-
- const pcCustomerText = document.getElementById('pcCustomerProfileText');
- if (pcCustomerText) {
- if (!cust) {
- pcCustomerText.textContent = 'Using as Guest User';
- return;
- }
- const name = cust.fullName || cust.name || cust.customerName || '';
- const phone = cust.mobileNumber || cust.phoneNumber || '';
- const clean = phone ? String(phone).replace(/^\+91/, '').replace(/\D/g, '').slice(-10) : '';
- if (name && clean) {
- pcCustomerText.textContent = `Using as ${name} (+91 ${clean})`;
- } else if (name) {
- pcCustomerText.textContent = `Using as ${name}`;
- } else if (clean) {
- pcCustomerText.textContent = `Using as +91 ${clean}`;
- } else if (cust.email) {
- pcCustomerText.textContent = `Using as ${cust.email}`;
- } else {
- pcCustomerText.textContent = 'Using as Guest User';
- }
- }
- }
-
- function toggleAccountMenu(e) {
- if (e) {
- e.stopPropagation();
- e.preventDefault();
- }
- const isPc = window.innerWidth > 600 && !document.body.classList.contains('is-embedded-mobile');
- const popover = isPc
- ? (document.getElementById('accountMenuPopoverPc') || document.getElementById('accountMenuPopover'))
- : (document.getElementById('accountMenuPopover') || document.getElementById('accountMenuPopoverPc'));
- if (!popover) return;
-
- const isHidden = popover.hidden || popover.style.display === 'none' || popover.hasAttribute('hidden');
- if (isHidden) {
- popover.removeAttribute('hidden');
- popover.hidden = false;
- popover.style.display = 'block';
- const dismissHandler = (evt) => {
- if (!popover.contains(evt.target) &&
- !evt.target.closest('#btnProfileMenu') &&
- !evt.target.closest('.ypg-pc-btn-more') &&
- !evt.target.closest('#btnPcMore') &&
- !evt.target.closest('#pcCustomerProfileRow')) {
- popover.setAttribute('hidden', '');
- popover.hidden = true;
- popover.style.display = 'none';
- document.removeEventListener('click', dismissHandler);
- }
- };
- setTimeout(() => document.addEventListener('click', dismissHandler), 10);
- } else {
- popover.setAttribute('hidden', '');
- popover.hidden = true;
- popover.style.display = 'none';
- }
- }
-
- async function handleCustomerLogout() {
- const popoverMobile = document.getElementById('accountMenuPopover');
- if (popoverMobile) { popoverMobile.setAttribute('hidden', ''); popoverMobile.hidden = true; popoverMobile.style.display = 'none'; }
- const popoverPc = document.getElementById('accountMenuPopoverPc');
- if (popoverPc) { popoverPc.setAttribute('hidden', ''); popoverPc.hidden = true; popoverPc.style.display = 'none'; }
-
- if (activeToken) {
- try {
- await fetch(`${API_BASE}/api/v1/customer/logout`, {
- method: 'POST',
- headers: { 'Authorization': `Bearer ${activeToken}` }
- });
- } catch { }
- }
-
- clearPreservedIdentity();
- activeCustomer = null;
- activeToken = null;
- hasAttemptedAutoLogin = false;
- updateCustomerDisplay(null);
- setGatewayAuthMode(true);
- goToAuthStep('mobile');
- renderSavedAccountsUI();
- }
-
- function escapeHtml(str) {
- if (!str) return '';
- return String(str).replace(/[&<>"']/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[m]);
- }
-
- let currentSelectedMethod = 'UPI';
-
- function hideAllContent() {
- document.getElementById('viewUpiContent').hidden = true;
- const vCod = document.getElementById('viewCodContent');
- if (vCod) vCod.hidden = true;
- const vCash = document.getElementById('viewCashContent');
- if (vCash) vCash.hidden = true;
- const vCard = document.getElementById('viewCardContent');
- if (vCard) vCard.hidden = true;
- document.getElementById('viewProcessingContent').hidden = true;
- document.getElementById('viewSuccessContent').hidden = true;
- document.getElementById('viewFailedContent').hidden = true;
- document.getElementById('viewQueuedContent').hidden = true;
- const vBlocked = document.getElementById('viewBlockedContent');
- if (vBlocked) vBlocked.hidden = true;
- const vDup = document.getElementById('viewDuplicateSessionContent');
- if (vDup) vDup.hidden = true;
- }
-
- function formatTime(totalSec) {
- const m = Math.floor(totalSec / 60);
- const s = totalSec % 60;
- return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
- }
-
- let _activeCountdownTargetTime = null;
-
- function runCountdown(seconds, onTick, onDone, targetExpiresAt) {
- const targetTime = targetExpiresAt
- ? new Date(targetExpiresAt).getTime()
- : (_activeCountdownTargetTime || (Date.now() + (seconds || 300) * 1000));
-
- if (countdownTimer && _activeCountdownTargetTime && Math.abs(_activeCountdownTargetTime - targetTime) <= 2500) {
- return;
- }
-
- _activeCountdownTargetTime = targetTime;
- if (countdownTimer) clearInterval(countdownTimer);
-
- const calcRemaining = () => {
- return Math.max(0, Math.ceil((targetTime - Date.now()) / 1000));
- };
-
- const doTick = (sec) => {
- onTick(sec);
- const tStr = formatTime(sec);
- document.querySelectorAll('.ypg-banner-running-timer').forEach(el => {
- el.textContent = tStr;
- });
- };
- doTick(calcRemaining());
-
- countdownTimer = setInterval(() => {
- const remaining = calcRemaining();
- if (remaining <= 0) {
- clearInterval(countdownTimer);
- countdownTimer = null;
- _activeCountdownTargetTime = null;
- doTick(0);
- if (onDone) onDone();
- } else {
- doTick(remaining);
- }
- }, 1000);
- }
-
- function renderMethodSelectorBar(data) {
- const bar = document.getElementById('paymentMethodSelectorBar');
- const sellingMode = data.sellingMode || 'ONLINE';
- const enabledMethods = data.enabledMethods || ['UPI'];
-
- // Populate authenticated customer into COD view
- const c = data.customer || activeCustomer;
- if (c) {
- const nameEl = document.getElementById('codCustomerName');
- const phoneEl = document.getElementById('codCustomerPhone');
- if (nameEl) nameEl.textContent = c.fullName || c.name || 'Customer';
- if (phoneEl) phoneEl.textContent = c.phoneNumber || c.mobileNumber || '-';
- }
-
- // Maintain authentic 3-column desktop layout
- const pcMethodsList = document.getElementById('pcMethodsList');
- const pcActiveView = document.querySelector('.ypg-pc-active-view');
- const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
-
- if (pcMethodsList) pcMethodsList.style.removeProperty('display');
- if (pcActiveView) pcActiveView.style.width = '';
- if (pcTopbarTitle) pcTopbarTitle.textContent = 'Payment Options';
-
- // Mobile selector bar is visible only when more than 1 method is available
- if (bar) {
- bar.style.display = (!enabledMethods || enabledMethods.length <= 1) ? 'none' : 'flex';
- }
-
- const tabUpi = document.getElementById('tabMethodUpi');
- const tabCod = document.getElementById('tabMethodCod');
- const tabCash = document.getElementById('tabMethodCash');
- const tabCard = document.getElementById('tabMethodCard');
-
- if (tabUpi) tabUpi.style.display = 'inline-flex';
-
- const pcUpi = document.getElementById('pcMethodCardUpi');
- const pcCod = document.getElementById('pcMethodCardCod');
- const pcCash = document.getElementById('pcMethodCardCash');
- const pcCard = document.getElementById('pcMethodCardCard');
-
- if (pcUpi) pcUpi.style.display = 'block';
-
- if (sellingMode === 'ONLINE') {
- // Online Selling Mode:
- // COD works (configurable ON/OFF).
- // Cash on counter and Card on counter do NOT exist (hidden).
- if (tabCod) tabCod.style.display = enabledMethods.includes('COD') ? 'inline-flex' : 'none';
- if (tabCash) tabCash.style.display = 'none';
- if (tabCard) tabCard.style.display = 'none';
-
- if (pcCod) pcCod.style.display = enabledMethods.includes('COD') ? 'block' : 'none';
- if (pcCash) pcCash.style.display = 'none';
- if (pcCard) pcCard.style.display = 'none';
- } else {
- // Offline Selling Mode:
- // Cash works (configurable ON/OFF).
- // Card works (configurable ON/OFF).
- // COD does NOT exist (hidden).
- if (tabCod) tabCod.style.display = 'none';
- if (tabCash) tabCash.style.display = enabledMethods.includes('CASH_COUNTER') ? 'inline-flex' : 'none';
- if (tabCard) tabCard.style.display = enabledMethods.includes('CARD_COUNTER') ? 'inline-flex' : 'none';
-
- if (pcCod) pcCod.style.display = 'none';
- if (pcCash) pcCash.style.display = enabledMethods.includes('CASH_COUNTER') ? 'block' : 'none';
- if (pcCard) pcCard.style.display = enabledMethods.includes('CARD_COUNTER') ? 'block' : 'none';
- }
-
- if (!enabledMethods.includes(currentSelectedMethod)) {
- currentSelectedMethod = 'UPI';
- }
- updateMethodTabsUI(currentSelectedMethod);
- }
-
- function updateMethodTabsUI(method) {
- const tabs = [
- { id: 'tabMethodUpi', method: 'UPI' },
- { id: 'tabMethodCod', method: 'COD' },
- { id: 'tabMethodCash', method: 'CASH_COUNTER' },
- { id: 'tabMethodCard', method: 'CARD_COUNTER' }
- ];
- tabs.forEach(t => {
- const el = document.getElementById(t.id);
- if (!el) return;
- if (t.method === method) {
- el.classList.add('active');
- } else {
- el.classList.remove('active');
- }
- });
-
- const pcCards = [
- { id: 'pcMethodCardUpi', method: 'UPI' },
- { id: 'pcMethodCardCod', method: 'COD' },
- { id: 'pcMethodCardCash', method: 'CASH_COUNTER' },
- { id: 'pcMethodCardCard', method: 'CARD_COUNTER' }
- ];
- pcCards.forEach(c => {
- const el = document.getElementById(c.id);
- if (!el) return;
- if (c.method === method) {
- el.classList.add('is-active');
- } else {
- el.classList.remove('is-active');
- }
- });
- }
-
- function switchMethodFromDowntime() {
- const enabled = state?.enabledMethods || state?.branding?.enabledPaymentMethods || [];
- const sellingMode = state?.sellingMode || state?.branding?.sellingMode || 'OFFLINE';
- if (sellingMode === 'ONLINE' && enabled.includes('COD')) {
- selectPaymentMethod('COD');
- } else if (enabled.includes('CASH_COUNTER')) {
- selectPaymentMethod('CASH_COUNTER');
- }
- }
-
- async function selectPaymentMethod(method) {
- currentSelectedMethod = method;
- updateMethodTabsUI(method);
- hideAllContent();
-
- if (method === 'UPI') {
- document.getElementById('viewUpiContent').hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'flex';
- } else if (method === 'COD') {
- const vCod = document.getElementById('viewCodContent');
- if (vCod) vCod.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- } else if (method === 'CASH_COUNTER') {
- const vCash = document.getElementById('viewCashContent');
- if (vCash) vCash.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- } else if (method === 'CARD_COUNTER') {
- const vCard = document.getElementById('viewCardContent');
- if (vCard) vCard.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- }
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/select-method`, {
- method: 'POST',
- headers: getApiHeaders({ 'Content-Type': 'application/json' }),
- body: JSON.stringify({ method, deviceId: DeviceIdentity?.currentDeviceId })
- });
- const resData = await res.json();
- if (res.ok && resData) {
- state.method = method;
- if (resData.timeRemainingSeconds !== undefined) {
- state.timeRemainingSeconds = resData.timeRemainingSeconds;
- }
- if (resData.status) {
- state.status = resData.status;
- }
-
- if (method === 'COD') {
- runCountdown(resData.timeRemainingSeconds || 300, sec => {
- const el = document.getElementById('codTimerText');
- if (el) el.textContent = formatTime(sec);
- }, () => {
- const el = document.getElementById('codTimerText');
- if (el) el.textContent = 'Expired';
- fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
- loadState();
- });
- } else if (method === 'UPI') {
- if (resData.status === 'ACTIVE') {
- loadQrSvg();
- runCountdown(resData.timeRemainingSeconds || 300, sec => {
- const el = document.getElementById('activeTimerText');
- if (el) el.textContent = formatTime(sec);
- }, () => {
- const el = document.getElementById('activeTimerText');
- if (el) el.textContent = 'Expired';
- fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
- loadState();
- });
- } else if (resData.status === 'QUEUED') {
- loadState();
- }
- } else {
- // Offline Counter mode: no timer countdown
- if (countdownTimer) clearInterval(countdownTimer);
- }
- }
- } catch (e) {
- console.warn('selectPaymentMethod network error:', e);
- }
- }
-
- async function promptConfirmCodOrder() {
- const amt = state?.amount || '{{AMOUNT}}';
- if (!confirm(`Are you sure you want to confirm and place this Cash on Delivery (COD) order for ₹${amt}? You will pay in cash upon doorstep delivery.`)) {
- return;
- }
- await executeConfirmCodOrder();
- }
-
- async function executeConfirmCodOrder() {
- const btn = document.getElementById('btnConfirmCod');
- if (btn) {
- btn.disabled = true;
- btn.innerText = 'Placing Cash on Delivery Order...';
- }
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/confirm-cod`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' }
- });
- const data = await res.json();
- if (res.ok) {
- loadState();
- } else {
- alert(data.error || 'Failed to place COD order');
- if (btn) {
- btn.disabled = false;
- btn.innerHTML = '<span>Confirm &amp; Place COD Order (₹' + (state?.amount || '{{AMOUNT}}') + ')</span> &rsaquo;';
- }
- }
- } catch (e) {
- alert('Network error confirming COD order.');
- if (btn) {
- btn.disabled = false;
- btn.innerHTML = '<span>Confirm &amp; Place COD Order (₹' + (state?.amount || '{{AMOUNT}}') + ')</span> &rsaquo;';
- }
- }
- }
-
- // --- DEVICE IDENTITY & HARDWARE CONTEXT BINDING LAYER ---
- const DeviceIdentity = {
- dbName: 'youpi_device_keystore_v1',
- storeName: 'keys',
- currentDeviceId: null,
- currentDeviceToken: null,
-
- async openDb() {
- return new Promise((resolve) => {
- if (!window.indexedDB) {
- resolve(null);
- return;
- }
- const req = window.indexedDB.open(this.dbName, 1);
- req.onupgradeneeded = (e) => {
- const db = e.target.result;
- if (!db.objectStoreNames.contains(this.storeName)) {
- db.createObjectStore(this.storeName, { keyPath: 'id' });
- }
- };
- req.onsuccess = () => resolve(req.result);
- req.onerror = () => resolve(null);
- });
- },
-
- async getStoredRecord() {
- try {
- const db = await this.openDb();
- if (!db) return null;
- return new Promise((resolve) => {
- const tx = db.transaction(this.storeName, 'readonly');
- const store = tx.objectStore(this.storeName);
- const req = store.get('primary_device');
- req.onsuccess = () => resolve(req.result || null);
- req.onerror = () => resolve(null);
- });
- } catch {
- return null;
- }
- },
-
- async saveRecord(record) {
- try {
- const db = await this.openDb();
- if (!db) return;
- return new Promise((resolve) => {
- const tx = db.transaction(this.storeName, 'readwrite');
- const store = tx.objectStore(this.storeName);
- store.put({ id: 'primary_device', ...record });
- tx.oncomplete = () => resolve();
- tx.onerror = () => resolve();
- });
- } catch {}
- },
-
- collectSignals() {
- let canvasSig = '';
- try {
- const canvas = document.createElement('canvas');
- canvas.width = 120;
- canvas.height = 30;
- const ctx = canvas.getContext('2d');
- ctx.textBaseline = 'top';
- ctx.font = "14px 'Arial'";
- ctx.fillText('YouPI-PG-Device-Binding-2026', 2, 2);
- canvasSig = canvas.toDataURL().slice(-32);
- } catch {}
-
- let webglRenderer = '';
- try {
- const gl = document.createElement('canvas').getContext('webgl');
- if (gl) {
- const dbg = gl.getExtension('WEBGL_debug_renderer_info');
- if (dbg) webglRenderer = gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL);
- }
- } catch {}
-
- return {
- userAgent: navigator.userAgent || '',
- platform: navigator.platform || '',
- language: navigator.language || '',
- timezone: (Intl && Intl.DateTimeFormat) ? Intl.DateTimeFormat().resolvedOptions().timeZone : '',
- screenSignature: `${window.screen?.width || 0}x${window.screen?.height || 0}x${window.screen?.colorDepth || 24}`,
- hardwareConcurrency: navigator.hardwareConcurrency || 0,
- deviceMemory: navigator.deviceMemory || 0,
- webglRenderer,
- canvasSignature: canvasSig
- };
- },
-
- async getOrRegister() {
- if (this.currentDeviceId) {
- return { deviceId: this.currentDeviceId, deviceToken: this.currentDeviceToken };
- }
-
- // 1. Check local storage / session cache first
- let cachedId = localStorage.getItem('ypg_device_id');
- let cachedToken = localStorage.getItem('ypg_device_token');
-
- // 2. Check IndexedDB persistent store
- const stored = await this.getStoredRecord();
- if (stored?.deviceId) {
- this.currentDeviceId = stored.deviceId;
- this.currentDeviceToken = stored.deviceToken;
- localStorage.setItem('ypg_device_id', stored.deviceId);
- if (stored.deviceToken) localStorage.setItem('ypg_device_token', stored.deviceToken);
- return { deviceId: stored.deviceId, deviceToken: stored.deviceToken };
- }
-
- if (cachedId) {
- this.currentDeviceId = cachedId;
- this.currentDeviceToken = cachedToken;
- return { deviceId: cachedId, deviceToken: cachedToken };
- }
-
- // 3. Generate new Web Crypto key pair
- let publicKeyBase64 = '';
- try {
- if (window.crypto && window.crypto.subtle) {
- const keyPair = await window.crypto.subtle.generateKey(
- { name: 'ECDSA', namedCurve: 'P-256' },
- true,
- ['sign', 'verify']
- );
- const spki = await window.crypto.subtle.exportKey('spki', keyPair.publicKey);
- const bytes = new Uint8Array(spki);
- let binary = '';
- for (let i = 0; i < bytes.byteLength; i++) {
- binary += String.fromCharCode(bytes[i]);
- }
- publicKeyBase64 = btoa(binary);
- }
- } catch (e) {
- console.warn('[DeviceIdentity] Web Crypto keygen fallback:', e.message);
- }
-
- if (!publicKeyBase64) {
- publicKeyBase64 = btoa(`fallback-device-key-${Math.random()}-${Date.now()}`);
- }
-
- // 4. Register with YouPI backend
- const signals = this.collectSignals();
- try {
- const resp = await fetch(`${API_BASE}/api/v1/devices/register`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ publicKey: publicKeyBase64, signals })
- });
- const data = await resp.json();
- if (data?.deviceId) {
- this.currentDeviceId = data.deviceId;
- this.currentDeviceToken = data.deviceToken;
- localStorage.setItem('ypg_device_id', data.deviceId);
- if (data.deviceToken) localStorage.setItem('ypg_device_token', data.deviceToken);
-
- await this.saveRecord({
- deviceId: data.deviceId,
- deviceToken: data.deviceToken,
- publicKeyBase64,
- registeredAt: new Date().toISOString()
- });
-
- return { deviceId: data.deviceId, deviceToken: data.deviceToken };
- }
- } catch (err) {
- console.error('[DeviceIdentity] Registration error:', err);
- }
-
- return { deviceId: null, deviceToken: null };
- }
- };
-
- function getApiHeaders(customHeaders = {}) {
- const headers = { ...customHeaders };
- if (typeof DeviceIdentity !== 'undefined' && DeviceIdentity?.currentDeviceId) {
- headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
- }
- if (typeof DeviceIdentity !== 'undefined' && DeviceIdentity?.currentDeviceToken) {
- headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
- }
- const token = activeToken || (getPreservedIdentity()?.token) || localStorage.getItem('ypg_customer_token');
- if (token) {
- headers['Authorization'] = `Bearer ${token}`;
- headers['x-customer-token'] = token;
- }
- return headers;
- }
-
- async function loadState() {
- try {
- await DeviceIdentity.getOrRegister();
- const headers = getApiHeaders();
-
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/state`, { headers });
- const data = await res.json().catch(() => ({}));
-
- if (res.status === 409 || data.error === 'DUPLICATE_SESSION_DETECTED') {
- renderDuplicateSession(data);
- dismissSplashScreen();
- return;
- }
-
- if (!res.ok) {
- dismissSplashScreen();
- return;
- }
-
- renderState(data);
- dismissSplashScreen();
- } catch (e) {
- console.warn('loadState error:', e);
- dismissSplashScreen();
- }
- }
-
- function adjustHexColor(col, amt) {
- if (!col) return '#0957cb';
- try {
- let usePound = false;
- if (col[0] === '#') {
- col = col.slice(1);
- usePound = true;
- }
- if (col.length === 3) col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
- const num = parseInt(col, 16);
- let r = (num >> 16) + amt;
- if (r > 255) r = 255; else if (r < 0) r = 0;
- let b = ((num >> 8) & 0x00FF) + amt;
- if (b > 255) b = 255; else if (b < 0) b = 0;
- let g = (num & 0x0000FF) + amt;
- if (g > 255) g = 255; else if (g < 0) g = 0;
- return (usePound ? '#' : '') + (g | (b << 8) | (r << 16)).toString(16).padStart(6, '0');
- } catch {
- return col;
- }
- }
-
- function applyDynamicTheme(branding) {
- if (!branding) return;
- const primary = branding.primaryColor || '#0b63e5';
- const darkPrimary = adjustHexColor(primary, -25);
- const root = document.documentElement;
-
- root.style.setProperty('--ypg-blue', primary);
- root.style.setProperty('--ypg-blue-dark', darkPrimary);
-
- const theme = branding.headerTheme || 'gradient';
- const headerEl = document.querySelector('.ypg-header');
- const sidebarEl = document.querySelector('.ypg-pc-sidebar');
-
- if (theme === 'solid') {
- root.style.setProperty('--ypg-header-gradient', primary);
- if (headerEl) headerEl.style.background = primary;
- if (sidebarEl) sidebarEl.style.background = primary;
- } else if (theme === 'dark') {
- root.style.setProperty('--ypg-header-gradient', '#0b1329');
- if (headerEl) headerEl.style.background = '#0b1329';
- if (sidebarEl) sidebarEl.style.background = 'linear-gradient(180deg, #0b1329 0%, #030712 100%)';
- } else {
- const grad = `linear-gradient(180deg, ${primary} 0%, ${darkPrimary} 100%)`;
- root.style.setProperty('--ypg-header-gradient', grad);
- if (headerEl) headerEl.style.background = grad;
- if (sidebarEl) sidebarEl.style.background = grad;
- }
- }
-
- function renderHelpLegalLinks(branding) {
- const container = document.getElementById('helpModalLegalLinks');
- if (!container) return;
- let html = '';
- if (branding.privacyPolicyUrl) {
- html += `<a href="${branding.privacyPolicyUrl}" target="_blank" rel="noopener noreferrer" style="color:var(--ypg-blue); text-decoration:underline; font-weight:600;">Privacy Policy &nearr;</a>`;
- }
- if (branding.termsUrl) {
- html += `<a href="${branding.termsUrl}" target="_blank" rel="noopener noreferrer" style="color:var(--ypg-blue); text-decoration:underline; font-weight:600;">Terms of Service &nearr;</a>`;
- }
- container.innerHTML = html;
- container.style.display = html ? 'flex' : 'none';
- }
-
- function renderState(data) {
- state = data;
- const b = data.branding || {};
- const appName = b.appName || 'YouPI PG';
- const merchantName = data.merchantName || 'Merchant Checkout';
-
- // 1. Dynamic Title
- document.title = `${merchantName} · ${appName} Checkout`;
-
- // 2. Dynamic Colors & Header Theme
- applyDynamicTheme(b);
-
- // 3. Merchant Name & Avatar
- if (data.merchantName) {
- const nameEl = document.getElementById('headerMerchantName');
- if (nameEl) nameEl.textContent = data.merchantName;
- const letterEl = document.getElementById('merchantAvatarLetter');
- if (letterEl) letterEl.textContent = data.merchantName.charAt(0).toUpperCase();
- }
-
- // 4. Verified Trust Badge
- const trustBadgeEl = document.getElementById('headerTrustBadge');
- const trustBadgeTextEl = document.getElementById('headerTrustBadgeText');
- if (trustBadgeEl) {
- if (b.hideTrustBadge) {
- trustBadgeEl.style.display = 'none';
- } else {
- trustBadgeEl.style.display = 'inline-flex';
- if (trustBadgeTextEl) {
- trustBadgeTextEl.textContent = b.trustBadgeText || `${appName} Verified Business`;
- }
- }
- }
-
- // 5. Header Sub-banner
- const subbannerEl = document.getElementById('headerSubbanner');
- const subbannerTextEl = document.getElementById('subbannerText');
- if (subbannerEl) {
- if (b.hideSubbanner) {
- subbannerEl.style.display = 'none';
- } else {
- subbannerEl.style.display = 'flex';
- if (subbannerTextEl) {
- subbannerTextEl.textContent = b.subbannerText || b.sidebarNotice || `Verified & Protected by ${appName}`;
- }
- }
- }
-
- // 6. Time-Saving Conversion Banner
- if (b.hideTimeSavingBanner) {
- document.querySelectorAll('.ypg-time-saving-banner').forEach(el => el.style.setProperty('display', 'none', 'important'));
- }
-
-
- // Update PC Sidebar Details & Whitelabeling
- const pcMerchant = document.getElementById('pcMerchantName');
- if (pcMerchant) pcMerchant.textContent = data.merchantName || 'Merchant Name';
- const pcPrice = document.getElementById('pcPriceSummaryAmount');
- if (pcPrice && data.amount) pcPrice.textContent = `₹${data.amount}`;
- const pcAppBrand = document.getElementById('pcAppNameBrand');
- if (pcAppBrand) pcAppBrand.textContent = appName;
-
- // PC Avatar Logo Whitelabel
- const pcLogoImg = document.getElementById('pcMerchantAvatarImg');
- const pcLetterSpan = document.getElementById('pcMerchantAvatarLetter');
- if (b.logoUrl) {
- if (pcLogoImg) {
- pcLogoImg.src = b.logoUrl;
- pcLogoImg.style.display = 'block';
- }
- if (pcLetterSpan) pcLetterSpan.style.display = 'none';
- } else {
- if (pcLogoImg) pcLogoImg.style.display = 'none';
- if (pcLetterSpan) {
- pcLetterSpan.style.display = 'block';
- pcLetterSpan.textContent = (data.merchantName || 'M').charAt(0).toUpperCase();
- }
- }
-
- // PC Trust Badge Whitelabel
- const pcTrust = document.getElementById('pcTrustBadge');
- const pcTrustText = document.getElementById('pcTrustBadgeText');
- if (pcTrust) {
- if (b.hideTrustBadge) {
- pcTrust.style.display = 'none';
- } else {
- pcTrust.style.display = 'inline-flex';
- if (pcTrustText) {
- pcTrustText.textContent = b.trustBadgeText || `${appName} Trusted Business`;
- }
- }
- }
-
- // PC Social Proof / Subbanner Whitelabel
- const pcSocialWrap = document.getElementById('pcSocialProofWrap');
- const pcSocialProof = document.getElementById('pcSocialProofText');
- if (pcSocialWrap) {
- if (b.hideSubbanner) {
- pcSocialWrap.style.display = 'none';
- } else {
- pcSocialWrap.style.display = 'flex';
- if (pcSocialProof) {
- pcSocialProof.textContent = b.subbannerText || b.sidebarNotice || `500+ orders last month from ${data.merchantName || 'Merchant'}`;
- }
- }
- }
-
- const pcCustomerText = document.getElementById('pcCustomerProfileText');
- if (pcCustomerText) {
- const c = data.customer || activeCustomer || (typeof getPreservedIdentity === 'function' ? getPreservedIdentity()?.customer : null);
- if (c) {
- const name = c.fullName || c.name || c.customerName || '';
- const mobile = c.mobileNumber || c.phoneNumber || '';
- const clean = mobile ? String(mobile).replace(/^\+91/, '').replace(/\D/g, '').slice(-10) : '';
- if (name && clean) {
- pcCustomerText.textContent = `Using as ${name} (+91 ${clean})`;
- } else if (name) {
- pcCustomerText.textContent = `Using as ${name}`;
- } else if (clean) {
- pcCustomerText.textContent = `Using as +91 ${clean}`;
- } else if (c.email) {
- pcCustomerText.textContent = `Using as ${c.email}`;
- } else {
- pcCustomerText.textContent = 'Using as Guest User';
- }
- } else {
- pcCustomerText.textContent = 'Using as Guest User';
- }
- }
- document.querySelectorAll('.cancelMerchantNameSpan').forEach(el => {
- el.textContent = data.merchantName || 'Merchant';
- });
-
- // Update UPI Server Health Indicator (3-Tier Model: Green, Yellow, Red)
- const serverIndicator = data.upiServerIndicator || { status: 'WORKING', tier: 'GREEN', label: 'Server Is Working', isWorking: true };
- const healthPill = document.getElementById('upiServerHealthIndicator');
- const healthLabel = document.getElementById('serverStatusLabel');
- const downtimeAlert = document.getElementById('serverDowntimeAlert');
- const downtimeHeading = document.querySelector('#serverDowntimeAlert .ypg-downtime-heading');
- const downtimeMsg = document.getElementById('serverDowntimeMsg');
- const btnCashAlt = document.getElementById('btnDowntimeCashAlt');
-
- const tier = serverIndicator.tier || (serverIndicator.status === 'WORKING' ? 'GREEN' : (serverIndicator.status === 'BUSY' ? 'YELLOW' : 'RED'));
-
- if (healthPill) {
- if (tier === 'GREEN') {
- healthPill.className = 'ypg-server-health-indicator is-working';
- } else if (tier === 'YELLOW') {
- healthPill.className = 'ypg-server-health-indicator is-busy';
- } else {
- healthPill.className = 'ypg-server-health-indicator is-issues';
- }
- }
- if (healthLabel) {
- healthLabel.textContent = serverIndicator.label || (tier === 'GREEN' ? 'Server Is Working' : (tier === 'YELLOW' ? 'UPI Server Busy' : 'Server Facing Issues'));
- }
- if (downtimeAlert) {
- if (tier === 'GREEN') {
- downtimeAlert.style.display = 'none';
- } else if (tier === 'YELLOW') {
- downtimeAlert.style.display = 'flex';
- downtimeAlert.className = 'ypg-downtime-alert is-warning';
- if (downtimeHeading) downtimeHeading.textContent = 'UPI Server Busy';
- if (downtimeMsg) {
- downtimeMsg.textContent = serverIndicator.warning || 'Your payment may go through extra processing seconds.';
- }
- if (btnCashAlt) {
- btnCashAlt.style.display = (serverIndicator.recommendedAlternative === 'CASH') ? 'inline-block' : 'none';
- }
- } else {
- // RED
- downtimeAlert.style.display = 'flex';
- downtimeAlert.className = 'ypg-downtime-alert';
- if (downtimeHeading) downtimeHeading.textContent = 'UPI Server Facing Issues';
- if (downtimeMsg) {
- downtimeMsg.textContent = serverIndicator.warning || 'It is not recommended to pay by UPI right now as the server is facing downtime. We recommend paying by cash instead.';
- }
- if (btnCashAlt) {
- btnCashAlt.style.display = (serverIndicator.recommendedAlternative === 'CASH') ? 'inline-block' : 'none';
- }
- }
- }
-
- // CRITICAL INVARIANT: In all 3 states (Green, Yellow, Red), ALWAYS display the dynamic UPI QR code
- const upiCardContainer = document.querySelector('.ypg-qr-card-container');
- if (upiCardContainer) upiCardContainer.style.display = 'flex';
- const qrContainerBox = document.getElementById('qrImageContainer');
- if (qrContainerBox && (!qrContainerBox.querySelector('svg') || qrContainerBox.textContent.includes('Loading QR'))) {
- loadQrSvg();
- }
-
- // 7. Amount & Order IDs
- if (data.amount) {
- const formatted = `₹${data.amount}`;
- const bAmt = document.getElementById('bottomAmountDisplay');
- if (bAmt) bAmt.textContent = formatted;
- const dAmt = document.getElementById('drawerTotalAmount');
- if (dAmt) dAmt.textContent = formatted;
- const sAmt = document.getElementById('successAmountVal');
- if (sAmt) sAmt.textContent = formatted;
- }
- if (data.orderId || data.id) {
- const oId = data.orderId || data.id;
- const dOrder = document.getElementById('drawerOrderId');
- if (dOrder) dOrder.textContent = oId;
- const formattedOId = String(oId).startsWith('#') ? oId : `#${oId}`;
- document.querySelectorAll('.cashierOrderIdDisplay').forEach(el => {
- el.textContent = formattedOId;
- });
- }
- // Note: Payee VPA / UPI ID is strictly hidden from customer view in all screens
-
- // 8. In-Store Offline Counter Instructions
- const cashNoticeEl = document.getElementById('cashCounterDeskNotice');
- if (cashNoticeEl && b.counterInstructions) {
- cashNoticeEl.textContent = b.counterInstructions;
- }
- const cardNoticeEl = document.getElementById('cardCounterDeskNotice');
- if (cardNoticeEl && b.cardCounterInstructions) {
- cardNoticeEl.textContent = b.cardCounterInstructions;
- }
-
- // 9. Dynamic Logo
- const logoImg = document.getElementById('merchantAvatarImg');
- const letterSpan = document.getElementById('merchantAvatarLetter');
- if (b.logoUrl) {
- if (logoImg) {
- logoImg.src = b.logoUrl;
- logoImg.style.display = 'block';
- }
- if (letterSpan) letterSpan.style.display = 'none';
- } else {
- if (logoImg) logoImg.style.display = 'none';
- if (letterSpan) letterSpan.style.display = 'block';
- }
-
- // 10. Splash Screen Branding
- const splashLogo = document.getElementById('splashBrandLogo');
- const splashDefaultShield = document.getElementById('splashDefaultShield');
- const splashSecuredText = document.getElementById('splashSecuredByText');
- if (b.logoUrl && splashLogo) {
- splashLogo.src = b.logoUrl;
- splashLogo.style.display = 'block';
- if (splashDefaultShield) splashDefaultShield.style.display = 'none';
- }
- if (splashSecuredText) {
- splashSecuredText.textContent = b.hidePoweredBy ? (b.appName || '256-Bit Bank Encryption') : (b.appName || 'YouPI PG');
- }
-
- // 12. Legal Disclaimer Strip
- const legalDisclaimerEl = document.getElementById('footerLegalDisclaimer');
- if (legalDisclaimerEl) {
- if (b.hidePoweredBy) {
- legalDisclaimerEl.innerHTML = `Secured by 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;" onclick="openHelpModal()">Privacy &amp; Terms</span>`;
- } else {
- legalDisclaimerEl.innerHTML = `Secured by ${appName} &amp; 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;" onclick="openHelpModal()">Privacy Notice</span>`;
- }
- }
-
- // 13. Success Screen Description
- const 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.`;
- }
-
- // 14. Help Modal Title & Legal Links
- const helpTitle = document.getElementById('helpModalTitle');
- if (helpTitle) helpTitle.textContent = `${appName} Help & Support`;
- renderHelpLegalLinks(b);
-
- // 1. Conflict detection: single active payment session invariant
- const conflictModal = document.getElementById('activeConflictModal');
- if (data.hasActiveSessionConflict) {
- hideAllContent();
- if (conflictModal) conflictModal.hidden = false;
- if (data.conflictingSession && data.conflictingSession.id) {
- activeConflictSessionId = data.conflictingSession.id;
- const desc = document.getElementById('conflictModalDesc');
- if (desc) {
- desc.textContent = `You already have an active payment session (#${data.conflictingSession.orderId || data.conflictingSession.id.slice(0, 8)}) for ₹${data.conflictingSession.amount}. For security, only one active payment session is allowed per customer.`;
- }
- }
- if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
- if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
- return;
- } else {
- if (conflictModal) conflictModal.hidden = true;
- }
-
- // --- 2. TERMINAL PAYMENT STATES (TERMINAL & OVER) ---
- if (['SUCCESS', 'CANCELLED', 'EXPIRED', 'FAILED'].includes(data.status)) {
- if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
- if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
- setGatewayAuthMode(false);
-
- if (data.status === 'CANCELLED') {
- emitTriggerHook('CANCEL_CONFIRMED');
- closeProcessingModal();
- closeCancelPaymentModal();
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
-
- hideAllContent();
- const failedView = document.getElementById('viewFailedContent');
- if (failedView) failedView.hidden = false;
- const footer = document.getElementById('ypgStickyFooter');
- if (footer) footer.style.display = 'none';
-
- const titleEl = document.getElementById('failedTitleText');
- if (titleEl) titleEl.textContent = 'Payment Cancelled';
- const descEl = document.getElementById('failedDescriptionText');
- if (descEl) descEl.textContent = 'You cancelled this payment session. Click below to return to the store.';
-
- const btnAction = document.getElementById('btnFailedAction');
- if (btnAction) {
- btnAction.textContent = 'Back to Store';
- btnAction.onclick = () => {
- const storeUrl = getStoreReturnUrl();
- const isEmbedded = (window.parent && window.parent !== window) || location.search.includes('embedded=1');
- if (isEmbedded) {
- try {
- window.parent.postMessage({ event: 'youpi.modal_close', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.close', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.cancel', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.payment_cancelled', redirectUrl: storeUrl }, '*');
- } catch (e) {}
- } else if (storeUrl && storeUrl !== '#' && !storeUrl.startsWith('javascript:')) {
- window.location.href = storeUrl;
- } else {
- window.history.back();
- }
- };
- }
- return;
- }
-
- if (data.status === 'FAILED' || data.status === 'EXPIRED') {
- closeProcessingModal();
- closeCancelPaymentModal();
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
-
- hideAllContent();
- const failedView = document.getElementById('viewFailedContent');
- if (failedView) failedView.hidden = false;
- const footer = document.getElementById('ypgStickyFooter');
- if (footer) footer.style.display = 'none';
- emitTriggerHook('PAYMENT_FAILED', { status: data.status });
-
- const isExpired = data.status === 'EXPIRED';
- const titleEl = document.getElementById('failedTitleText');
- if (titleEl) titleEl.textContent = isExpired ? 'Payment Session Expired' : 'Payment Not Confirmed';
- const descEl = document.getElementById('failedDescriptionText');
- if (descEl) {
- descEl.textContent = isExpired
- ? 'The 5-minute active payment window elapsed before verification was completed. For security, please return to the store and initiate a new order.'
- : 'No matching UPI bank confirmation was detected during the verification window.';
- }
- const btnAction = document.getElementById('btnFailedAction');
- if (btnAction) {
- btnAction.textContent = isExpired ? 'Start New Payment' : 'Try Again';
- btnAction.onclick = () => retryNewPayment();
- }
- return;
- }
-
- if (data.status === 'SUCCESS') {
- closeProcessingModal();
- closeCancelPaymentModal();
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
-
- hideAllContent();
- const successView = document.getElementById('viewSuccessContent');
- if (successView) successView.hidden = false;
- const footer = document.getElementById('ypgStickyFooter');
- if (footer) footer.style.display = 'none';
- const amtEl = document.getElementById('successAmountVal');
- if (amtEl) amtEl.textContent = `₹${data.amount}`;
-
- const isCodOrder = data.method === 'COD' || data.verificationTag === 'COD_ORDER_PLACED';
- const titleEl = document.getElementById('successTitleText');
- const descEl = document.getElementById('successDescText');
- const codApiBox = document.getElementById('successCodDevApiBox');
- const codApiUrl = document.getElementById('successCodDevApiUrl');
-
- if (isCodOrder) {
- if (titleEl) titleEl.textContent = 'Order Placed (Cash on Delivery)!';
- if (descEl) descEl.textContent = `Your order #${data.orderId} was confirmed. Please keep ₹${data.amount} in cash ready for the courier agent upon arrival.`;
- if (codApiBox && codApiUrl) {
- codApiBox.style.display = 'block';
- codApiUrl.textContent = `${API_BASE}/api/v1/orders/${data.orderId}/cod`;
- }
- } else {
- if (titleEl) titleEl.textContent = 'Payment Successful!';
- if (descEl) descEl.textContent = 'Your payment was automatically verified by YouPI PG banking observers.';
- if (codApiBox) codApiBox.style.display = 'none';
- }
-
- emitTriggerHook('PAYMENT_COMPLETED', { amount: data.amount, method: data.method, isCod: isCodOrder });
-
- try {
- window.parent.postMessage({
- event: 'youpi.payment_success',
- data: data
- }, '*');
- } catch (e) { }
-
- const btnReturn = document.getElementById('btnReturnStore') || document.getElementById('btnReturnToStore');
- if (btnReturn && data.returnUrl) {
- btnReturn.hidden = false;
- btnReturn.href = data.returnUrl;
- if (window.parent === window) {
- setTimeout(() => { window.location.href = data.returnUrl; }, 2000);
- }
- } else if (btnReturn) {
- btnReturn.hidden = true;
- }
- return;
- }
- }
-
- // Sync payment methods & modality layout immediately to match merchant settings
- renderMethodSelectorBar(data);
-
- // Auto-bind customer to payment session helper
- if (typeof autoBindCustomerToSession !== 'function') {
- window.autoBindCustomerToSession = async function(customerId, token) {
- if (window.isAutoBindingSession || !PAYMENT_ID || !token || !customerId) return;
- window.isAutoBindingSession = true;
- try {
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/bind-customer`, {
- method: 'POST',
- headers: getApiHeaders({
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${token}`
- }),
- body: JSON.stringify({ token, customerId })
- });
- if (res.ok) {
- const boundData = await res.json().catch(() => null);
- if (boundData && boundData.status && boundData.status !== 'INITIATED') {
- loadState();
- }
- } else if (res.status === 401) {
- clearPreservedIdentity();
- activeCustomer = null;
- activeToken = null;
- setGatewayAuthMode(true);
- goToAuthStep('mobile');
- renderSavedAccountsUI();
- }
- } catch (e) {
- } finally {
- window.isAutoBindingSession = false;
- }
- };
- }
-
- // 3. Pre-Gateway Customer Authentication Gate (Preserves identity up to 1 week)
- if (data.customer) {
- activeCustomer = data.customer;
- } else if (!activeCustomer) {
- const preserved = getPreservedIdentity();
- if (preserved && preserved.customer) {
- activeCustomer = preserved.customer;
- activeToken = preserved.token || activeToken;
- }
- }
- const hasCustomer = Boolean(data.customer || activeCustomer);
-
- if (!hasCustomer) {
- setGatewayAuthMode(true);
- const stepMob = document.getElementById('authStepMobile');
- const isAlreadyOnMobile = stepMob && !stepMob.hidden;
- if (!currentAuthStep || (currentAuthStep === 'mobile' && !isAlreadyOnMobile)) {
- goToAuthStep('mobile');
- }
- renderSavedAccountsUI();
- return;
- }
-
- // Authenticated Customer
- if (activeCustomer) {
- updateCustomerDisplay(activeCustomer);
- // Automatically bind customer to the payment session if session is INITIATED or unbound
- if (activeToken && PAYMENT_ID && (!data.customer || data.status === 'INITIATED')) {
- window.autoBindCustomerToSession(activeCustomer.id, activeToken);
- }
- }
- setGatewayAuthMode(false);
-
- // Render psychological time-saving conversion banner
- renderTimeSavingBanners(data);
-
- // 3. Status Handling: BLOCKED, QUEUED, ACTIVE, PROCESSING, SUCCESS, FAILED, EXPIRED
- if (data.status === 'BLOCKED' || data.isBanned || data.fraudDetected) {
- renderBlockedState(data);
- return;
- }
-
- if (data.status === 'QUEUED') {
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
-
- hideAllContent();
- document.getElementById('viewQueuedContent').hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- document.getElementById('queueNumberDisplay').textContent = `#${data.queuePosition || 1}`;
- runCountdown(data.timeRemainingSeconds, sec => {
- document.getElementById('queueTimerText').textContent = formatTime(sec);
- }, () => loadState());
-
- if (!queuePollTimer) {
- queuePollTimer = setInterval(() => { loadState(); }, 1200);
- }
- return;
- }
-
- if (queuePollTimer) {
- clearInterval(queuePollTimer);
- queuePollTimer = null;
- }
-
- if (data.status === 'ACTIVE' || (data.status === 'INITIATED' && (data.timeRemainingSeconds > 0 || data.expiresAt))) {
- renderMethodSelectorBar(data);
-
- hideAllContent();
- if (currentSelectedMethod === 'COD') {
- const vCod = document.getElementById('viewCodContent');
- if (vCod) vCod.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
-
- runCountdown(data.timeRemainingSeconds || 300, sec => {
- const el = document.getElementById('codTimerText');
- if (el) el.textContent = formatTime(sec);
- }, () => {
- const el = document.getElementById('codTimerText');
- if (el) el.textContent = 'Expired';
- fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
- loadState();
- }, data.expiresAt);
- } else if (currentSelectedMethod === 'CASH_COUNTER') {
- const vCash = document.getElementById('viewCashContent');
- if (vCash) vCash.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- } else if (currentSelectedMethod === 'CARD_COUNTER') {
- const vCard = document.getElementById('viewCardContent');
- if (vCard) vCard.hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- } else {
- // Default: UPI QR (CRITICAL INVARIANT: ALWAYS SHOWS QR AND RUNS 5:00 TIMER REGARDLESS OF GREEN/YELLOW/RED)
- document.getElementById('viewUpiContent').hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'flex';
- loadQrSvg();
-
- const btnContinue = document.getElementById('btnContinuePayment');
-
- const remainingSec = (data.timeRemainingSeconds !== undefined && data.timeRemainingSeconds !== null) ? Number(data.timeRemainingSeconds) : 300;
- const targetExpiry = data.expiresAt || new Date(Date.now() + remainingSec * 1000).toISOString();
-
- if (remainingSec <= 0 && data.status === 'ACTIVE') {
- const tText = document.getElementById('activeTimerText');
- if (tText) tText.textContent = 'Expired';
- if (btnContinue) btnContinue.style.display = 'none';
- return;
- }
-
- // Initialize button hidden until 4:00 has elapsed
- if (btnContinue && remainingSec > 240) {
- btnContinue.style.display = 'none';
- } else if (btnContinue) {
- btnContinue.style.display = 'block';
- }
-
- runCountdown(remainingSec, sec => {
- const tText = document.getElementById('activeTimerText');
- if (tText) tText.textContent = formatTime(sec);
-
- // "Payment Done — Check My Payment" button appears after 4:00
- if (sec <= 240 && btnContinue) {
- btnContinue.style.display = 'block';
- } else if (btnContinue) {
- btnContinue.style.display = 'none';
- }
- }, () => {
- const tText = document.getElementById('activeTimerText');
- if (tText) tText.textContent = 'Expired';
- if (btnContinue) btnContinue.style.display = 'none';
- closeProcessingModal();
- fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/expire`, { method: 'POST' }).catch(() => { });
- loadState();
- }, targetExpiry);
- }
- return;
- }
-
- if (data.status === 'PROCESSING') {
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
-
- hideAllContent();
- document.getElementById('viewProcessingContent').hidden = false;
- document.getElementById('ypgStickyFooter').style.display = 'none';
- runCountdown(data.timeRemainingSeconds, sec => {
- document.getElementById('procTimerText').textContent = `${sec}s`;
- }, () => loadState(), data.expiresAt);
- return;
- }
-
-
- }
-
- // --- PSYCHOLOGICAL TIME-SAVING CONVERSION BANNER ---
- // Invariant: ONLY display when the customer is actively waiting in the UPI queue!
- function renderTimeSavingBanners(data) {
- const qBanner = document.getElementById('queueTimeSavingBanner');
- const uBanner = document.getElementById('upiTimeSavingBanner');
- if (uBanner) uBanner.style.display = 'none'; // NEVER show on active UPI session
-
- const isQueued = (data.status === 'QUEUED') || (Number(data.queuePosition || 0) > 0);
- if (!isQueued || !qBanner) {
- if (qBanner) qBanner.style.display = 'none';
- return;
- }
-
- const enabled = data.enabledMethods || ['UPI'];
- const sellingMode = data.sellingMode || 'OFFLINE';
-
- let altMethodCode = null;
- let altMethodName = null;
-
- if (sellingMode === 'ONLINE') {
- if (enabled.includes('COD')) {
- altMethodCode = 'COD';
- altMethodName = 'Cash on Delivery';
- } else if (enabled.includes('CARD')) {
- altMethodCode = 'CARD';
- altMethodName = 'Credit / Debit Card';
- } else if (enabled.includes('NETBANKING')) {
- altMethodCode = 'NETBANKING';
- altMethodName = 'Net Banking';
- } else if (enabled.includes('CARD_COUNTER')) {
- altMethodCode = 'CARD_COUNTER';
- altMethodName = 'Card Payment';
- }
- } else {
- // Offline selling mode (retail till / counter)
- if (enabled.includes('CASH_COUNTER')) {
- altMethodCode = 'CASH_COUNTER';
- altMethodName = 'Cash at Till';
- } else if (enabled.includes('CARD_COUNTER')) {
- altMethodCode = 'CARD_COUNTER';
- altMethodName = 'Card at Counter';
- }
- }
-
- // CRITICAL REQUIREMENT: If both cash and card are disabled by merchant, psychological conversion MUST NOT BE SHOWN!
- if (!altMethodCode || (!enabled.includes('COD') && !enabled.includes('CASH_COUNTER') && !enabled.includes('CARD') && !enabled.includes('CARD_COUNTER'))) {
- qBanner.style.display = 'none';
- return;
- }
-
- const timeSec = data.timeRemainingSeconds || (data.queuePosition ? data.queuePosition * 30 : 30);
- const initialTimerStr = formatTime(timeSec);
-
- const actionText = sellingMode === 'ONLINE'
- ? `Skip the UPI wait! Pay with <strong>${altMethodName}</strong> instantly without waiting for a UPI slot.`
- : `Don't wait in the UPI line! Pay with <strong>${altMethodName}</strong> right now to complete your purchase instantly.`;
-
- qBanner.innerHTML = `
- <div class="ypg-queue-conversion-card">
- <div class="ypg-queue-conversion-header">
- <div class="ypg-queue-conversion-badge"><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" style="display:inline-block; vertical-align:middle; margin-right:3px;"><path d="M12 2l2.4 7.2h7.6l-6 4.8 2.4 7.2-6.4-4.8-6.4 4.8 2.4-7.2-6-4.8h7.6z"/></svg>Instant Alternative</div>
- <div class="ypg-queue-conversion-pill">Save <span class="ypg-banner-running-timer">${initialTimerStr}</span></div>
- </div>
- <div class="ypg-queue-conversion-text">
- ${actionText}
- </div>
- <button type="button" class="ypg-btn-queue-switch" onclick="selectPaymentMethod('${altMethodCode}')">
- <span>Pay with ${altMethodName}</span>
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="9 18 15 12 9 6"/></svg>
- </button>
- </div>
- `;
- qBanner.style.display = 'block';
- }
-
- // --- PURE QR SVG LOADER (ALWAYS LOADS & SHOWS QR CODE REGARDLESS OF SERVER STATUS) ---
- async function loadQrSvg() {
- const container = document.getElementById('qrImageContainer');
- if (!container) return;
- try {
- const res = await fetch(`/checkout/${PAYMENT_ID}/qr.svg`);
- if (res.ok) {
- const svg = await res.text();
- if (svg && svg.includes('<svg')) {
- container.innerHTML = svg;
- return;
- }
- }
- } catch (e) {
- console.warn('loadQrSvg error:', e);
- }
- // Automatic retry to guarantee QR code is loaded
- setTimeout(async () => {
- try {
- const res = await fetch(`/checkout/${PAYMENT_ID}/qr.svg`);
- if (res.ok) {
- const svg = await res.text();
- if (svg && svg.includes('<svg')) {
- container.innerHTML = svg;
- }
- }
- } catch (e) {}
- }, 400);
- }
-
- function copyVpaId() {
- const vpa = (state?.payeeVpa || document.getElementById('displayVpaVal')?.textContent || '').trim();
- if (!vpa) return;
-
- const btn = document.getElementById('btnCopyVpa');
- const text = document.getElementById('copyVpaText');
- if (btn && text) {
- navigator.clipboard.writeText(vpa).then(() => {
- text.textContent = 'Copied!';
- btn.classList.add('copied');
- setTimeout(() => {
- text.textContent = 'Copy';
- btn.classList.remove('copied');
- }, 2000);
- }).catch(() => {
- text.textContent = 'Copied!';
- setTimeout(() => { text.textContent = 'Copy'; }, 2000);
- });
- }
- }
-
- // --- RAZORPAY AUTHENTIC "PROCESSING YOUR PAYMENT" MODAL SHEET ---
- function openProcessingModal(title = 'Processing your payment', subtitle = 'This will only take a few seconds.') {
- const modal = document.getElementById('rzpProcessingModal');
- const tEl = document.getElementById('rzpProcessingTitle');
- const sEl = document.getElementById('rzpProcessingSubtitle');
- if (tEl) tEl.textContent = title;
- if (sEl) sEl.textContent = subtitle;
- if (modal) {
- modal.hidden = false;
- requestAnimationFrame(() => modal.classList.add('active'));
- }
- }
-
- function closeProcessingModal() {
- const modal = document.getElementById('rzpProcessingModal');
- if (modal) {
- modal.classList.remove('active');
- setTimeout(() => { modal.hidden = true; }, 300);
- }
- }
-
- // --- RAZORPAY AUTHENTIC "CANCEL PAYMENT" CONFIRMATION MODAL SHEET ---
- function openCancelPaymentModal() {
- emitTriggerHook('CANCEL_CLICKED');
- document.body.style.overflow = 'hidden';
- const yBody = document.querySelector('.ypg-body');
- if (yBody) yBody.style.overflow = 'hidden';
-
- const modal = document.getElementById('rzpCancelModal');
- const promptView = document.getElementById('rzpCancelPromptView');
- const progressView = document.getElementById('rzpCancellingProgressView');
- if (promptView) promptView.style.display = 'flex';
- if (progressView) progressView.style.display = 'none';
- if (modal) {
- modal.hidden = false;
- requestAnimationFrame(() => modal.classList.add('active'));
- }
- }
-
- function closeCancelPaymentModal() {
- document.body.style.overflow = '';
- const yBody = document.querySelector('.ypg-body');
- if (yBody) yBody.style.overflow = '';
-
- const modal = document.getElementById('rzpCancelModal');
- if (modal) {
- modal.classList.remove('active');
- setTimeout(() => { modal.hidden = true; }, 300);
- }
- }
-
- async function confirmCancelPayment() {
- emitTriggerHook('CANCEL_CONFIRMED');
- if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
- if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
-
- const promptView = document.getElementById('rzpCancelPromptView');
- const progressView = document.getElementById('rzpCancellingProgressView');
- if (promptView) promptView.style.display = 'none';
- if (progressView) progressView.style.display = 'flex';
-
- try {
- await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/cancel`, {
- method: 'POST',
- headers: getApiHeaders()
- });
- } catch (e) { }
-
- // Smooth realistic delay matching Razorpay transition
- setTimeout(() => {
- document.body.style.overflow = '';
- const yBody = document.querySelector('.ypg-body');
- if (yBody) yBody.style.overflow = '';
-
- closeCancelPaymentModal();
- closeProcessingModal();
-
- const storeUrl = getStoreReturnUrl();
- const isEmbedded = (window.parent && window.parent !== window) || location.search.includes('embedded=1');
-
- if (isEmbedded) {
- try {
- window.parent.postMessage({ event: 'youpi.modal_close', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.close', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.cancel', redirectUrl: storeUrl }, '*');
- window.parent.postMessage({ event: 'youpi.payment_cancelled', redirectUrl: storeUrl }, '*');
- } catch (e) { }
- }
-
- loadState();
- }, 500);
- }
-
- // Direct invocation from header back button, close button, or inline links
- function cancelPayment() {
- openCancelPaymentModal();
- }
-
- // Listen for cancel requests from parent iframe cross button
- window.addEventListener('message', (e) => {
- if (e.data && e.data.event === 'youpi.request_cancel') {
- openCancelPaymentModal();
- }
- });
-
- // --- MANUAL PAYMENT DONE VERIFICATION ---
- async function submitPaymentDone() {
- openProcessingModal('Processing your payment', 'This will only take a few seconds.');
- emitTriggerHook('PAYMENT_DONE_CLICKED');
-
- try {
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/payment-done`, {
- method: 'POST'
- });
- if (res.ok) {
- loadState();
- }
- } catch (e) { }
- }
-
- // --- SINGLE ACTIVE PAYMENT SESSION CONFLICT RESOLUTION ---
- let activeConflictSessionId = null;
-
- async function executeRetryNewPayment() {
- try {
- const btn = document.getElementById('btnEndSessionAndStartNew');
- if (btn) {
- btn.disabled = true;
- btn.textContent = 'Activating new payment...';
- }
- const headers = { 'Content-Type': 'application/json' };
- if (typeof DeviceIdentity !== 'undefined') {
- if (DeviceIdentity.currentDeviceId) headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
- if (DeviceIdentity.currentDeviceToken) headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
- }
- const token = activeToken || localStorage.getItem('ypg_customer_token');
- if (token) {
- headers['Authorization'] = `Bearer ${token}`;
- headers['x-customer-token'] = token;
- }
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/retry-new-payment`, {
- method: 'POST',
- headers
- });
- if (res.ok) {
- const conflictModal = document.getElementById('activeConflictModal');
- if (conflictModal) conflictModal.hidden = true;
- await loadState();
- } else {
- const err = await res.json().catch(() => ({}));
- alert(err.error || 'Failed to retry payment');
- if (btn) {
- btn.disabled = false;
- btn.textContent = 'END SESSION & START NEW PAYMENT';
- }
- }
- } catch (e) {
- alert('Network error while retrying payment');
- const btn = document.getElementById('btnEndSessionAndStartNew');
- if (btn) {
- btn.disabled = false;
- btn.textContent = 'END SESSION & START NEW PAYMENT';
- }
- }
- }
-
- function continueExistingActivePayment() {
- if (activeConflictSessionId) {
- window.location.href = `/checkout/${activeConflictSessionId}`;
- } else {
- const conflictModal = document.getElementById('activeConflictModal');
- if (conflictModal) conflictModal.hidden = true;
- loadState();
- }
- }
-
-
-
- function renderBlockedState(data) {
- closeProcessingModal();
- closeCancelPaymentModal();
- if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
- if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
-
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
- const footer = document.getElementById('ypgStickyFooter');
- if (footer) footer.style.display = 'none';
-
- hideAllContent();
- const vBlocked = document.getElementById('viewBlockedContent');
- if (vBlocked) vBlocked.hidden = false;
-
- // Expand to full width on PC desktop split view
- const pcMethodsList = document.getElementById('pcMethodsList');
- if (pcMethodsList) pcMethodsList.style.setProperty('display', 'none', 'important');
- const pcActiveView = document.querySelector('.ypg-pc-active-view');
- if (pcActiveView) pcActiveView.style.width = '100%';
- const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
- if (pcTopbarTitle) pcTopbarTitle.textContent = 'Security Incident Investigation';
-
- const orderRef = data.orderId || state?.orderId || 'N/A';
- const orderEl = document.getElementById('blockedOrderRefVal');
- if (orderEl) orderEl.textContent = `#${orderRef}`;
-
- const sessEl = document.getElementById('blockedSessionIdVal');
- if (sessEl) sessEl.textContent = data.id || PAYMENT_ID || 'N/A';
-
- const timeEl = document.getElementById('blockedTimestampVal');
- if (timeEl) timeEl.textContent = new Date().toLocaleTimeString();
-
- if (data.blockedNotice?.title) {
- const titleEl = document.getElementById('blockedTitleText');
- if (titleEl) titleEl.textContent = data.blockedNotice.title;
- }
- if (data.blockedNotice?.subtitle) {
- const subEl = document.getElementById('blockedSubtitleText');
- if (subEl) subEl.textContent = data.blockedNotice.subtitle;
- }
- if (data.blockedNotice?.message) {
- const msgEl = document.getElementById('blockedNoticeText');
- if (msgEl) msgEl.textContent = data.blockedNotice.message;
- }
-
- emitTriggerHook('PAYMENT_BLOCKED', {
- reason: data.reason || data.blockedNotice?.reason || 'FRAUDULENT_PAYMENT_INJECTION',
- orderId: orderRef
- });
-
- try {
- window.parent.postMessage({
- event: 'youpi.payment_blocked',
- data: {
- status: 'BLOCKED',
- isBanned: true,
- orderId: orderRef,
- paymentId: data.id || PAYMENT_ID
- }
- }, '*');
- } catch (e) {}
- }
-
- function handleBlockedExit() {
- const failRedirectUrl = getFailedRedirectUrl();
- if (window.parent && window.parent !== window) {
- try {
- window.parent.postMessage({
- event: 'youpi.payment_blocked_exit',
- data: { status: 'BLOCKED', isBanned: true, orderId: state?.orderId }
- }, '*');
- } catch (e) {}
- }
- window.location.href = failRedirectUrl;
- }
-
- let lastDuplicateSessionPayload = null;
- function renderDuplicateSession(data) {
- lastDuplicateSessionPayload = data;
- if (countdownTimer) { clearInterval(countdownTimer); countdownTimer = null; }
- if (queuePollTimer) { clearInterval(queuePollTimer); queuePollTimer = null; }
- if (sse) { try { sse.close(); } catch(e){} sse = null; }
-
- const bar = document.getElementById('paymentMethodSelectorBar');
- if (bar) bar.style.display = 'none';
- const footer = document.getElementById('ypgStickyFooter');
- if (footer) footer.style.display = 'none';
-
- hideAllContent();
- const vDup = document.getElementById('viewDuplicateSessionContent');
- if (vDup) vDup.hidden = false;
-
- // Expand to full width on PC desktop split view
- const pcMethodsList = document.getElementById('pcMethodsList');
- if (pcMethodsList) pcMethodsList.style.setProperty('display', 'none', 'important');
- const pcActiveView = document.querySelector('.ypg-pc-active-view');
- if (pcActiveView) pcActiveView.style.width = '100%';
- const pcTopbarTitle = document.querySelector('.ypg-pc-topbar-title');
- if (pcTopbarTitle) pcTopbarTitle.textContent = 'Device Security Verification';
-
- emitTriggerHook('DUPLICATE_SESSION_DETECTED', {
- sessionId: data.session_id || PAYMENT_ID,
- action: 'END_SESSION_AND_CREATE_NEW'
- });
- }
-
- async function handleEndAndStartNewPayment() {
- const btn = document.getElementById('btnEndAndRestartPayment');
- if (btn) {
- btn.disabled = true;
- btn.innerHTML = '<span class="ypg-spinner" style="display:inline-block;width:15px;height:15px;border:2px solid #fff;border-top-color:transparent;border-radius:50%;animation:rzpRotate 0.8s linear infinite;margin-right:8px;vertical-align:middle;"></span> CREATING NEW PAYMENT...';
- }
-
- try {
- await DeviceIdentity.getOrRegister();
- const headers = { 'Content-Type': 'application/json' };
- if (DeviceIdentity.currentDeviceId) {
- headers['X-Device-Id'] = DeviceIdentity.currentDeviceId;
- }
- if (DeviceIdentity.currentDeviceToken) {
- headers['X-Device-Token'] = DeviceIdentity.currentDeviceToken;
- }
-
- const conflictingSessionId = lastDuplicateSessionPayload?.conflicting_session_id || activeConflictSessionId || null;
-
- const res = await fetch(`${API_BASE}/api/v1/checkout/${PAYMENT_ID}/end-and-restart-payment`, {
- method: 'POST',
- headers,
- body: JSON.stringify({
- deviceId: DeviceIdentity.currentDeviceId,
- conflictingSessionId
- })
- });
-
- const data = await res.json();
- if (data.success && (data.checkoutUrl || data.newSessionId)) {
- const targetUrl = data.checkoutUrl || `/checkout/${data.newSessionId}`;
- window.location.href = targetUrl;
- } else {
- alert(data.error || 'Failed to start new payment session. Please try again.');
- if (btn) {
- btn.disabled = false;
- btn.innerHTML = '<span>END SESSION &amp; START NEW PAYMENT</span>';
- }
- }
- } catch (err) {
- alert('Network error while starting new payment session.');
- if (btn) {
- btn.disabled = false;
- btn.innerHTML = '<span>END SESSION &amp; START NEW PAYMENT</span>';
- }
- }
- }
-
- // --- SSE REALTIME STREAM (AUTOMATIC OBSERVER & CASHIER INTEGRATION) ---
- function connectSse() {
- if (sse) {
- try { sse.close(); } catch (e) { }
- sse = null;
- }
-
- try {
- const devQuery = DeviceIdentity.currentDeviceId ? `?deviceId=${encodeURIComponent(DeviceIdentity.currentDeviceId)}` : '';
- const streamUrl = `${API_BASE}/api/v1/checkout/${PAYMENT_ID}/stream${devQuery}`;
- sse = new EventSource(streamUrl);
-
- const handleRealtimePayload = (event) => {
- try {
- const data = JSON.parse(event.data);
- if (data && (data.error === 'DUPLICATE_SESSION_DETECTED' || data.type === 'DUPLICATE_SESSION_DETECTED')) {
- renderDuplicateSession(data);
- } else if (data && (data.status === 'BLOCKED' || data.isBanned || data.fraudDetected || data.type === 'FRAUD_BLOCKED' || data.event === 'account_blocked')) {
- renderBlockedState(data);
- } else if (data && data.type === 'STATE_CHANGE' && data.payload) {
- renderState(data.payload);
- } else if (data && data.status) {
- if (data.status === 'BLOCKED' || data.isBanned) {
- renderBlockedState(data);
- } else {
- loadState();
- }
- } else {
- loadState();
- }
- } catch (e) {
- loadState();
- }
- };
-
- sse.onmessage = handleRealtimePayload;
- sse.addEventListener('status_change', handleRealtimePayload);
- sse.addEventListener('state_change', handleRealtimePayload);
- sse.addEventListener('account_blocked', handleRealtimePayload);
- sse.addEventListener('fraud_detected', handleRealtimePayload);
- sse.addEventListener('counter_payment_confirmed', handleRealtimePayload);
- sse.addEventListener('counter_payment_declined', handleRealtimePayload);
- sse.addEventListener('payment_success', handleRealtimePayload);
- sse.addEventListener('queue_cleared', handleRealtimePayload);
- sse.addEventListener('session_expired', handleRealtimePayload);
-
- sse.onerror = () => {
- if (sse) {
- try { sse.close(); } catch (e) { }
- sse = null;
- }
- setTimeout(connectSse, 3000);
- };
- } catch (e) {
- setTimeout(connectSse, 3000);
- }
- }
-
- // Continuous 2-second fallback polling: guarantees instant response when cashier confirms/declines or queues clear
- setInterval(() => {
- if (state && (state.status === 'SUCCESS' || state.status === 'FAILED' || state.status === 'EXPIRED' || state.status === 'BLOCKED' || state.isBanned)) {
- return;
- }
- loadState();
- }, 2000);
-
- // --- SUPPORT / HELP MODAL ---
- function openHelpModal() {
- document.getElementById('helpModal').hidden = false;
- const popoverMobile = document.getElementById('accountMenuPopover');
- if (popoverMobile) { popoverMobile.setAttribute('hidden', ''); popoverMobile.hidden = true; popoverMobile.style.display = 'none'; }
- const popoverPc = document.getElementById('accountMenuPopoverPc');
- if (popoverPc) { popoverPc.setAttribute('hidden', ''); popoverPc.hidden = true; popoverPc.style.display = 'none'; }
-
- const branding = state?.branding || {};
- renderSupportInfo({
- supportEmails: branding.supportEmails || (branding.supportEmail ? [branding.supportEmail] : []),
- supportMobiles: branding.supportMobiles || (branding.supportMobile ? [branding.supportMobile] : [])
- });
- }
+ <link rel="stylesheet" href="/css/checkout.css">
+</head>
- function renderSupportInfo(info) {
- const emailBox = document.getElementById('helpModalEmailsContainer');
- const phoneBox = document.getElementById('helpModalMobilesContainer');
- const caseBox = document.getElementById('helpModalCaseInfoText');
+<body>
- if (emailBox && info.supportEmails) {
- emailBox.innerHTML = `<strong>Email:</strong> ${info.supportEmails.join(', ')}`;
- }
- if (phoneBox && info.supportMobiles) {
- phoneBox.innerHTML = `<strong>Phone:</strong> ${info.supportMobiles.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'}`;
- }
- }
+ <!-- include:partials/splash.html -->
- function closeHelpModal() {
- document.getElementById('helpModal').hidden = true;
- }
+ <!-- YOUPI PG CHECKOUT CARD / DRAWER WRAPPER -->
+ <div class="ypg-wrapper">
- function copyCaseInfo() {
- const text = document.getElementById('helpModalCaseInfoText').textContent;
- navigator.clipboard.writeText(text).then(() => {
- document.getElementById('copyCaseText').textContent = 'Copied to Clipboard!';
- setTimeout(() => {
- document.getElementById('copyCaseText').textContent = 'Copy Payment Case Details';
- }, 2000);
- });
- }
+ <!-- include:partials/sidebar.html -->
- // WhatsApp OTP Input Keyboard Listeners
- const mobIn = document.getElementById('authMobileInput');
- if (mobIn) {
- mobIn.addEventListener('input', (e) => {
- const clean = e.target.value.replace(/\D/g, '').slice(0, 10);
- if (e.target.value !== clean) {
- e.target.value = clean;
- }
- currentAuthMobile = clean;
- });
- mobIn.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- handleAuthMobileSubmit();
- }
- });
- }
+ <!-- include:partials/header.html -->
- const nameIn = document.getElementById('authSignupName');
- const emailIn = document.getElementById('authSignupEmail');
- if (nameIn) {
- nameIn.addEventListener('input', (e) => {
- currentAuthName = e.target.value;
- });
- nameIn.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- emailIn?.focus();
- }
- });
- }
- if (emailIn) {
- emailIn.addEventListener('input', (e) => {
- currentAuthEmail = e.target.value;
- });
- emailIn.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- handleAuthSignupSubmit();
- }
- });
- }
+ <!-- 3. SCROLLABLE BODY -->
+ <div class="ypg-body">
+ <!-- include:partials/auth.html -->
+ <!-- include:partials/payment-methods.html -->
+ </div>
- const otpIn = document.getElementById('authOtpInput');
- if (otpIn) {
- otpIn.addEventListener('input', (e) => {
- const val = e.target.value.replace(/\D/g, '');
- e.target.value = val;
- if (val.length === 6) {
- handleAuthVerifyOtpSubmit();
- }
- });
- otpIn.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- handleAuthVerifyOtpSubmit();
- }
- });
- }
+ <!-- include:partials/footer.html -->
- // Boot checkout - restore preserved 1-week identity if available
- const bootPreserved = getPreservedIdentity();
- if (bootPreserved && bootPreserved.customer) {
- activeCustomer = bootPreserved.customer;
- activeToken = bootPreserved.token || localStorage.getItem('ypg_customer_token') || null;
- updateCustomerDisplay(activeCustomer);
- } else {
- activeCustomer = null;
- activeToken = null;
- }
+ <!-- include:partials/modals.html -->
- try {
- const initEl = document.getElementById('ypgInitialState');
- if (initEl && initEl.textContent && initEl.textContent.trim()) {
- const parsed = JSON.parse(initEl.textContent);
- if (parsed && (parsed.amount || parsed.branding || parsed.merchantName)) {
- renderState(parsed);
- }
- }
- } catch (e) { }
+ </div>
- loadState();
- connectSse();
+ <script id="ypgInitialState" type="application/json">{{INITIAL_STATE_JSON}}</script>
+ <script>
+ const PAYMENT_ID = "{{PAYMENT_ID}}";
+ const API_BASE = "{{API_BASE_URL}}";
</script>
+ <script src="/js/checkout.js"></script>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/apps/checkout-portal/src/views/partials/auth.html b/apps/checkout-portal/src/views/partials/auth.html
new file mode 100644
index 0000000..b16bbff
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/auth.html
@@ -0,0 +1,110 @@
+ <!-- PRE-GATEWAY CUSTOMER AUTHENTICATION VIEW (WHATSAPP BERRY PROTOCOL OTP FLOW) -->
+ <div id="preGatewayAuthView" hidden>
+ <h2 class="ypg-page-title" id="authViewMainTitle">Sign in to Pay</h2>
+ <div class="ypg-auth-box">
+ <div class="ypg-auth-sub-desc" id="authViewSubTitle">Enter your 10-digit WhatsApp mobile number to continue
+ </div>
+
+ <!-- Saved Account (1-Tap Selection) -->
+ <div class="ypg-saved-accs-wrapper" id="preAuthSavedAccountsContainer" hidden>
+ <div
+ style="font-size:11px; font-weight:800; color:var(--ypg-text-muted); text-transform:uppercase; margin-bottom:8px;">
+ Saved Account
+ </div>
+ <div id="savedAccountsList"></div>
+ </div>
+
+ <!-- STEP 1: ENTER MOBILE NUMBER -->
+ <div id="authStepMobile">
+ <div class="ypg-input-group">
+ <label class="ypg-input-label">WhatsApp Mobile Number</label>
+ <div class="ypg-phone-input-wrap">
+ <div class="ypg-phone-prefix">
+ <span>🇮🇳</span>
+ <span>+91</span>
+ </div>
+ <input type="tel" class="ypg-phone-control" id="authMobileInput" placeholder="10-digit mobile number"
+ maxlength="10" inputmode="numeric" />
+ </div>
+ </div>
+
+ <div
+ style="font-size:12px; color:var(--ypg-text-muted); margin-bottom:14px; display:flex; align-items:center; gap:6px;">
+ <span>💬</span>
+ <span>We'll verify your mobile via WhatsApp OTP</span>
+ </div>
+
+ <button type="button" class="ypg-btn-auth-action" id="btnAuthContinue" onclick="handleAuthMobileSubmit()">
+ <span>Continue</span> &rsaquo;
+ </button>
+ </div>
+
+ <!-- STEP 2: NEW CUSTOMER SIGN UP (Shown only if user does NOT exist) -->
+ <div id="authStepSignup" hidden>
+ <div class="ypg-auth-badge-banner">
+ <div>
+ <span>Mobile: </span>
+ <strong id="authSignupPhoneBadge">+91 </strong>
+ </div>
+ <button type="button" class="ypg-btn-link" onclick="goToAuthStep('mobile')">Change</button>
+ </div>
+
+ <div style="font-size:12.5px; color:var(--ypg-text-dark); font-weight:600; margin-bottom:12px;">
+ New to YOUPI PG? Please enter your name and email to proceed:
+ </div>
+
+ <div class="ypg-input-group">
+ <label class="ypg-input-label">Full Name</label>
+ <input type="text" class="ypg-input-control" id="authSignupName" placeholder="e.g. Alex Sharma" />
+ </div>
+
+ <div class="ypg-input-group">
+ <label class="ypg-input-label">Email Address</label>
+ <input type="email" class="ypg-input-control" id="authSignupEmail"
+ placeholder="e.g. [email protected]" />
+ </div>
+
+ <button type="button" class="ypg-btn-auth-action" id="btnAuthSignup" onclick="handleAuthSignupSubmit()">
+ <span>Sign Up &amp; Send WhatsApp OTP</span> &rsaquo;
+ </button>
+ </div>
+
+ <!-- STEP 3: OTP VERIFICATION (Shown for existing user login OR after signup) -->
+ <div id="authStepOtp" hidden>
+ <div class="ypg-auth-badge-banner" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
+ <div>
+ <span>Code sent to WhatsApp / SMS: </span>
+ <strong id="authOtpPhoneBadge">+91 </strong>
+ </div>
+ <button type="button" class="ypg-btn-link" onclick="goToAuthStep('mobile')">Edit</button>
+ </div>
+
+ <div id="authOtpGreeting"
+ style="font-size:12.5px; color:var(--ypg-text-dark); font-weight:600; margin-bottom:8px;">
+ Enter the 6-digit code sent to your phone:
+ </div>
+
+ <div class="ypg-input-group">
+ <input type="text" class="ypg-input-control ypg-otp-control" id="authOtpInput" placeholder="••••••"
+ maxlength="6" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code"
+ autocorrect="off" autocapitalize="off" spellcheck="false" />
+ </div>
+
+ <button type="button" class="ypg-btn-auth-action" id="btnAuthVerifyOtp"
+ onclick="handleAuthVerifyOtpSubmit()">
+ <span>Verify &amp; Continue to Pay</span> &rsaquo;
+ </button>
+
+ <div
+ style="display:flex; justify-content:space-between; align-items:center; margin-top:14px; font-size:12px; color:var(--ypg-text-muted);">
+ <div>
+ Didn't receive code?
+ <button type="button" class="ypg-btn-link" id="btnResendOtp" onclick="handleResendOtp()"
+ style="margin-left:4px;">Resend OTP</button>
+ </div>
+ <span id="otpCountdownTimer" style="font-weight:600; color:#64748b;"></span>
+ </div>
+ </div>
+
+ </div>
+ </div>
diff --git a/apps/checkout-portal/src/views/partials/footer.html b/apps/checkout-portal/src/views/partials/footer.html
new file mode 100644
index 0000000..e9d103d
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/footer.html
@@ -0,0 +1,54 @@
+ <!-- 4. AUTHENTIC STICKY BOTTOM FOOTER (SHOWN ONLY WHEN ACTIVE) -->
+ <footer class="ypg-sticky-footer" id="ypgStickyFooter">
+
+ <!-- Legal Disclaimer -->
+ <div class="ypg-legal-disclaimer" id="footerLegalDisclaimer">
+ Secured by YouPI PG & 256-Bit Bank Encryption &bull; <span style="text-decoration:underline; cursor:pointer;"
+ onclick="openHelpModal()">Privacy Notice</span>
+ </div>
+
+ <!-- Bottom Action Row: ₹5,500 View Details | Continue Button -->
+ <div class="ypg-action-bottom-bar">
+ <div class="ypg-amount-view-group">
+ <div class="ypg-bottom-price" id="bottomAmountDisplay">₹{{AMOUNT}}</div>
+ <button type="button" class="ypg-btn-view-details" onclick="toggleOrderDetails()">
+ <span>View Details</span>
+ <span id="chevronDetailsIcon">&#9652;</span>
+ </button>
+ </div>
+
+ <!-- Continue CTA Button (Triggers Verification - only appears after 2 minutes elapsed) -->
+ <button type="button" class="ypg-btn-continue" id="btnContinuePayment" onclick="submitPaymentDone()"
+ style="display:none;">
+ Payment Done — Check My Payment
+ </button>
+ </div>
+
+ <!-- ORDER BREAKDOWN POPUP DRAWER -->
+ <div class="ypg-details-drawer" id="orderDetailsDrawer">
+ <div class="ypg-details-header">
+ <span>Order Summary</span>
+ <button type="button" onclick="toggleOrderDetails()"
+ style="background:none; border:none; font-size:18px; cursor:pointer; color:#64748b;">✕</button>
+ </div>
+ <div class="ypg-details-row">
+ <span>Order Reference</span>
+ <strong id="drawerOrderId">{{ORDER_ID}}</strong>
+ </div>
+ <div class="ypg-details-row">
+ <span>Merchant</span>
+ <strong>{{MERCHANT_NAME}}</strong>
+ </div>
+
+ <div class="ypg-details-row">
+ <span>Platform & Processing Fee</span>
+ <span style="color:#10b981; font-weight:700;">₹0.00 (Zero Fee)</span>
+ </div>
+ <div class="ypg-details-row total">
+ <span>Total Amount</span>
+ <strong id="drawerTotalAmount">₹{{AMOUNT}}</strong>
+ </div>
+ </div>
+ </footer>
+
+ </div><!-- END ypg-pc-workspace -->
diff --git a/apps/checkout-portal/src/views/partials/header.html b/apps/checkout-portal/src/views/partials/header.html
new file mode 100644
index 0000000..e25a327
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/header.html
@@ -0,0 +1,101 @@
+ <!-- PC RIGHT WORKSPACE WRAPPER -->
+ <div class="ypg-pc-workspace">
+ <!-- PC TOPBAR -->
+ <div class="ypg-pc-topbar">
+ <div class="ypg-pc-topbar-title">Payment Options</div>
+ <div class="ypg-pc-topbar-actions" style="position: relative;">
+ <button type="button" class="ypg-pc-btn-more" id="btnPcMore" onclick="toggleAccountMenu(event)" title="Options">•••</button>
+ <button type="button" class="ypg-pc-btn-close" onclick="openCancelPaymentModal()"
+ title="Close Checkout">✕</button>
+
+ <!-- PC Account Popover Menu -->
+ <div class="ypg-account-popover" id="accountMenuPopoverPc" hidden style="position: absolute; top: 40px; right: 0; background: #ffffff; color: var(--ypg-text-dark); border-radius: 12px; box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18); border: 1px solid var(--ypg-border); padding: 8px; z-index: 1000; min-width: 220px;">
+ <div class="popoverCustomerName" id="popoverCustomerNamePc"
+ style="padding:6px 10px 8px 10px; font-weight:700; font-size:12px; border-bottom:1px solid #f1f5f9; color:#0f172a; word-break:break-word;">
+ Guest User</div>
+ <button type="button" class="ypg-popover-item" onclick="openHelpModal()">
+ <span>❓</span> Help & Support
+ </button>
+ <button type="button" class="ypg-popover-item" onclick="handleCustomerLogout()"
+ style="color:var(--ypg-danger);">
+ <span>🚪</span> Sign Out / Change Number
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- 2. AUTHENTIC YOUPI PG HEADER -->
+ <header class="ypg-header">
+ <!-- Mobile Top Drag Handle -->
+ <div class="ypg-drag-handle-bar"></div>
+
+ <!-- Main Header Row -->
+ <div class="ypg-header-main-row">
+ <div class="ypg-header-left-group">
+ <!-- Back Button -->
+ <button type="button" class="ypg-btn-back" id="btnHeaderBack" onclick="cancelPayment()" title="Back">
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4"
+ stroke-linecap="round" stroke-linejoin="round">
+ <path d="M19 12H5M12 19l-7-7 7-7" />
+ </svg>
+ </button>
+
+ <!-- Teal Merchant Avatar with White Initial -->
+ <div class="ypg-merchant-avatar" id="merchantAvatarBox">
+ <span id="merchantAvatarLetter">M</span>
+ <img id="merchantAvatarImg" alt="Logo" style="display:none;" />
+ </div>
+
+ <!-- Merchant Name & YouPI PG Verified Business Badge -->
+ <div class="ypg-merchant-text-group">
+ <div class="ypg-merchant-name" id="headerMerchantName">{{MERCHANT_NAME}}</div>
+ <div class="ypg-trusted-badge" id="headerTrustBadge">
+ <svg class="ypg-green-shield" viewBox="0 0 24 24" fill="none">
+ <path d="M12 2L3 6v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6l-9-4z" fill="#10b981" />
+ <path d="M8.5 12l2.5 2.5 5-5" stroke="#ffffff" stroke-width="2.2" stroke-linecap="round"
+ stroke-linejoin="round" />
+ </svg>
+ <span id="headerTrustBadgeText">YouPI PG Verified Business</span>
+ </div>
+ </div>
+ </div>
+
+ <!-- Right Profile Button (Toggles User Details Popover) -->
+ <button type="button" class="ypg-btn-profile" id="btnProfileMenu" onclick="toggleAccountMenu(event)"
+ title="User Profile">
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"
+ stroke-linecap="round" stroke-linejoin="round">
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
+ <circle cx="12" cy="7" r="4" />
+ </svg>
+ </button>
+ </div>
+
+ <!-- Header Sub-banner -->
+ <div class="ypg-header-subbanner" id="headerSubbanner">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
+ stroke-linejoin="round">
+ <circle cx="9" cy="21" r="1" />
+ <circle cx="20" cy="21" r="1" />
+ <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
+ </svg>
+ <span id="subbannerText">200+ orders verified this month by YouPI PG</span>
+ </div>
+
+ <!-- Account Popover Menu -->
+ <div class="ypg-account-popover" id="accountMenuPopover" hidden>
+ <div id="popoverCustomerName"
+ style="padding:4px 8px 8px 8px; font-weight:700; font-size:12px; border-bottom:1px solid #f1f5f9; color:#0f172a;">
+ Guest User</div>
+ <button type="button" class="ypg-popover-item" onclick="openHelpModal()">
+ <span>❓</span> Help & Support
+ </button>
+ <button type="button" class="ypg-popover-item" onclick="handleCustomerLogout()"
+ style="color:var(--ypg-danger);">
+ <span>🚪</span> Sign Out / Change Number
+ </button>
+ </div>
+ </header>
+
+ <!-- 3. SCROLLABLE BODY -->
+ <main class="ypg-body">
diff --git a/apps/checkout-portal/src/views/partials/modals.html b/apps/checkout-portal/src/views/partials/modals.html
new file mode 100644
index 0000000..14e0fcf
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/modals.html
@@ -0,0 +1,179 @@
+ <!-- HELP MODAL -->
+ <div class="ypg-dialog-overlay" id="helpModal" hidden>
+ <div class="ypg-dialog-card">
+ <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
+ <strong style="font-size:15px;" id="helpModalTitle">YouPI PG Help &amp; Support</strong>
+ <button type="button" onclick="closeHelpModal()"
+ style="background:none; border:none; font-size:18px; cursor:pointer; color:#64748b;">✕</button>
+ </div>
+ <div style="font-size:12px; color:#64748b; margin-bottom:12px;">For inquiries regarding your order or payment
+ status:</div>
+ <div id="helpModalEmailsContainer" style="margin-bottom:8px; font-size:12px;"></div>
+ <div id="helpModalMobilesContainer" style="margin-bottom:12px; font-size:12px;"></div>
+ <div id="helpModalLegalLinks"
+ style="display:none; gap:12px; font-size:11.5px; margin-bottom:12px; padding-bottom:8px; border-bottom:1px solid #e2e8f0;">
+ </div>
+ <div style="font-size:11px; font-weight:700; color:#64748b; text-transform:uppercase; margin-bottom:4px;">
+ Payment Case Info</div>
+ <pre id="helpModalCaseInfoText"
+ style="background:#f1f5f9; padding:8px; border-radius:6px; font-size:10px; color:#334155; white-space:pre-wrap; font-family:monospace; margin-bottom:12px;"></pre>
+ <button type="button" class="ypg-btn-auth-action" onclick="copyCaseInfo()">
+ <span id="copyCaseText">Copy Payment Case Details</span>
+ </button>
+ </div>
+ </div>
+
+ <!-- SINGLE ACTIVE SESSION CONFLICT MODAL -->
+ <div class="ypg-dialog-overlay" id="activeConflictModal" hidden>
+ <div class="ypg-dialog-card" style="max-width:380px; text-align:center;">
+ <div
+ style="width:48px; height:48px; border-radius:50%; background:#fef3c7; color:#d97706; display:flex; align-items:center; justify-content:center; font-size:24px; margin:0 auto 12px auto;">
+ ⚠️</div>
+ <strong style="font-size:16px; color:#0f172a; display:block; margin-bottom:6px;" id="conflictModalTitle">Active Session Detected</strong>
+ <p style="font-size:12.5px; color:#475569; line-height:1.5; margin-bottom:16px;" id="conflictModalDesc">
+ You already have an active payment session.
+ </p>
+ <div style="display:flex; flex-direction:column; gap:8px;">
+ <button type="button" class="ypg-btn-auth-action" id="btnContinueExistingActive"
+ onclick="continueExistingActivePayment()"
+ style="background:#2563eb; color:#ffffff; font-size:13px; font-weight:700; padding:11px;">
+ CONTINUE ACTIVE SESSION
+ </button>
+ <button type="button" class="ypg-btn-auth-action" id="btnEndSessionAndStartNew"
+ onclick="executeRetryNewPayment()"
+ style="background:#f1f5f9; color:#334155; border:1px solid #cbd5e1; font-size:12.5px; font-weight:600; padding:9px;">
+ END SESSION &amp; START NEW PAYMENT
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- RAZORPAY AUTHENTIC "PROCESSING YOUR PAYMENT" MODAL SHEET -->
+ <div class="rzp-sheet-backdrop" id="rzpProcessingModal" hidden>
+ <div class="rzp-sheet-dialog" style="position:relative;">
+ <button type="button" class="rzp-btn-sheet-close" onclick="closeProcessingModal()" title="Back to QR"
+ style="position:absolute; top:14px; right:14px; background:none; border:none; font-size:18px; cursor:pointer; color:#64748b; z-index:10; width:30px; height:30px; display:flex; align-items:center; justify-content:center; border-radius:50%; transition:background 0.15s;">✕</button>
+ <div class="rzp-sheet-content">
+ <div class="rzp-sheet-title" id="rzpProcessingTitle">Verifying Your Payment</div>
+ <div class="rzp-sheet-subtitle" id="rzpProcessingSubtitle">Bank verification in progress. Please do not close
+ or refresh this window.</div>
+ <div class="rzp-coin-stage">
+ <div class="rzp-halo-ring"></div>
+ <div class="rzp-3d-coin">
+ <div class="rzp-coin-face rzp-coin-front">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ <div class="rzp-coin-face rzp-coin-back">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ </div>
+ </div>
+ <div
+ style="font-size:12px; color:#10b981; font-weight:700; display:flex; align-items:center; justify-content:center; gap:6px; margin-top:10px;">
+ <span
+ style="display:inline-block; width:7px; height:7px; border-radius:50%; background:#10b981; box-shadow:0 0 6px #10b981; animation:rzpHaloPulse 1.2s infinite;"></span>
+ Checking UPI transaction in real-time...
+ </div>
+ <button type="button" class="rzp-sheet-cancel-btn" onclick="openCancelPaymentModal()"
+ style="margin-top:12px;">Cancel Payment</button>
+ <button type="button" onclick="closeProcessingModal()"
+ style="background:none; border:none; color:#64748b; font-size:12px; font-weight:600; cursor:pointer; margin-top:8px; text-decoration:underline;">
+ Return to QR Code
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- RAZORPAY AUTHENTIC "CANCEL PAYMENT" CONFIRMATION MODAL SHEET -->
+ <div class="rzp-sheet-backdrop" id="rzpCancelModal" hidden>
+ <div class="rzp-sheet-dialog">
+ <!-- State 1: Exit Door & Confirm Prompt -->
+ <div id="rzpCancelPromptView"
+ style="display:flex; flex-direction:column; align-items:center; text-align:center; padding-bottom:16px;">
+ <div class="rzp-cancel-header-arc">
+ <button type="button" class="rzp-btn-sheet-close" onclick="closeCancelPaymentModal()"
+ title="Back">✕</button>
+ <!-- Authentic Exit Door Illustration with EXIT sign & footprints -->
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120" width="88" height="62" fill="none">
+ <rect x="65" y="10" width="30" height="13" rx="2" fill="#dc2626" stroke="#b91c1c" stroke-width="0.8" />
+ <text x="80" y="19.5" font-family="-apple-system, BlinkMacSystemFont, Arial, sans-serif" font-size="7.5"
+ font-weight="900" fill="#ffffff" text-anchor="middle" letter-spacing="0.8">EXIT</text>
+ <path d="M50 23 H110 V90 H104 V27 H56 V90 H50 Z" fill="#94a3b8" />
+ <rect x="54" y="26" width="52" height="64" fill="#f8fafc" opacity="0.6" />
+ <path d="M55 27 L38 34 V97 L55 90 Z" fill="rgba(224, 242, 254, 0.75)" stroke="#64748b"
+ stroke-width="1.8" />
+ <path d="M53 30 L41 35 V93 L53 87 Z" fill="rgba(186, 230, 253, 0.45)" stroke="#94a3b8" stroke-width="1" />
+ <rect x="44" y="60" width="3" height="10" rx="1" fill="#334155" />
+ <path d="M105 27 L122 34 V97 L105 90 Z" fill="rgba(224, 242, 254, 0.75)" stroke="#64748b"
+ stroke-width="1.8" />
+ <path d="M107 30 L119 35 V93 L107 87 Z" fill="rgba(186, 230, 253, 0.45)" stroke="#94a3b8"
+ stroke-width="1" />
+ <rect x="113" y="60" width="3" height="10" rx="1" fill="#334155" />
+ <line x1="30" y1="94" x2="130" y2="94" stroke="#cbd5e1" stroke-width="1.5" stroke-dasharray="2 2" />
+ <g transform="translate(74, 80) rotate(-10) scale(0.65)" fill="#475569">
+ <ellipse cx="4" cy="3" rx="3.5" ry="4.5" />
+ <ellipse cx="4" cy="10" rx="2.5" ry="3" />
+ </g>
+ <g transform="translate(85, 88) rotate(12) scale(0.75)" fill="#334155">
+ <ellipse cx="4" cy="3" rx="3.5" ry="4.5" />
+ <ellipse cx="4" cy="10" rx="2.5" ry="3" />
+ </g>
+ <g transform="translate(71, 98) rotate(-8) scale(0.85)" fill="#1e293b">
+ <ellipse cx="4" cy="3" rx="3.8" ry="4.8" />
+ <ellipse cx="4" cy="11" rx="2.8" ry="3.2" />
+ </g>
+ <g transform="translate(87, 106) rotate(10) scale(0.95)" fill="#0f172a">
+ <ellipse cx="4" cy="3" rx="4" ry="5" />
+ <ellipse cx="4" cy="12" rx="3" ry="3.5" />
+ </g>
+ </svg>
+ </div>
+ <div
+ style="padding:12px 20px 0; width:100%; display:flex; flex-direction:column; align-items:center; box-sizing:border-box;">
+ <div class="rzp-sheet-title">
+ <span class="pc-only-title">Are you sure you want to exit?</span>
+ <span class="mob-only-title">Cancel Payment</span>
+ </div>
+ <div class="rzp-sheet-subtitle" style="margin-bottom:0; max-width:320px; line-height:1.45;">
+ <span class="pc-only-sub">You will be taken back to <span
+ class="cancelMerchantNameSpan">{{MERCHANT_NAME}}</span> website</span>
+ <span class="mob-only-sub">Your payment is ongoing. Are you sure you want to cancel the payment?</span>
+ </div>
+ <button type="button" class="rzp-btn-wait" onclick="closeCancelPaymentModal()">
+ <span class="pc-only-btn">Continue to payment</span>
+ <span class="mob-only-btn">No, wait</span>
+ </button>
+ <button type="button" class="rzp-btn-confirm-cancel" onclick="confirmCancelPayment()">
+ <span class="pc-only-btn">Yes, exit</span>
+ <span class="mob-only-btn">Yes, Cancel</span>
+ </button>
+ </div>
+ </div>
+
+ <!-- State 2: Cancelling Payment with Running Coin -->
+ <div id="rzpCancellingProgressView"
+ style="display:none; padding:28px 20px 24px; flex-direction:column; align-items:center; text-align:center;">
+ <div class="rzp-sheet-title">Cancelling Payment</div>
+ <div class="rzp-sheet-subtitle">This will only take a few seconds.</div>
+ <div class="rzp-coin-stage">
+ <div class="rzp-halo-ring"></div>
+ <div class="rzp-3d-coin">
+ <div class="rzp-coin-face rzp-coin-front">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ <div class="rzp-coin-face rzp-coin-back">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ </div>
+ </div>
+ <div class="rzp-secured-by">
+ <span>Secured by</span>
+ <strong style="color:#0f172a; font-weight:800;">{{APP_NAME}}</strong>
+ </div>
+ </div>
+ </div>
+ </div>
\ No newline at end of file
diff --git a/apps/checkout-portal/src/views/partials/payment-methods.html b/apps/checkout-portal/src/views/partials/payment-methods.html
new file mode 100644
index 0000000..7042778
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/payment-methods.html
@@ -0,0 +1,526 @@
+ <!-- MAIN PAYMENT GATEWAY INTERFACE -->
+ <div id="paymentGatewayInterface" hidden>
+
+ <!-- DYNAMIC PAYMENT METHOD SELECTOR BAR (ONLINE / OFFLINE MODALITY TABS) -->
+ <div id="paymentMethodSelectorBar" class="ypg-method-selector-bar" style="display:{{METHOD_SELECTOR_DISPLAY}};">
+ <button type="button" class="ypg-method-tab active" id="tabMethodUpi" onclick="selectPaymentMethod('UPI')">
+ <img src="/icons/upi.svg" alt="UPI" class="ypg-tab-icon" style="height:15px;" />
+ <span>UPI QR</span>
+ </button>
+ <button type="button" class="ypg-method-tab" id="tabMethodCod" onclick="selectPaymentMethod('COD')"
+ style="{{TAB_COD_STYLE}}">
+ <img src="/icons/cash.svg" alt="COD" class="ypg-tab-icon" style="height:14px; width:14px;" />
+ <span>Cash on Delivery</span>
+ </button>
+ <button type="button" class="ypg-method-tab" id="tabMethodCash"
+ onclick="selectPaymentMethod('CASH_COUNTER')" style="{{TAB_CASH_STYLE}}">
+ <img src="/icons/cash.svg" alt="Cash" class="ypg-tab-icon" style="height:14px; width:14px;" />
+ <span>Cash</span>
+ </button>
+ <button type="button" class="ypg-method-tab" id="tabMethodCard"
+ onclick="selectPaymentMethod('CARD_COUNTER')" style="{{TAB_CARD_STYLE}}">
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:4px; vertical-align:middle;"><rect x="2" y="5" width="20" height="14" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>
+ <span>Card</span>
+ </button>
+ </div>
+
+ <!-- PC 2-SUB-COLUMN CONTAINER (Exact Razorpay Frame 002 layout on Desktop) -->
+ <div class="ypg-pc-columns">
+ <!-- PC LEFT METHODS SUB-COLUMN -->
+ <div class="ypg-pc-methods-list" id="pcMethodsList">
+ <!-- UPI Card -->
+ <div class="ypg-pc-method-card is-active" id="pcMethodCardUpi" onclick="selectPaymentMethod('UPI')">
+ <div class="ypg-pc-method-header">
+ <img src="/icons/upi.svg" alt="UPI" style="height:15px; margin-right:6px; vertical-align:middle;" />
+ <div class="ypg-pc-method-title">UPI QR</div>
+ </div>
+ <div class="ypg-pc-method-sub">Scan &amp; Pay via UPI Apps</div>
+ <div class="ypg-pc-method-icons">
+ <img class="ypg-pc-mini-icon" src="/icons/gpay.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.gpay" alt="GPay" />
+ <img class="ypg-pc-mini-icon" src="/icons/phonepe.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.phonepe" alt="PhonePe" />
+ <img class="ypg-pc-mini-icon" src="/icons/paytm.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.paytm" alt="Paytm" />
+ <img class="ypg-pc-mini-icon" src="/icons/cred.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.cred" alt="CRED" />
+ </div>
+ </div>
+
+ <!-- Cash at Till Card (Offline Mode) -->
+ <div class="ypg-pc-method-card" id="pcMethodCardCash" onclick="selectPaymentMethod('CASH_COUNTER')" style="{{PC_CASH_STYLE}}">
+ <div class="ypg-pc-method-header">
+ <img src="/icons/cash.svg" alt="Cash" style="width:16px; height:16px; margin-right:6px; vertical-align:middle;" />
+ <div class="ypg-pc-method-title">Cash at Till</div>
+ <span class="ypg-pc-cash-pill">Counter</span>
+ </div>
+ <div class="ypg-pc-method-sub">Pay cash directly to cashier</div>
+ <div class="ypg-pc-method-icons" style="margin-top:6px;">
+ <span style="font-size:10.5px; font-weight:700; color:#15803d; background:#dcfce7; padding:2px 8px; border-radius:5px; display:inline-flex; align-items:center; gap:4px; border:1px solid #bbf7d0;">
+ <img src="/icons/cash.svg" alt="Cash" style="width:12px; height:12px;" />
+ Physical Cash
+ </span>
+ </div>
+ </div>
+
+ <!-- Card at Counter (Offline Mode) -->
+ <div class="ypg-pc-method-card" id="pcMethodCardCard" onclick="selectPaymentMethod('CARD_COUNTER')" style="{{PC_CARD_STYLE}}">
+ <div class="ypg-pc-method-header">
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:6px; vertical-align:middle; color:#475569;"><rect x="2" y="5" width="20" height="14" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>
+ <div class="ypg-pc-method-title">Card at Counter</div>
+ <span class="ypg-pc-cash-pill" style="background:#f1f5f9; color:#475569;">POS</span>
+ </div>
+ <div class="ypg-pc-method-sub">Swipe or tap card at POS desk</div>
+ <div class="ypg-pc-method-icons" style="gap:5px; margin-top:6px; display:flex; align-items:center;">
+ <img src="/icons/visa.svg" alt="Visa" style="height:15px; width:auto; object-fit:contain;" />
+ <img src="/icons/mastercard.svg" alt="Mastercard" style="height:15px; width:auto; object-fit:contain;" />
+ <img src="/icons/rupay.svg" alt="RuPay" style="height:15px; width:auto; object-fit:contain;" />
+ </div>
+ </div>
+
+ <!-- Cash on Delivery (COD) Card (Online Mode) -->
+ <div class="ypg-pc-method-card" id="pcMethodCardCod" onclick="selectPaymentMethod('COD')" style="{{PC_COD_STYLE}}">
+ <div class="ypg-pc-method-header">
+ <img src="/icons/cash.svg" alt="COD" style="width:16px; height:16px; margin-right:6px; vertical-align:middle;" />
+ <div class="ypg-pc-method-title">Cash on Delivery</div>
+ <span class="ypg-pc-cash-pill" style="background:#fef3c7; color:#92400e;">COD</span>
+ </div>
+ <div class="ypg-pc-method-sub">Pay physical cash at doorstep</div>
+ <div class="ypg-pc-method-icons" style="margin-top:6px;">
+ <span style="font-size:10.5px; font-weight:700; color:#b45309; background:#fef3c7; padding:2px 8px; border-radius:5px; display:inline-flex; align-items:center; gap:4px; border:1px solid #fde68a;">
+ <img src="/icons/cash.svg" alt="COD" style="width:12px; height:12px;" />
+ Doorstep Cash
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <!-- PC RIGHT ACTIVE PAYMENT WORKSPACE -->
+ <div class="ypg-pc-active-view">
+ <!-- VIEW A: PURE UPI QR INTERFACE -->
+ <div id="viewUpiContent">
+ <h2 class="ypg-page-title">UPI QR Payment</h2>
+
+ <!-- Section Label & Countdown Timer -->
+ <div class="ypg-section-label-row">
+ <span class="ypg-section-heading">Scan &amp; Pay via UPI</span>
+ <div class="ypg-countdown-pill" id="activeTimerBadge">
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2.2">
+ <circle cx="12" cy="12" r="10" />
+ <polyline points="12 6 12 12 16 14" />
+ </svg>
+ <span id="activeTimerText">05:00</span>
+ </div>
+ </div>
+
+ <!-- UPI Server Health Indicator & Downtime Warning -->
+ <div class="ypg-server-health-indicator {{SERVER_HEALTH_CLASS}}" id="upiServerHealthIndicator">
+ <span class="ypg-pulse-dot" id="serverPulseDot"></span>
+ <span id="serverStatusLabel">{{SERVER_HEALTH_LABEL}}</span>
+ </div>
+
+ <div class="{{DOWNTIME_ALERT_CLASS}}" id="serverDowntimeAlert" style="display:{{DOWNTIME_ALERT_STYLE}};">
+ <div class="ypg-downtime-icon">
+ <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
+ </div>
+ <div class="ypg-downtime-info">
+ <div class="ypg-downtime-heading">{{DOWNTIME_HEADING}}</div>
+ <div class="ypg-downtime-msg" id="serverDowntimeMsg">
+ {{DOWNTIME_MSG}}
+ </div>
+ <button type="button" class="ypg-btn-downtime-alt" id="btnDowntimeCashAlt"
+ onclick="switchMethodFromDowntime()" style="display:{{DOWNTIME_ALT_BTN_DISPLAY}};">
+ {{DOWNTIME_ALT_BTN_LABEL}}
+ </button>
+ </div>
+ </div>
+
+ <!-- Core UPI QR Card -->
+ <div class="ypg-qr-card-container">
+ <!-- Left: QR Box -->
+ <div class="ypg-qr-image-box" id="qrImageContainer">
+ <div style="font-size:11px; color:#94a3b8; text-align:center;">Loading QR...</div>
+ </div>
+
+ <!-- Right: Prompt, UPI App Logos -->
+ <div class="ypg-qr-details-col">
+ <div class="ypg-qr-prompt-title">Scan the QR using any UPI App</div>
+
+ <!-- Brand Logos Row (Zero Fake Offers) -->
+ <div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:3px 0 6px 0;">
+ <div class="ypg-upi-logos-row">
+ <div class="ypg-app-icon" title="Google Pay"><img src="/icons/gpay.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.gpay" alt="GPay" /></div>
+ <div class="ypg-app-icon" title="PhonePe"><img src="/icons/phonepe.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.phonepe" alt="PhonePe" />
+ </div>
+ <div class="ypg-app-icon" title="Paytm"><img src="/icons/paytm.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.paytm" alt="Paytm" /></div>
+ <div class="ypg-app-icon" title="CRED"><img src="/icons/cred.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.cred" alt="CRED" /></div>
+ <div class="ypg-app-icon" title="BHIM UPI"><img src="/icons/bhim.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.bhim" alt="BHIM" /></div>
+ <div class="ypg-app-icon" title="Amazon Pay"><img src="/icons/amazonpay.png"
+ onerror="if(window.FALLBACK_ICONS)this.src=window.FALLBACK_ICONS.amazonpay"
+ alt="Amazon Pay" /></div>
+ </div>
+ </div>
+
+ <div style="font-size:12px; color:#64748b; line-height:1.4;">
+ Open any UPI app on your phone to scan and pay directly.
+ </div>
+ </div>
+ </div>
+ <!-- UPI Payment Instructions Guide -->
+ <div class="ypg-instructions-card">
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">1</div>
+ <div>Open any UPI App on your phone (Google Pay, PhonePe, Paytm, CRED).</div>
+ </div>
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">2</div>
+ <div>Scan the QR code above and complete the payment of <strong>₹{{AMOUNT}}</strong>.</div>
+ </div>
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">3</div>
+ <div>Payment is detected automatically, or tap <strong>Continue</strong> below after paying.</div>
+ </div>
+ </div>
+ </div>
+
+ <!-- VIEW COD: CASH ON DELIVERY (ONLINE SELLING MODE) -->
+ <div id="viewCodContent" hidden>
+ <div class="ypg-section-label-row" style="margin-top:0; margin-bottom:12px;">
+ <h2 class="ypg-page-title" style="margin-bottom:0;">Cash on Delivery (COD)</h2>
+ <div class="ypg-countdown-pill" id="codTimerBadge">
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
+ stroke-width="2.2">
+ <circle cx="12" cy="12" r="10" />
+ <polyline points="12 6 12 12 16 14" />
+ </svg>
+ <span id="codTimerText">05:00</span>
+ </div>
+ </div>
+
+ <!-- COD Notice Pill -->
+ <div class="ypg-offers-pill" style="background:#fef3c7; border-color:#fde68a;">
+ <div class="ypg-offers-left">
+ <div class="ypg-offer-icon-badge" style="background:#d97706; color:#fff; display:flex; align-items:center; justify-content:center;">
+ <img src="/icons/cash.svg" alt="Cash" style="width:14px; height:14px;" />
+ </div>
+ <span style="color:#92400e; font-weight:700;">Pay Cash at Doorstep</span>
+ </div>
+ <div class="ypg-offers-right">
+ <span style="color:#b45309;">Verified Purchase</span>
+ </div>
+ </div>
+
+ <!-- Order Summary Card -->
+ <div
+ style="background:#ffffff; border:1px solid var(--ypg-border); border-radius:12px; padding:16px; margin:14px 0;">
+ <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
+ <span style="font-size:12px; color:#64748b; font-weight:600;">Payable on Delivery</span>
+ <strong style="font-size:20px; font-weight:800; color:#0f172a;">₹{{AMOUNT}}</strong>
+ </div>
+ <div
+ style="font-size:12px; color:#334155; line-height:1.5; border-top:1px dashed var(--ypg-border); padding-top:10px;">
+ <div>Recipient: <strong id="codCustomerName">Customer</strong></div>
+ <div>Contact: <span id="codCustomerPhone" style="font-family:monospace;">-</span></div>
+ </div>
+ </div>
+
+ <!-- Doorstep Delivery Guide -->
+ <div class="ypg-instructions-card">
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">1</div>
+ <div>Review and confirm your Cash on Delivery order below.</div>
+ </div>
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">2</div>
+ <div>Merchant processes and ships your package directly to your destination.</div>
+ </div>
+ <div class="ypg-instruction-step">
+ <div class="ypg-step-num">3</div>
+ <div>Hand over <strong>₹{{AMOUNT}}</strong> in physical cash to the courier agent upon arrival.
+ </div>
+ </div>
+ </div>
+
+ <!-- Action Button with Pre-Purchase Confirmation -->
+ <button type="button" class="ypg-btn-auth-action" id="btnConfirmCod" onclick="promptConfirmCodOrder()"
+ style="background:#0d9f67; font-size:14px; padding:12px;">
+ <span>Confirm &amp; Place COD Order (₹{{AMOUNT}})</span> &rsaquo;
+ </button>
+ </div>
+
+ <!-- VIEW CASH: CASH AT BILLING TILL (OFFLINE SELLING MODE) -->
+ <div id="viewCashContent" hidden>
+ <h2 class="ypg-page-title">Pay with Cash at Till</h2>
+
+ <div
+ style="background:#f0fdf4; border:1px solid #bbf7d0; border-radius:12px; padding:16px; margin:14px 0; text-align:center;">
+ <div
+ style="font-size:12px; font-weight:700; color:#166534; text-transform:uppercase; letter-spacing:0.5px; margin-bottom:4px;">
+ Amount Payable to Cashier</div>
+ <div style="font-size:28px; font-weight:800; color:#15803d;">₹{{AMOUNT}}</div>
+
+ <!-- Prominent Cashier Order ID Display -->
+ <div
+ style="margin-top:12px; padding-top:10px; border-top:1px dashed #86efac; display:flex; align-items:center; justify-content:center; gap:8px;">
+ <span style="font-size:12px; font-weight:700; color:#166534;">Store Order ID:</span>
+ <span class="cashierOrderIdDisplay"
+ style="font-family:monospace; font-size:14.5px; font-weight:900; color:#0f172a; background:#ffffff; padding:3px 10px; border-radius:6px; border:1.5px solid #86efac; letter-spacing:0.5px;">#{{ORDER_ID}}</span>
+ </div>
+ </div>
+
+ <!-- Counter Desk Instructions -->
+ <div class="ypg-instructions-card">
+ <div style="font-size:12.5px; font-weight:700; color:#0f172a; margin-bottom:8px;">Counter Desk
+ Instructions</div>
+ <p style="font-size:12px; color:#475569; line-height:1.5; margin:0;" id="cashCounterDeskNotice">
+ {{COUNTER_INSTRUCTIONS}}
+ </p>
+ </div>
+
+ <div class="ypg-live-observer-strip" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
+ <div class="ypg-radar-dot" style="background:#2563eb; box-shadow:0 0 0 0 rgba(37,99,235,0.7);"></div>
+ <span>Awaiting Cashier Confirmation at Billing Desk...</span>
+ </div>
+
+ <div style="font-size:12px; color:#64748b; text-align:center; padding:8px;">
+ Present this screen and Order ID to the cashier. Your payment will automatically update once confirmed
+ by staff.
+ </div>
+ </div>
+
+ <!-- VIEW CARD: CARD AT POS MACHINE (OFFLINE SELLING MODE) -->
+ <div id="viewCardContent" hidden>
+ <h2 class="ypg-page-title">Pay with Card at Counter</h2>
+ <div style="display:flex; align-items:center; justify-content:center; gap:8px; margin:6px 0 12px 0;">
+ <img src="/icons/visa.svg" alt="Visa" style="height:16px; width:auto; object-fit:contain;" />
+ <img src="/icons/mastercard.svg" alt="Mastercard" style="height:16px; width:auto; object-fit:contain;" />
+ <img src="/icons/rupay.svg" alt="RuPay" style="height:16px; width:auto; object-fit:contain;" />
+ </div>
+
+ <div
+ style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:12px; padding:16px; margin:14px 0; text-align:center;">
+ <div
+ style="font-size:12px; font-weight:700; color:#475569; text-transform:uppercase; letter-spacing:0.5px; margin-bottom:4px;">
+ POS Terminal Charge</div>
+ <div style="font-size:28px; font-weight:800; color:#0f172a;">₹{{AMOUNT}}</div>
+
+ <!-- Prominent Cashier Order ID Display -->
+ <div
+ style="margin-top:12px; padding-top:10px; border-top:1px dashed #cbd5e1; display:flex; align-items:center; justify-content:center; gap:8px;">
+ <span style="font-size:12px; font-weight:700; color:#475569;">Store Order ID:</span>
+ <span class="cashierOrderIdDisplay"
+ style="font-family:monospace; font-size:14.5px; font-weight:900; color:#0f172a; background:#ffffff; padding:3px 10px; border-radius:6px; border:1.5px solid #cbd5e1; letter-spacing:0.5px;">#{{ORDER_ID}}</span>
+ </div>
+ </div>
+
+ <!-- Counter Desk Instructions -->
+ <div class="ypg-instructions-card">
+ <div style="font-size:12.5px; font-weight:700; color:#0f172a; margin-bottom:8px;">POS Terminal
+ Instructions</div>
+ <p style="font-size:12px; color:#475569; line-height:1.5; margin:0;" id="cardCounterDeskNotice">
+ Please swipe, insert, or tap your credit or debit card on the store POS terminal at the billing
+ desk.
+ </p>
+ </div>
+
+ <div class="ypg-live-observer-strip" style="background:#eff6ff; border-color:#bfdbfe; color:#1e40af;">
+ <div class="ypg-radar-dot" style="background:#2563eb; box-shadow:0 0 0 0 rgba(37,99,235,0.7);"></div>
+ <span>Awaiting Cashier Slip Verification...</span>
+ </div>
+
+ <div style="font-size:12px; color:#64748b; text-align:center; padding:8px;">
+ Present this screen and Order ID to the cashier. Cashier will verify transaction and approve this
+ checkout session.
+ </div>
+ </div>
+
+ <!-- VIEW B: QUEUE VIEW (WHEN CHANNELS ARE OCCUPIED) -->
+ <div id="viewQueuedContent" hidden>
+ <!-- Psychological Time-Saving Conversion Hook in Queue -->
+ <div id="queueTimeSavingBanner" class="ypg-time-saving-banner" style="display:none;"></div>
+
+ <div class="ypg-queue-container">
+ <div style="font-size:16px; font-weight:800; color:#1e3a8a;">You Are In Line for Payment</div>
+ <div class="ypg-queue-number" id="queueNumberDisplay">#1</div>
+ <div style="font-size:13px; font-weight:700; color:#2563eb;">
+ Estimated Wait: <span id="queueTimerText">00:30</span>
+ </div>
+ <div style="font-size:12px; color:#475569; margin-top:8px; line-height:1.4;">
+ Your payment slot is reserved. You will be activated automatically the moment the current
+ transaction finishes.
+ </div>
+ </div>
+ </div>
+
+ <!-- VIEW C: RAZORPAY AUTHENTIC PROCESSING / VERIFYING VIEW -->
+ <div id="viewProcessingContent" hidden>
+ <div
+ style="padding:28px 16px 20px; display:flex; flex-direction:column; align-items:center; text-align:center;">
+ <div class="rzp-sheet-title">Processing your payment</div>
+ <div class="rzp-sheet-subtitle">This will only take a few seconds.</div>
+ <div class="rzp-coin-stage">
+ <div class="rzp-halo-ring"></div>
+ <div class="rzp-3d-coin">
+ <div class="rzp-coin-face rzp-coin-front">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ <div class="rzp-coin-face rzp-coin-back">
+ <div class="rzp-coin-inner-rim"></div>
+ <div class="rzp-coin-sheen"></div>
+ </div>
+ </div>
+ </div>
+ <div style="font-size:12px; color:#64748b; margin-top:8px;">
+ Bank verification in progress (<span id="procTimerText">30s</span>)
+ </div>
+ <button type="button" class="rzp-sheet-cancel-btn" onclick="openCancelPaymentModal()"
+ style="max-width:320px;">Cancel</button>
+ </div>
+ </div>
+
+ <!-- VIEW D: SUCCESS CELEBRATION VIEW -->
+ <div id="viewSuccessContent" hidden>
+ <div class="ypg-success-box">
+ <div class="ypg-success-circle" id="successIconCircle">
+ <svg class="ypg-check-svg" viewBox="0 0 24 24">
+ <polyline class="ypg-check-path" points="20 6 9 17 4 12"></polyline>
+ </svg>
+ </div>
+ <div class="ypg-success-title" id="successTitleText">Payment Successful!</div>
+ <div class="ypg-success-amount" id="successAmountVal">₹{{AMOUNT}}</div>
+ <div style="font-size:12px; color:var(--ypg-text-muted); margin-bottom:14px;" id="successDescText">
+ Your payment was automatically verified by YouPI PG banking observers.
+ </div>
+ <div id="successCodDevApiBox"
+ style="display:none; font-size:11.5px; background:#f1f5f9; padding:10px 14px; border-radius:8px; margin-bottom:14px; text-align:left; border:1px solid #e2e8f0;">
+ <span style="font-weight:700; color:#334155;">Developer Order API:</span>
+ <div
+ style="word-break:break-all; font-family:monospace; color:#2563eb; margin-top:3px; font-size:11px;"
+ id="successCodDevApiUrl"></div>
+ </div>
+ <a href="javascript:void(0)" class="btn-return-merchant" id="btnReturnStore">Return to Merchant</a>
+ </div>
+ </div>
+
+ <!-- VIEW E: DEDICATED PAYMENT EXPIRED / FAILED VIEW (CLEAN & CENTERED) -->
+ <div id="viewFailedContent" hidden>
+ <div class="ypg-expired-box">
+ <div class="ypg-expired-icon-wrap">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"
+ stroke-linejoin="round">
+ <circle cx="12" cy="12" r="10" />
+ <polyline points="12 6 12 12 16 14" />
+ </svg>
+ </div>
+ <div class="ypg-expired-title" id="failedTitleText">Payment Session Expired</div>
+ <div class="ypg-expired-desc" id="failedDescriptionText">
+ The 5-minute active payment window elapsed before verification was completed. For security, please
+ return to the store and initiate a new order.
+ </div>
+ <div class="ypg-expired-actions">
+ <button type="button" class="ypg-btn-expired-primary" id="btnFailedAction"
+ onclick="handleRetryNewPayment()">
+ Try Again
+ </button>
+ <button type="button" class="ypg-btn-expired-secondary" onclick="openHelpModal()">
+ Help & Support
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- VIEW F: DEDICATED FRAUD / SECURITY ALERT & ACCESS BLOCKED VIEW -->
+ <div id="viewBlockedContent" hidden>
+ <div class="ypg-blocked-box">
+ <div class="ypg-blocked-badge">
+ <span class="ypg-blocked-badge-dot"></span>
+ <span>Security Alert &bull; Under Investigation</span>
+ </div>
+ <div class="ypg-blocked-icon-wrap">
+ <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
+ <line x1="12" y1="8" x2="12" y2="12"/>
+ <line x1="12" y1="16" x2="12.01" y2="16"/>
+ </svg>
+ </div>
+ <div class="ypg-blocked-title" id="blockedTitleText">Fraudulent Activity Detected</div>
+ <div class="ypg-blocked-subtitle" id="blockedSubtitleText">Payment Session Terminated &amp; Account Suspended</div>
+
+ <div class="ypg-blocked-card">
+ <p class="ypg-blocked-desc" id="blockedNoticeText">
+ Our automated verification engine detected fraudulent payment activity associated with this transaction. Access has been immediately suspended to protect network integrity.
+ </p>
+ <div class="ypg-blocked-investigation">
+ <span style="font-size:15px; line-height:1;">🔍</span>
+ <span><strong>Investigation In Progress:</strong> Our fraud risk &amp; security operations team is reviewing the activity. Store administrator review is required before access can be restored.</span>
+ </div>
+ </div>
+
+ <div class="ypg-blocked-details">
+ <span class="ypg-blocked-details-label">Order Ref:</span>
+ <span class="ypg-blocked-details-val" id="blockedOrderRefVal">-</span>
+ <span class="ypg-blocked-details-label">Session ID:</span>
+ <span class="ypg-blocked-details-val" id="blockedSessionIdVal">-</span>
+ <span class="ypg-blocked-details-label">Status:</span>
+ <span class="ypg-blocked-details-val" style="color:#ef4444; font-weight:800;">ACCOUNT BLOCKED</span>
+ <span class="ypg-blocked-details-label">Timestamp:</span>
+ <span class="ypg-blocked-details-val" id="blockedTimestampVal">-</span>
+ </div>
+
+ <div style="display:flex; flex-direction:column; gap:8px; width:100%; max-width:340px;">
+ <button type="button" class="ypg-btn-blocked-exit" onclick="handleBlockedExit()">
+ <span>Return to Merchant Store</span>
+ </button>
+ <button type="button" onclick="openHelpModal()" style="background:none; border:none; color:#64748b; font-size:12px; font-weight:600; cursor:pointer; text-decoration:underline; padding:6px;">
+ Need help? View Security Case Reference
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- VIEW G: DEDICATED DUPLICATE SESSION DETECTED VIEW (DEVICE BINDING SECURITY) -->
+ <div id="viewDuplicateSessionContent" hidden>
+ <div class="ypg-duplicate-box">
+ <div class="ypg-duplicate-badge">
+ <span class="ypg-duplicate-badge-dot"></span>
+ <span>Device Security Check</span>
+ </div>
+ <div class="ypg-duplicate-icon-wrap">
+ <svg viewBox="0 0 24 24" width="34" height="34" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
+ <line x1="8" y1="21" x2="16" y2="21"/>
+ <line x1="12" y1="17" x2="12" y2="21"/>
+ <line x1="12" y1="7" x2="12" y2="10"/>
+ <line x1="12" y1="13" x2="12.01" y2="13"/>
+ </svg>
+ </div>
+ <div class="ypg-duplicate-title" id="dupSessionTitleText">Duplicate Session Detected</div>
+ <div class="ypg-duplicate-subtitle" id="dupSessionSubtitleText">Payment Session Active on Another Device</div>
+
+ <div class="ypg-duplicate-card">
+ <p class="ypg-duplicate-desc" style="font-weight:700; color:#0f172a; margin-bottom:6px;">
+ This payment session was created on another device.
+ </p>
+ <p class="ypg-duplicate-desc" style="color:#64748b; font-size:12.5px;">
+ For security reasons, this session cannot be continued from this device.
+ </p>
+ </div>
+
+ <div style="display:flex; flex-direction:column; gap:8px; width:100%; max-width:360px;">
+ <button type="button" class="ypg-btn-duplicate-action" id="btnEndAndRestartPayment" onclick="handleEndAndStartNewPayment()">
+ <span>END SESSION &amp; START NEW PAYMENT</span>
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </main>
diff --git a/apps/checkout-portal/src/views/partials/sidebar.html b/apps/checkout-portal/src/views/partials/sidebar.html
new file mode 100644
index 0000000..be21df9
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/sidebar.html
@@ -0,0 +1,75 @@
+ <!-- PC LEFT SIDEBAR (Razorpay 2-Column Exact Layout for Desktop) -->
+ <aside class="ypg-pc-sidebar">
+ <div>
+ <!-- Merchant Brand Header -->
+ <div class="ypg-pc-brand-header">
+ <div class="ypg-pc-avatar" id="pcMerchantAvatarBox">
+ <span id="pcMerchantAvatarLetter">M</span>
+ <img id="pcMerchantAvatarImg" alt="Logo" style="display:none;" />
+ </div>
+ <div class="ypg-pc-brand-info">
+ <div class="ypg-pc-merchant-name" id="pcMerchantName">{{MERCHANT_NAME}}</div>
+ <div class="ypg-pc-trust-badge" id="pcTrustBadge">
+ <svg class="ypg-pc-green-shield" viewBox="0 0 24 24" fill="none">
+ <path d="M12 2L3 6v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6l-9-4z" fill="#10b981" />
+ <path d="M8.5 12l2.5 2.5 5-5" stroke="#ffffff" stroke-width="2.2" stroke-linecap="round"
+ stroke-linejoin="round" />
+ </svg>
+ <span id="pcTrustBadgeText">YouPI PG Trusted Business</span>
+ </div>
+ </div>
+ </div>
+
+ <!-- Social Proof Banner -->
+ <div class="ypg-pc-social-proof" id="pcSocialProofWrap">
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <circle cx="9" cy="21" r="1" />
+ <circle cx="20" cy="21" r="1" />
+ <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
+ </svg>
+ <span id="pcSocialProofText">500+ orders last month from {{MERCHANT_NAME}}</span>
+ </div>
+
+ <!-- Price Summary Card (STRICTLY NO UPI ID VISIBLE) -->
+ <div class="ypg-pc-price-card">
+ <div class="ypg-pc-price-label">Price Summary</div>
+ <div class="ypg-pc-price-val" id="pcPriceSummaryAmount">₹{{AMOUNT}}</div>
+ </div>
+
+ <!-- User Identity Row -->
+ <div class="ypg-pc-row-btn" id="pcCustomerProfileRow" onclick="toggleAccountMenu(event)">
+ <div class="ypg-pc-row-left">
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
+ <circle cx="12" cy="7" r="4" />
+ </svg>
+ <span id="pcCustomerProfileText">Using as Guest User</span>
+ </div>
+ <span class="ypg-pc-chevron">&rsaquo;</span>
+ </div>
+ </div>
+
+ <!-- Bottom Isometric Shopping Bags Graphic -->
+ <div style="margin-top:auto;">
+ <div class="ypg-pc-bags-wrap">
+ <svg viewBox="0 0 260 160" width="220" height="135" fill="none">
+ <ellipse cx="130" cy="145" rx="100" ry="12" fill="rgba(0,0,0,0.18)" />
+ <!-- White / Cyan shopping bag with blue handles -->
+ <path d="M100 65 L135 60 L145 135 L90 140 Z" fill="#ffffff" stroke="#cbd5e1" stroke-width="1.5" />
+ <path d="M100 65 L135 60 L140 85 L95 90 Z" fill="#f1f5f9" />
+ <path d="M110 63 C110 48, 125 48, 125 61" stroke="#0284c7" stroke-width="3" fill="none"
+ stroke-linecap="round" />
+ <!-- Green shopping bag with % badge -->
+ <path d="M140 75 L180 70 L195 135 L135 140 Z" fill="#10b981" stroke="#059669" stroke-width="1.5" />
+ <path d="M150 73 C150 58, 168 58, 168 71" stroke="#047857" stroke-width="3" fill="none"
+ stroke-linecap="round" />
+ <circle cx="160" cy="98" r="14" fill="#34d399" />
+ <text x="160" y="103" font-size="12" font-weight="900" fill="#064e3b" text-anchor="middle">%</text>
+ <!-- Blue gift box with white ribbon -->
+ <path d="M55 100 L95 95 L105 140 L50 142 Z" fill="#0284c7" />
+ <path d="M50 100 L95 95 L95 105 L48 108 Z" fill="#38bdf8" />
+ <rect x="71" y="96" width="7" height="45" fill="#ffffff" />
+ </svg>
+ </div>
+ </div>
+ </aside>
diff --git a/apps/checkout-portal/src/views/partials/splash.html b/apps/checkout-portal/src/views/partials/splash.html
new file mode 100644
index 0000000..c61a8b6
--- /dev/null
+++ b/apps/checkout-portal/src/views/partials/splash.html
@@ -0,0 +1,35 @@
+ <!-- TOAST NOTIFICATION -->
+ <div id="ypgToast" class="ypg-toast"><img src="/icons/upi.svg" alt="UPI" style="height:12px; vertical-align:middle; filter:brightness(0) invert(1); margin-right:4px;" /> Direct UPI QR is active for instant banking verification</div>
+
+ <!-- YOUPI PG CHECKOUT CARD / DRAWER WRAPPER -->
+ <div class="ypg-wrapper">
+
+ <!-- 1. INITIAL YOUPI PG LOADING SPLASH -->
+ <div id="ypgSplashScreen" class="ypg-splash-screen">
+ <div class="ypg-splash-center">
+ <div class="ypg-shield-orbit-box">
+ <img id="splashBrandLogo" alt="Logo"
+ style="display:none; max-width:82px; max-height:82px; border-radius:16px; object-fit:contain; box-shadow:0 8px 24px rgba(0,0,0,0.12);" />
+ <!-- Authentic YouPI PG Shield with 'Y' Monogram -->
+ <svg class="ypg-shield-icon-svg" id="splashDefaultShield" viewBox="0 0 100 120" fill="none">
+ <defs>
+ <linearGradient id="ypgShieldGrad" x1="0" y1="0" x2="1" y2="1">
+ <stop offset="0%" stop-color="#0b63e5" />
+ <stop offset="100%" stop-color="#0747a6" />
+ </linearGradient>
+ </defs>
+ <path d="M50 4 L92 22 C92 72, 50 116, 50 116 C50 116, 8 72, 8 22 Z" fill="url(#ypgShieldGrad)" />
+ <!-- Sharp white & cyan 'Y' monogram -->
+ <path d="M33 32 L46 54 L46 84 L54 84 L54 54 L67 32 L56 32 L50 44 L44 32 Z" fill="#ffffff" />
+ <polygon points="50,44 56,32 61,32 54,49" fill="#38bdf8" />
+ </svg>
+ <div class="ypg-orbit-dot"></div>
+ </div>
+ </div>
+ <div class="ypg-splash-footer" id="splashFooterWrap">
+ <span>Secured By</span>
+ <strong id="splashSecuredByText" style="color:var(--ypg-blue); font-size:15px; letter-spacing:-0.2px;">YouPI
+ PG</strong>
+ </div>
+ </div>
+