From d734179302ab3c2a7a2aafe7f03ea150b026e441 Mon Sep 17 00:00:00 2001 From: Zixin Zhou Date: Wed, 27 Aug 2025 23:56:27 +0800 Subject: [PATCH] update pay --- app/dashboard/page.tsx | 3 ++- app/payment-success/page.tsx | 3 ++- app/pricing/page.tsx | 32 ++++++++++++++++---------------- components/pages/home-page2.tsx | 17 ++++++----------- lib/stripe.ts | 6 +++--- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 6047257..036c12f 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -58,7 +58,8 @@ export default function DashboardPage() { // 获取支付详情 const fetchPaymentDetails = async (sessionId: string) => { try { - const response = await fetch(`/api/payment/checkout-status/${sessionId}?user_id=test_user_123`); + const User = JSON.parse(localStorage.getItem("currentUser") || "{}"); + const response = await fetch(`/api/payment/checkout-status/${sessionId}?user_id=${User.id}`); const result = await response.json(); if (result.successful && result.data) { diff --git a/app/payment-success/page.tsx b/app/payment-success/page.tsx index 66963da..589d424 100644 --- a/app/payment-success/page.tsx +++ b/app/payment-success/page.tsx @@ -42,7 +42,8 @@ export default function PaymentSuccessPage() { try { // 使用新的Checkout Session状态查询 const { getCheckoutSessionStatus } = await import('@/lib/stripe'); - const result = await getCheckoutSessionStatus(sessionId, 'test_user_123'); // 临时测试用户ID + const User = JSON.parse(localStorage.getItem("currentUser") || "{}"); + const result = await getCheckoutSessionStatus(sessionId, User.id); if (result.successful && result.data) { setPaymentData(result.data); diff --git a/app/pricing/page.tsx b/app/pricing/page.tsx index 4a8316d..7f61a3a 100644 --- a/app/pricing/page.tsx +++ b/app/pricing/page.tsx @@ -9,7 +9,7 @@ import { fetchSubscriptionPlans, SubscriptionPlan } from '@/lib/stripe'; export default function PricingPage() { const router = useRouter(); - const [billingCycle, setBillingCycle] = useState<'monthly' | 'yearly'>('monthly'); + const [billingCycle, setBillingCycle] = useState<'month' | 'year'>('month'); const [plans, setPlans] = useState([]); // 从后端获取订阅计划数据 @@ -28,15 +28,15 @@ export default function PricingPage() { // 转换后端数据为前端显示格式,保持原有的数据结构 const transformPlanForDisplay = (plan: SubscriptionPlan) => { - const monthlyPrice = plan.price_monthly / 100; // 后端存储的是分,转换为元 - const yearlyPrice = plan.price_yearly / 100; + const monthlyPrice = plan.price_month / 100; // 后端存储的是分,转换为元 + const yearlyPrice = plan.price_year / 100; return { name: plan.name, displayName: plan.display_name, price: { - monthly: monthlyPrice, - yearly: yearlyPrice + month: monthlyPrice, + year: yearlyPrice }, description: plan.description, features: plan.features || [], @@ -103,16 +103,16 @@ export default function PricingPage() {