From 1acc15636383d1eb659f0d31ed81a60827e8529b Mon Sep 17 00:00:00 2001 From: MaheshtheDev <38828053+MaheshtheDev@users.noreply.github.com> Date: Sat, 9 May 2026 19:52:21 +0000 Subject: [PATCH] fix: payment upgrade issue (#918) --- .../components/add-document/connections.tsx | 8 +- apps/web/components/add-document/index.tsx | 12 +- .../integrations/plugins-detail.tsx | 11 +- apps/web/components/settings/account.tsx | 339 +++++++++--------- .../components/settings/connections-mcp.tsx | 11 +- apps/web/hooks/use-token-usage.ts | 2 + 6 files changed, 194 insertions(+), 189 deletions(-) diff --git a/apps/web/components/add-document/connections.tsx b/apps/web/components/add-document/connections.tsx index 955a0345..c8e748ad 100644 --- a/apps/web/components/add-document/connections.tsx +++ b/apps/web/components/add-document/connections.tsx @@ -243,13 +243,19 @@ export function ConnectContent({ selectedProject }: ConnectContentProps) { const handleUpgrade = async () => { setIsUpgrading(true) try { - await autumn.attach({ + const result = await autumn.attach({ planId: "api_pro", successUrl: window.location.href, }) + if (result?.paymentUrl) { + window.open(result.paymentUrl, "_self") + return + } + autumn.refetch?.() } catch (error) { console.error("Upgrade error:", error) toast.error("Failed to start upgrade process") + } finally { setIsUpgrading(false) } } diff --git a/apps/web/components/add-document/index.tsx b/apps/web/components/add-document/index.tsx index eb286cff..12406853 100644 --- a/apps/web/components/add-document/index.tsx +++ b/apps/web/components/add-document/index.tsx @@ -393,13 +393,19 @@ export function AddDocument({ onClick={async () => { setIsUpgrading(true) try { - await autumn.attach({ + const result = await autumn.attach({ planId: "api_pro", - successUrl: "https://app.supermemory.ai/settings#account", + successUrl: `${window.location.origin}/settings#account`, }) - window.location.reload() + if (result?.paymentUrl) { + window.open(result.paymentUrl, "_self") + return + } + autumn.refetch?.() } catch (error) { console.error(error) + toast.error("Failed to start checkout. Please try again.") + } finally { setIsUpgrading(false) } }} diff --git a/apps/web/components/integrations/plugins-detail.tsx b/apps/web/components/integrations/plugins-detail.tsx index 1fff4441..c7b43f23 100644 --- a/apps/web/components/integrations/plugins-detail.tsx +++ b/apps/web/components/integrations/plugins-detail.tsx @@ -495,13 +495,18 @@ export function PluginsDetail() { const handleUpgrade = async () => { try { - await autumn.attach({ + const result = await autumn.attach({ planId: "api_pro", - successUrl: "https://app.supermemory.ai/?view=integrations", + successUrl: `${window.location.origin}/?view=integrations`, }) - window.location.reload() + if (result?.paymentUrl) { + window.open(result.paymentUrl, "_self") + return + } + autumn.refetch?.() } catch (error) { console.error(error) + toast.error("Failed to start checkout. Please try again.") } } diff --git a/apps/web/components/settings/account.tsx b/apps/web/components/settings/account.tsx index 43d6303d..bb447a6c 100644 --- a/apps/web/components/settings/account.tsx +++ b/apps/web/components/settings/account.tsx @@ -9,7 +9,6 @@ import { } from "@/hooks/use-account-settings" import { Avatar, AvatarFallback, AvatarImage } from "@ui/components/avatar" import { useTokenUsage } from "@/hooks/use-token-usage" -import { formatUsageNumber } from "@/lib/billing-utils" import { Dialog, DialogContent, @@ -57,36 +56,123 @@ function SettingsCard({ children }: { children: React.ReactNode }) { ) } -function PlanFeatureRow({ - icon, - text, - variant = "muted", +function PlanComparisonCard({ + name, + price, + period, + description, + credits, + features, + highlight, }: { - icon: "check" | "x" - text: string - variant?: "muted" | "highlight" + name: string + price: string + period: string + description: string + credits: string + features: string[] + highlight: boolean }) { return ( -
+ {name} +
+ {highlight && ( + + RECOMMENDED + + )} +- {text} - + {description} +
+ ++ {credits} +
++ of usage included +
+- {formatUsageNumber(tokensUsed)} tokens ·{" "} - {formatUsageNumber(searchesUsed)} queries - {daysRemaining !== null && ( - <> - {" · resets in "} - {daysRemaining} day{daysRemaining !== 1 ? "s" : ""} - > - )} + {daysRemaining !== null + ? `Resets in ${daysRemaining} day${daysRemaining !== 1 ? "s" : ""}` + : ""}
@@ -457,73 +550,6 @@ export default function Account() { Manage billing - -- Free plan -
-- {planDisplayNames[currentPlan]} plan -
- - ACTIVE - -- {formatUsageNumber(tokensUsed)} tokens ·{" "} - {formatUsageNumber(searchesUsed)} queries - {daysRemaining !== null && ( - <> - {" · resets in "} - {daysRemaining} day{daysRemaining !== 1 ? "s" : ""} - > - )} + {daysRemaining !== null + ? `Resets in ${daysRemaining} day${daysRemaining !== 1 ? "s" : ""}` + : ""}
@@ -628,72 +649,32 @@ export default function Account() {- Free plan -
-- Pro plan -
- - RECOMMENDED - -