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.
The project's README from github.com/gxurav1710/YouPI-PG. As one markdown file: README.md.
██╗ ██╗ ██████╗ ██╗ ██╗██████╗ ██╗ ██████╗ ██████╗
╚██╗ ██╔╝██╔═══██╗██║ ██║██╔══██╗██║ ██╔══██╗██╔════╝
╚████╔╝ ██║ ██║██║ ██║██████╔╝██║ ██████╔╝██║ ███╗
╚██╔╝ ██║ ██║██║ ██║██╔═══╝ ██║ ██╔═══╝ ██║ ██║
██║ ╚██████╔╝╚██████╔╝██║ ██║ ██║ ╚██████╔╝
╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝
0% Gateway Fees • Direct-to-Bank Settlement • WhatsApp Pre-Checkout OTP • Bank SMS & Gmail Observers
Live Demos • Why YOUPI? • Architecture • Superpowers • Quickstart • Merchant Integration • Banking Observers • Port Topology • Docs
See YOUPI PG V2 live in action across Desktop and Mobile checkout flows:
| 🖥️ Desktop Modal Flow | 📱 Mobile Drawer & App Switcher |
|---|---|
![]() Full end-to-end checkout: One-script modal, WhatsApp OTP, dynamic vector QR & bank observation. |
![]() Ultra-responsive bottom drawer with 1-tap deep-link intent for GPay, PhonePe, Paytm & CRED. |
• Zero-JS One-Script Trigger: Auto-binds to [data-youpi-pay]• WhatsApp Pre-Checkout OTP: Real-time 6-digit phone verification • Dynamic Vector SVG QR: Pure vector QR code with dual timers • Automated Observer Credit: Instant credit via bank SMS/Gmail |
• Responsive Bottom Drawer: Native app-feel mobile UI • Direct UPI App Deep-Linking: GPay, PhonePe, Paytm, CRED • Real-Time Payment Polling: Instant status reflection • Counter Desk Modalities: Configurable Cash & Card fallback |
High-Definition 120FPS Raw Recordings: assets/Desktop.mp4 • assets/Mobile.mp4
Traditional payment gateways (Razorpay, Cashfree, PayU, Stripe) lock your revenue into high fees, multi-day settlement delays, and sudden compliance freezes:
| Comparison Metric | Traditional Aggregators (Razorpay / Cashfree) | ⚡ YOUPI PG (Self-Hosted Sovereign) |
|---|---|---|
| Transaction Fee | 2.0% – 3.0% + 18% GST per transaction | 0.0% (Zero Fees Forever) |
| Settlement Speed | T+2 to T+3 Business Days (Holdbacks) | Instant (Direct into your Bank Account) |
| Account Freeze Risk | High (Unilateral freezes at aggregator discretion) | ZERO (You control your own VPA & infrastructure) |
| Customer Authentication | SMS OTP (Costly SMS gateway bills, phone spoofing) | WhatsApp OTP (Zero spoofing, verified mobile) |
| Payment Verification | Aggregator proprietary webhooks | Bank SMS & Gmail Alerts parsed in real time |
| Queue & Mismatch Prevention | Aggregator pooled virtual accounts | Invariant Single-Slot FIFO UPI Queue |
| Branding Control | "Secured by Razorpay" badges mandatory | 100% White-Label (Your brand, your domain, zero mentions) |
| Offline Retail Till Desk | Expensive add-ons / dedicated POS hardware | Built-in POS Cash & Card at Till Billing Mode |
| Deployment Simplicity | Proprietary SaaS lock-in | Native Node.js host process (Zero Docker mandatory) |
YOUPI PG converts your standard Indian personal or business UPI receiving accounts into an automated, zero-fee payment gateway by coupling pure vector SVG QR codes with an automated multi-channel banking observation mesh.
flowchart LR
subgraph Storefront["Merchant Storefront"]
Buyer[Buyer Browser]
Cart[Checkout Button]
end
subgraph Gateway["YOUPI Gateway Instance"]
AuthGate[WhatsApp Berry Auth<br/>6-Digit OTP]
Queue[Single-Slot FIFO Queue<br/>Deterministic Arbiter]
VectorQR[ISO Vector QR Engine<br/>UPI URI]
DualTimer[Dual Timers<br/>5:00 Pay • 0:30 Verify]
end
subgraph BankingMesh["Sovereign Banking Observers"]
AndroidNode[Native Android APK<br/>SMS & Push Notifications]
GmailNode[Gmail Ingestion<br/>OAuth2 & CDP Web]
SMSNode[Google Messages<br/>Headless CDP]
end
subgraph Settlement["Direct Bank Settlement"]
MerchantBank[(Merchant Bank Account<br/>Direct P2P UPI Transfer)]
end
Buyer -->|Clicks Checkout| Cart
Cart -->|youpi.js Embed| AuthGate
AuthGate -->|Verified| Queue
Queue -->|Active Slot| VectorQR
VectorQR -->|Displays Dynamic QR| Buyer
Buyer -->|Scans & Pays with any UPI App<br/>GPay / PhonePe / Paytm / CRED| MerchantBank
MerchantBank -->|Pushes Cellular SMS & Alerts| AndroidNode
MerchantBank -->|Pushes Credit Alert Email| GmailNode
AndroidNode -->|HMAC-SHA256 Signed Alert| DualTimer
GmailNode -->|Normalized Amount & UTR| DualTimer
DualTimer -->|Confirmed SUCCESS| Buyer
DualTimer -->|Authoritative Server Webhook| Cart
Every rupee paid goes straight from your customer's bank account to your bank account via standard NPCI UPI rails. No intermediaries hold your money.
No more fake orders, bot spam, or fraudulent phone numbers. Before a customer can enter the checkout queue, the gateway delivers a cryptographically random 6-digit OTP directly to their WhatsApp app using the embedded Baileys/Berry Protocol socket. Verified customer profiles are remembered in browser localStorage.
Because standard UPI alerts do not carry arbitrary merchant metadata, multiple concurrent transactions with identical amounts could create attribution confusion. YOUPI PG solves this with a mathematical invariant:
com.youpi.observer)A lightweight, battery-optimized Android foreground service that captures:
android.provider.Telephony.SMS_RECEIVED).NotificationListenerService.Dual backup observation channels:
CASH_COUNTER), and Card at POS Terminal (CARD_COUNTER) with an interactive real-time cashier till dock and instant SSE customer approval.Rebrand the checkout portal completely through the Merchant Admin Panel:
pay.yourbrand.com).Never leave customers hanging with blank screens or 404 errors:
/order-success — Payment verified by observers, order marked paid and provisioned./order-failed — Verification timed out, reassuring customer no money was lost./order-suspicious — Flagged by fraud heuristics, held for manual compliance review./order-expired — 5-minute session elapsed, slot released for queued customers./order-cancelled — Customer cancelled checkout session.>= 20.0.0 LTS (node -v)Standard npm install works out-of-the-box across all packages and apps without any protocol issues:
git clone https://github.com/gxurav1710/YouPI-PG.git youpi-pg
cd youpi-pg
npm install
cp .env.example .env
(The default .env is pre-configured for localhost out of the box).
On first launch, YOUPI PG automatically provisions data/youpi_pg.sqlite, creates the directory if missing, and executes idempotent migrations and baseline seeds. No manual database setup is required:
npm run dev
# or
npm start
That's it! Your entire gateway cluster will spin up:
http://localhost:8090http://localhost:6001http://localhost:5000http://localhost:6100http://localhost:7000Verify all 31 test suites across packages, apps, and chaos harnesses:
npm test
============================================================
🧪 YOUPI PG V2 — FULL REGRESSION TEST RUNNER
Running 31 curated test suites...
============================================================
[1/31] Testing packages/common/src/__tests__/common.test.js... ✅ PASS (0.22s)
...
[31/31] Testing scripts/production-infrastructure.test.js... ✅ PASS (0.17s)
============================================================
🎉 ALL 31 TEST SUITES PASSED CLEANLY (Total: 17.68s)
============================================================
Integrating YOUPI PG into your website, web app, or e-commerce store takes less than 5 minutes.
<head><!-- Official YOUPI PG Universal Integration Script -->
<script src="https://pay.yourdomain.com/youpi.js"
data-youpi-key="YOUR_MERCHANT_PUBLIC_KEY"
data-currency="INR">
</script>
Add data-youpi-pay attributes to any existing HTML button:
<button data-youpi-pay
data-order-id="ORDER-1001"
data-amount="499.00"
data-currency="INR">
⚡ Buy Now with YOUPI PG
</button>
The script automatically intercepts the click, opens a centered desktop modal (or mobile slide-up bottom sheet), and launches the checkout session!
window.Youpi.pay({
order_id: 'ORDER-1001',
amount: 499.00,
currency: 'INR',
name: 'Acme Digital Store',
description: 'Pro Subscription Top-Up',
handler: function(response) {
// response: { status: 'SUCCESS', order_id, amount_received, utr }
console.log(`Payment confirmed! UTR: ${response.utr}`);
window.location.href = `/order-success?order_id=${response.order_id}&utr=${response.utr}`;
},
onClose: function() {
console.log('Customer closed payment modal');
}
});
⚠️ CRITICAL SECURITY RULE: Never fulfill orders based solely on frontend browser events. Always verify the backend HMAC-SHA256 signature! Consumers MUST compute the HMAC over the raw, unparsed request bytes before any JSON parsing.
X-Gateway-Signature: sha256=<64_char_hex_hash>X-Gateway-Event: SUCCESS, X-Gateway-Delivery-Id: <uuid>, X-Gateway-Timestamp: <timestamp_ms>event: 'SUCCESS'orderId: Merchant order ID (string)amount: Formatted amount in Rupees, e.g. '499.00'amountPaise: Integer amount in Paise, e.g. 49900utr: 12-digit bank reference numberpaymentId: Unique gateway payment session UUIDimport crypto from 'node:crypto';
app.post('/api/youpi-webhook', express.raw({ type: 'application/json' }), (req, res) => {
const signature = req.headers['x-gateway-signature'] || '';
const secret = process.env.YOUPI_WEBHOOK_SECRET;
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(req.body).digest('hex');
if (signature.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
return res.status(401).json({ error: 'Invalid webhook signature' });
}
const payload = JSON.parse(req.body.toString('utf8'));
if (payload.event === 'SUCCESS') {
// Fulfill order: payload.orderId, payload.utr, payload.amount, payload.amountPaise
}
res.status(200).json({ received: true });
});
import hmac, hashlib, json
from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
@app.post("/api/youpi-webhook")
async def youpi_webhook(request: Request):
raw_body = await request.body()
signature = request.headers.get("X-Gateway-Signature", "")
secret = request.app.state.webhook_secret.encode("utf-8")
expected = "sha256=" + hmac.new(secret, raw_body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(signature, expected):
raise HTTPException(status_code=401, detail="Invalid webhook signature")
payload = json.loads(raw_body.decode("utf-8"))
if payload.get("event") == "SUCCESS":
# Fulfill order: payload["orderId"], payload["utr"], payload["amount"]
pass
return {"received": True}
<?php
$rawPayload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_GATEWAY_SIGNATURE'] ?? '';
$secret = getenv('YOUPI_WEBHOOK_SECRET');
$expected = 'sha256=' . hash_hmac('sha256', $rawPayload, $secret);
if (!hash_equals($expected, $signature)) {
http_response_code(401);
exit(json_encode(['error' => 'Invalid webhook signature']));
}
$payload = json_decode($rawPayload, true);
if (($payload['event'] ?? '') === 'SUCCESS') {
// Fulfill order: $payload['orderId'], $payload['utr'], $payload['amount']
}
http_response_code(200);
echo json_encode(['received' => true]);
?>
net/http)package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"io"
"net/http"
"os"
)
func youpiWebhookHandler(w http.ResponseWriter, r *http.Request) {
rawBody, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, "Cannot read body", http.StatusBadRequest)
return
}
defer r.Body.Close()
signature := r.Header.Get("X-Gateway-Signature")
secret := []byte(os.Getenv("YOUPI_WEBHOOK_SECRET"))
mac := hmac.New(sha256.New, secret)
mac.Write(rawBody)
expected := "sha256=" + hex.EncodeToString(mac.Sum(nil))
if !hmac.Equal([]byte(signature), []byte(expected)) {
http.Error(w, "Invalid webhook signature", http.StatusUnauthorized)
return
}
var payload struct {
Event string `json:"event"`
OrderId string `json:"orderId"`
UTR string `json:"utr"`
Amount string `json:"amount"`
AmountPaise int64 `json:"amountPaise"`
}
if err := json.Unmarshal(rawBody, &payload); err == nil && payload.Event == "SUCCESS" {
// Fulfill order: payload.OrderId, payload.UTR, payload.Amount
}
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"received":true}`))
}
YOUPI PG confirms payments without expensive commercial banking APIs using a triple-layer observation pipeline:
CUSTOMER SCANS & PAYS VIA UPI
│
▼
RECEIVING BANK ACCOUNT
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ CELLULAR SMS │ │ BANK PUSH │ │ GMAIL CREDIT │
│ ALERT ON SIM │ │ NOTIFICATION │ │ ALERT EMAIL │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
▼ ▼ │
┌──────────────────────────────────┐ │
│ NATIVE ANDROID OBSERVER APK │ │
│ com.youpi.observer (Foreground) │ │
│ HMAC-SHA256 Signed Payload │ │
└─────────────────┬────────────────┘ │
│ ▼
│ ┌───────────────────┐
│ │ GMAIL OBSERVER │
│ │ Google Cloud API │
│ └─────────┬─────────┘
│ │
└─────────────┬─────────────┘
▼
PAYMENT CORE REST ENGINE
Exact Amount & UTR Normalization
│
▼
SUCCESS CONFIRMED
apps/android-observer-app/youpi-sms-gateway.apk on any secondary Android smartphone with the receiving bank SIM. Scan the pairing QR code in Merchant Admin to establish an encrypted HMAC link.| Service | Port | Directory | Entrypoint | Responsibility |
|---|---|---|---|---|
| Payment API | 6100 |
apps/payment-api |
src/index.js |
Core REST API, state machine, DB transactions & SSE stream |
| Checkout Portal | 7000 |
apps/checkout-portal |
src/index.js |
Customer iframe checkout, dynamic vector QR, SDK bundle |
| Merchant Admin | 6001 |
apps/merchant-admin |
src/index.js |
Operations panel, till billing desk, branding customizer |
| Showcase Store | 5000 |
apps/coin-wallet-store |
src/index.js |
Reference enterprise merchant PDP, 5 outcome demonstrations |
| Control Center | 8090 |
apps/control-center |
src/index.js |
Process supervisor for starting, stopping, and logging all services |
| SMS Observer | 6002 |
apps/sms-observer |
src/index.js |
Google Messages Web automation via Chrome CDP |
| Gmail Observer | 6003 |
apps/gmail-observer |
src/index.js |
Gmail Web CDP automation & Google OAuth2 poller |
| Android APK | N/A | apps/android-observer-app |
Android OS | Intercepts cellular banking SMS and notifications |
49900 paise = ₹499.00). Floating-point rounding drift is mathematically impossible.PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;, ensuring crash safety and concurrent read performance.Deep-dive engineering manuals and operational runbooks are available in the /docs directory:
| Document | Description |
|---|---|
📘 ARCHITECTURE.md |
Canonical System Architecture & Engineering Blueprint |
🚀 docs/INSTALLATION.md |
Host installation, prerequisites & environment setup |
⚙️ docs/CONFIGURATION.md |
Environment configuration variables & secret management |
📱 docs/ANDROID_MOBILE_APP.md |
Native Android Kotlin Observer APK guide & permissions |
🔭 docs/OBSERVERS_SETUP.md |
Complete setup for Gmail, Google Messages & Android |
💳 docs/MERCHANT_INTEGRATION.md |
Full developer integration guide, SDK methods & webhooks |
🎨 docs/WHITE_LABEL.md |
White-label branding customizer, domains & Cloudflare |
🛠️ docs/OPERATIONS_TROUBLESHOOTING.md |
Production operations, logs, diagnostics & troubleshooting |
🌐 openapi.yaml |
Official OpenAPI 3.0 REST API specification |
Distributed under commercial and sovereign licensing for independent merchant deployments. See LICENSE for full terms.
Take back control of your payments. Zero middleman fees. Direct settlement.
⭐ Star this repository if you believe in open, zero-fee payment infrastructure!
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.