From 7aa8941e9c908f34ece8a4c73d8587469e53dd79 Mon Sep 17 00:00:00 2001 From: Yash Dewasthale Date: Mon, 3 Aug 2026 12:04:18 +0530 Subject: [PATCH] refactor: simplify checkout URL handling and update Dodo mode configuration: - Removed hardcoded product checkout URLs and streamlined the URL generation in the getCheckoutUrl function. - Updated the DODO_MODE environment variable in the .env.example file to default to an empty string for clarity. --- apps/supercode-cli/client/app/studio/page.tsx | 23 ++----------------- apps/supercode-cli/server/.env.example | 2 +- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/apps/supercode-cli/client/app/studio/page.tsx b/apps/supercode-cli/client/app/studio/page.tsx index 0d7eac5..282fcfe 100644 --- a/apps/supercode-cli/client/app/studio/page.tsx +++ b/apps/supercode-cli/client/app/studio/page.tsx @@ -74,28 +74,9 @@ type CreditBalance = { const CHECKOUT_BASE = process.env.NEXT_PUBLIC_DODO_CHECKOUT_BASE ?? "https://checkout.dodopayments.com/buy" -const PRODUCT_CHECKOUT_URLS: Record = { - // ── test mode ── - pdt_0Nk0u6EggnAdDxGtoLa1W: `${CHECKOUT_BASE}/pdt_0Nk0u6EggnAdDxGtoLa1W?quantity=1`, - pdt_0NkRjph71bwF2z3aBulCG: `${CHECKOUT_BASE}/pdt_0Nk0vwfI1kYrDaRsQzEUQ?quantity=1`, - pdt_0Nk0vS5WMtkT7u2T7P70e: `${CHECKOUT_BASE}/pdt_0Nk0vS5WMtkT7u2T7P70e?quantity=1`, - pdt_0NkRm62YJBP043k9sEDab: `${CHECKOUT_BASE}/pdt_0NkRm62YJBP043k9sEDab?quantity=1`, - pdt_0Nk0vwfI1kYrDaRsQzEUQ: `${CHECKOUT_BASE}/pdt_0Nk0vwfI1kYrDaRsQzEUQ?quantity=1`, - pdt_0NkRmfmsthQToUr41UAnd: `${CHECKOUT_BASE}/pdt_0NkRmfmsthQToUr41UAnd?quantity=1`, - pdt_0NkRmxBRNTOME3FYF9Qkg: `${CHECKOUT_BASE}/pdt_0NkRmxBRNTOME3FYF9Qkg?quantity=1`, - // ── live mode ── - pdt_0NkW4k2cUeO1f7a8yLje5: `${CHECKOUT_BASE}/pdt_0NkW4k2cUeO1f7a8yLje5?quantity=1`, - pdt_0NkW59I3J7uy2m1j0RAOF: `${CHECKOUT_BASE}/pdt_0NkW59I3J7uy2m1j0RAOF?quantity=1`, - pdt_0NkW5Vvq7Uxw55sjMlDFe: `${CHECKOUT_BASE}/pdt_0NkW5Vvq7Uxw55sjMlDFe?quantity=1`, - pdt_0NkW5s9M64jbHMoKrIpsl: `${CHECKOUT_BASE}/pdt_0NkW5s9M64jbHMoKrIpsl?quantity=1`, - pdt_0NkW6PfRqqooJXIMaX4Ci: `${CHECKOUT_BASE}/pdt_0NkW6PfRqqooJXIMaX4Ci?quantity=1`, - pdt_0NkW6cjti170KbFpeolfw: `${CHECKOUT_BASE}/pdt_0NkW6cjti170KbFpeolfw?quantity=1`, - pdt_0NkW6tnjud9Sp1iGr9TXj: `${CHECKOUT_BASE}/pdt_0NkW6tnjud9Sp1iGr9TXj?quantity=1`, -} - function getCheckoutUrl(plan: Plan): string | null { if (!plan.dodoProductId) return null - return PRODUCT_CHECKOUT_URLS[plan.dodoProductId] ?? null + return `${CHECKOUT_BASE}/${plan.dodoProductId}?quantity=1` } const TIER_COLORS: Record = { @@ -314,7 +295,7 @@ function StudioPage() { if (!confirmingPlan || !userId) return const url = getCheckoutUrl(confirmingPlan) if (url) { - window.location.href = url + window.open(url, "_blank", "noopener,noreferrer") } else { setConfirmingPlan(null) toast.error("Checkout URL not available for this plan") diff --git a/apps/supercode-cli/server/.env.example b/apps/supercode-cli/server/.env.example index 856a419..2972666 100644 --- a/apps/supercode-cli/server/.env.example +++ b/apps/supercode-cli/server/.env.example @@ -85,7 +85,7 @@ FIRECRAWL_API_KEY="" DODO_PAYMENTS_API_KEY="" DODO_PAYMENTS_WEBHOOK_KEY="" # ⚪ "test" to use test-mode product IDs in the seed; omit for live. -DODO_MODE="test" +DODO_MODE="" # Where Dodo redirects after checkout (used by the checkout route) # Test: set to localhost or ngrok URL # Live: https://supercode-terminal.vercel.app/studio?success=true