From ac74a1d62f5de8221917d8c608136be3d57b4554 Mon Sep 17 00:00:00 2001 From: Tony Giorgio Date: Mon, 14 Jul 2025 16:08:22 -0500 Subject: [PATCH] fix: prevent Stripe users from upgrading with Bitcoin toggle enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users on Stripe plans must now cancel their subscription first before switching to Bitcoin payments. When Bitcoin toggle is enabled: - Buttons show "Cancel Stripe First" instead of upgrade/downgrade - Clicking redirects to Stripe portal for subscription management - Prevents confusing overlapping subscriptions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/routes/pricing.tsx | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/pricing.tsx b/frontend/src/routes/pricing.tsx index b9aaee5f..2158b8d6 100644 --- a/frontend/src/routes/pricing.tsx +++ b/frontend/src/routes/pricing.tsx @@ -310,6 +310,15 @@ function PricingPage() { return "Contact Us"; } + // If user is on Stripe plan but Bitcoin toggle is on, show special message + if ( + freshBillingStatus?.payment_provider === "stripe" && + useBitcoin && + !targetPlanName.includes("free") + ) { + return "Cancel Stripe First"; + } + // For team plan if (isTeamPlan) { if (isCurrentPlan) { @@ -468,6 +477,33 @@ function PricingPage() { return; } + // If user is on Stripe plan but Bitcoin toggle is on, redirect to portal to cancel + if ( + freshBillingStatus?.payment_provider === "stripe" && + useBitcoin && + !targetPlanName.includes("free") + ) { + if (portalUrl) { + if (isIOS) { + console.log("[Billing] iOS detected, using opener plugin to launch Safari for portal"); + import("@tauri-apps/api/core") + .then((coreModule) => { + return coreModule.invoke("plugin:opener|open_url", { url: portalUrl }); + }) + .then(() => { + console.log("[Billing] Successfully opened portal URL in external browser"); + }) + .catch((err) => { + console.error("[Billing] Failed to open external browser:", err); + alert("Failed to open browser. Please try again."); + }); + } else { + window.open(portalUrl, "_blank"); + } + } + return; + } + const currentPlanName = freshBillingStatus?.product_name?.toLowerCase(); const isCurrentlyOnFreePlan = currentPlanName?.includes("free"); const isTargetFreePlan = targetPlanName.includes("free"); @@ -514,7 +550,7 @@ function PricingPage() { // create checkout session newHandleSubscribe(product.id); }, - [isLoggedIn, freshBillingStatus, navigate, portalUrl, newHandleSubscribe, isIOS] + [isLoggedIn, freshBillingStatus, navigate, portalUrl, newHandleSubscribe, isIOS, useBitcoin] ); useEffect(() => {