Live demo of the Whirlwind template, as shippedStripe test mode: card 4242 4242 4242 4242, any future date, any CVCGet Whirlwind →

Webhooks

Handling Stripe webhook events and keeping the DB in sync.

Endpoint

The handler is app/api/webhook/stripe/route.js. It verifies the signature with STRIPE_WEBHOOK_SECRET before reading anything.

Events it handles

- checkout.session.completed: record the purchase, email the claim link - customer.subscription.created and updated: upsert public.subscriptions - customer.subscription.deleted: mark the subscription ended, remove access - invoice.payment_failed: logged for follow-up - charge.refunded: mark the purchase refunded, remove access

Register it

1. Stripe dashboard → Developers → Webhooks → Add endpoint 2. URL: https://yourapp.com/api/webhook/stripe 3. Select the five events above 4. Copy the signing secret into STRIPE_WEBHOOK_SECRET
💡

Production needs its own endpoint and secret. npm run deploy reminds you.