Handle Stripe Webhook
This function handles webhooks from Stripe to synchronize subscription status with the Supabase database.
Features
-
Event Handling:
-
checkout.session.completed: Processing new subscriptions. -
customer.subscription.updated: Handling renewals, plan changes, and cancellations. -
customer.subscription.deleted: Handling subscription expiration.
-
-
Security:
-
Verifies Stripe signatures using
STRIPE_WEBHOOK_SIGNING_SECRET.
-
-
Database Updates:
-
Updates
user_subscriptionstable withstatus,current_period_end, etc. -
Uses Service Role key for secure database access.
-