import Link from "next/link"; import { redirect } from "next/navigation"; import { CreditCard, ShieldCheck, Sparkles } from "lucide-react"; import { auth } from "@/app/(auth)/auth"; import { ManageSubscriptionButton } from "@/components/billing/manage-subscription-button"; import { getCheckoutEnabledPlans, resolvePlanByMonthlyImageLimit, } from "@/lib/billing/plans"; import { getUserById } from "@/lib/db/queries"; function formatLimit(limit: number | null) { if (limit == null || limit === 0) { return "无限制"; } return `${limit.toLocaleString("zh-CN")} 张 / 月`; } export default async function BillingPage() { const session = await auth(); if (!session?.user?.id) { redirect("/login?callbackUrl=/billing"); } const user = await getUserById({ id: session.user.id }); if (!user) { redirect("/login?callbackUrl=/billing"); } const currentPlan = resolvePlanByMonthlyImageLimit(user.monthlyImageLimit); const checkoutEnabledPlans = getCheckoutEnabledPlans(); const checkoutAvailableCount = Object.values(checkoutEnabledPlans).filter(Boolean).length; return (

Billing Center

订阅与账单管理

查看当前套餐、权益额度,并可进入 Stripe 门户管理续费、取消和发票信息。

当前订阅

Active Plan

{currentPlan.name}

月度出图额度:{formatLimit(currentPlan.monthlyImageLimit)}

更换套餐 {currentPlan.id !== "starter" ? : null}

订阅状态

当前账号:{session.user.name || session.user.email}

已配置可下单套餐:{checkoutAvailableCount}/3

订阅权益按 Webhook 自动写回账户额度(`monthlyImageLimit`)。

说明

  • 如已完成支付但权益未刷新,可稍后重试或联系管理员检查 Webhook 配置。
  • 取消订阅后,到期会自动回退为 Starter 套餐额度。
  • 账单、付款方式、发票下载统一在 Stripe Portal 中管理。
); }