Stripe Subscription Not Updating in Database
Quick Answer
The webhook handler doesn't process subscription lifecycle events. It needs handlers for created, updated, and deleted events. Start with "Handle subscription events" before making broader code changes.
You're in the right place if...
- !User pays but subscription status not updating
- !Database shows wrong plan after upgrade
- !Cancellation not reflected in app
Why this happens
The webhook handler doesn't process subscription lifecycle events. It needs handlers for created, updated, and deleted events.
Fix
Handle subscription events
Add these event handlers to your webhook endpoint:
switch (event.type) {
case 'customer.subscription.created':
case 'customer.subscription.updated':
await updateSubscription(event.data.object)
break
case 'customer.subscription.deleted':
await cancelSubscription(event.data.object)
break
case 'invoice.payment_failed':
await handlePaymentFailed(event.data.object)
break
}Prevent this next time
Handle ALL subscription lifecycle events, not just 'created'. Users upgrade, downgrade, cancel, and have payment failures.
Frequently Asked Questions
At minimum: subscription.created, subscription.updated, subscription.deleted, and invoice.payment_failed.
Use the Stripe CLI: stripe trigger customer.subscription.updated
Related fixes
Weekly Newsletter
Get next week's fix before you need it.
Join developers getting weekly vibe coding tips, error fixes, and tool updates.
Subscribe on Substack →