Set up Stripe Webhooks for complex payment scenarios
mainWhile the boilerplate includes built-in Stripe integration that verifies payments automatically, you can optionally set up webhooks to handle advanced logic like usage-based billing, custom subscription workflows, or customer dashboards.
To configure webhooks:
- In your Stripe Dashboard, navigate to Developers > Webhooks and click Add endpoint.
- Set the endpoint URL based on your environment:
- Local development:
http://localhost:8787/webhooks/stripe - Production:
https://your-worker-name.your-account.workers.dev/webhooks/stripe
- Local development:
- Select relevant events (e.g.,
checkout.session.completed,invoice.payment_succeeded,customer.subscription.updated). - Copy the Signing secret and add it to your environment configuration.
# Local development (.dev.vars)
STRIPE_WEBHOOK_SECRET="whsec_your-webhook-secret-here"# Production (using Wrangler)
npx wrangler secret put STRIPE_WEBHOOK_SECRET