handle subscribe success
This commit is contained in:
parent
c765368382
commit
147cacb1e4
@ -214,12 +214,35 @@ async function handleSubscriptionDeleted(subscription: Record<string, unknown>)
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePaymentSucceeded(_invoice: Record<string, unknown>) {
|
||||
async function handlePaymentSucceeded(invoice: Record<string, unknown>) {
|
||||
try {
|
||||
// 这里可以添加额外的逻辑,比如发送确认邮件等
|
||||
console.log('💰 Processing payment succeeded')
|
||||
|
||||
const subscriptionId = invoice.subscription as string
|
||||
const customerId = invoice.customer as string
|
||||
|
||||
console.log('Payment details:', {
|
||||
subscriptionId,
|
||||
customerId,
|
||||
amount: invoice.amount_paid,
|
||||
status: invoice.status
|
||||
})
|
||||
|
||||
if (!subscriptionId) {
|
||||
console.log('❌ No subscription ID found in invoice, skipping')
|
||||
return
|
||||
}
|
||||
|
||||
// 获取订阅详情
|
||||
console.log('📞 Retrieving subscription from Stripe...')
|
||||
const subscription = await stripe.subscriptions.retrieve(subscriptionId)
|
||||
console.log('✅ Retrieved subscription:', subscription.id, 'status:', subscription.status)
|
||||
|
||||
// 处理订阅更新(激活逻辑)
|
||||
await handleSubscriptionUpdate(subscription as unknown as Record<string, unknown>)
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error handling payment success:', error)
|
||||
console.error('❌ Error handling payment success:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user