The Stripe Webhooks API handles webhook events from Stripe for subscription and payment processing.
Edge Function: stripe-webhooks
Webhook URL: https://bgbavxtjlbvgplozizxu.supabase.co/functions/v1/stripe-webhooks
Stripe webhooks are authenticated using webhook signatures:
Stripe-Signature: <signature>
The signature is verified using the STRIPE_WEBHOOK_SECRET environment variable.
Triggered when a new customer is created in Stripe.
Handles:
Triggered when customer information is updated.
Handles:
Triggered when a new subscription is created.
Handles:
Triggered when a subscription is modified.
Handles:
Triggered when a subscription is cancelled or expires.
Handles:
Triggered when a payment is successfully processed.
Handles:
Triggered when a payment fails.
Handles:
Triggered when an invoice is successfully paid.
Handles:
Triggered when invoice payment fails.
Handles:
All webhook handlers return:
{
received: true
}
{
id: string,
user_id: string,
stripe_customer_id: string,
stripe_subscription_id: string,
status: 'active' | 'cancelled' | 'past_due' | 'unpaid',
plan_id: string,
current_period_start: string,
current_period_end: string,
cancel_at_period_end: boolean,
created_at: string,
updated_at: string
}
{
id: string,
user_id: string,
stripe_payment_intent_id: string,
amount: number,
currency: string,
status: 'succeeded' | 'failed' | 'pending',
payment_method: string,
created_at: string
}
When subscription changes occur, the user profile is updated:
{
subscription_tier: 'free' | 'pro' | 'enterprise',
subscription_status: 'active' | 'cancelled' | 'past_due',
stripe_customer_id: string
}
| Tier | Features | Credits/Month |
|---|---|---|
| Free | Basic features | 100 |
| Pro | Advanced features | 1,000 |
| Enterprise | All features | 10,000 |
{
error: string
}
Common Errors:
400 - Invalid signature or webhook payload500 - Database update failedUse Stripe CLI to test webhooks locally:
stripe listen --forward-to localhost:54321/functions/v1/stripe-webhooks
stripe trigger customer.subscription.created
Monitor webhook processing: