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

fix(vercel): remove circular service binding

jaygoga2188-collabf96688c885aa
diff --git a/apps/payment-api/src/index.js b/apps/payment-api/src/index.js
index cedae01..bcf1f1b 100644
--- a/apps/payment-api/src/index.js
+++ b/apps/payment-api/src/index.js
@@ -133,14 +133,18 @@ export function createPaymentApp(customDb = null, options = {}) {
const server = new HttpServer();
server.use(authGuard);
- let checkoutBaseUrl = process.env.CHECKOUT_PORTAL_URL || process.env.BASE_CHECKOUT_URL || 'http://localhost:7000';
+ let checkoutBaseUrl = process.env.CHECKOUT_PUBLIC_URL
+ || process.env.PUBLIC_APP_URL
+ || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : null)
+ || process.env.BASE_CHECKOUT_URL
+ || 'http://localhost:7000';
try {
const rootEnv = path.resolve(__dirname, '../../../.env');
if (fs.existsSync(rootEnv)) {
const raw = fs.readFileSync(rootEnv, 'utf8');
for (const line of raw.split(/\r?\n/)) {
const trimmed = line.trim();
- if (trimmed.startsWith('BASE_CHECKOUT_URL=') && !process.env.CHECKOUT_PORTAL_URL) {
+ if (trimmed.startsWith('BASE_CHECKOUT_URL=') && !process.env.CHECKOUT_PUBLIC_URL && !process.env.PUBLIC_APP_URL) {
const val = trimmed.split('=')[1]?.trim();
if (val) checkoutBaseUrl = val.replace(/^["']|["']$/g, '');
}
diff --git a/apps/payment-api/src/routes/payments.routes.js b/apps/payment-api/src/routes/payments.routes.js
index f944b29..3ab4b62 100644
--- a/apps/payment-api/src/routes/payments.routes.js
+++ b/apps/payment-api/src/routes/payments.routes.js
@@ -35,7 +35,7 @@ export function registerPaymentRoutes(server, ctx) {
if (urls && urls.checkoutUrl) return urls.checkoutUrl;
} catch {}
}
- return ctx.checkoutBaseUrl || process.env.CHECKOUT_PORTAL_URL || 'http://localhost:7000';
+ return ctx.checkoutBaseUrl || resolvePublicDeploymentOrigin() || 'http://localhost:7000';
}
// POST /api/v1/payments
diff --git a/vercel.json b/vercel.json
index a84601e..07f6c70 100644
--- a/vercel.json
+++ b/vercel.json
@@ -53,7 +53,6 @@
"runtime": "node",
"entrypoint": "vercel-entrypoint.js",
"bindings": [
- { "type": "service", "service": "checkout-portal", "format": "url", "env": "CHECKOUT_PORTAL_URL" },
{ "type": "service", "service": "gmail-observer", "format": "url", "env": "GMAIL_OBSERVER_URL" },
{ "type": "service", "service": "sms-observer", "format": "url", "env": "SMS_OBSERVER_URL" }
]