diff --git a/src/app/credits/page.tsx b/src/app/credits/page.tsx index 89c2ca9..310d87f 100644 --- a/src/app/credits/page.tsx +++ b/src/app/credits/page.tsx @@ -195,47 +195,22 @@ export default function CreditsPage() { setIsTopUpLoading(true) try { - // 首先检查是否是开发环境 - const isDevelopment = process.env.NODE_ENV === 'development' - - if (isDevelopment) { - // 开发环境:使用模拟充值 - const response = await fetch('/api/credits/topup', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ amount }), - }) + // 统一使用 Stripe 支付 + const response = await fetch('/api/credits/stripe-topup', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ amount }), + }) - const data = await response.json() + const data = await response.json() - if (response.ok && data.success) { - alert(`Successfully topped up $${amount}!`) - setShowTopUpModal(false) - setTopUpAmount('') - loadCreditData() - } else { - alert(data.error || 'Failed to process top-up') - } + if (response.ok && data.success && data.sessionUrl) { + // 重定向到 Stripe Checkout + window.location.href = data.sessionUrl } else { - // 生产环境:使用 Stripe - const response = await fetch('/api/credits/stripe-topup', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ amount }), - }) - - const data = await response.json() - - if (response.ok && data.success && data.sessionUrl) { - // 重定向到 Stripe Checkout - window.location.href = data.sessionUrl - } else { - alert(data.error || 'Failed to create payment session') - } + alert(data.error || 'Failed to create payment session') } } catch (error) { console.error('Top-up error:', error)