fix addup
This commit is contained in:
parent
ace22f60a9
commit
4c953dbe5f
@ -195,31 +195,7 @@ 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 }),
|
||||
})
|
||||
|
||||
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')
|
||||
}
|
||||
} else {
|
||||
// 生产环境:使用 Stripe
|
||||
// 统一使用 Stripe 支付
|
||||
const response = await fetch('/api/credits/stripe-topup', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -236,7 +212,6 @@ export default function CreditsPage() {
|
||||
} else {
|
||||
alert(data.error || 'Failed to create payment session')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Top-up error:', error)
|
||||
alert('Failed to process top-up. Please try again.')
|
||||
|
Loading…
Reference in New Issue
Block a user