Stripe Webhooks — Internal Operations Guide
This page supplements the public Stripe Webhooks documentation with internal operational details.
Architecture
Stripe → POST /v1/webhooks/stripe → Signature Verification → Event Router → Account State Machine
Event processing pipeline
- Signature verification — HMAC-SHA256 using
STRIPE_WEBHOOK_SECRETfrom Secret Manager - Idempotency check — Stripe event ID lookup in
stripe_eventstable - Event routing — dispatches to handler based on
event.type - Account state transition — updates account
statusfield - Notification — triggers email via notification service
Environment variables
| Variable | Source | Description |
|---|---|---|
STRIPE_WEBHOOK_SECRET | Secret Manager | Webhook signing secret from Stripe dashboard |
STRIPE_SECRET_KEY | Secret Manager | API key for Stripe API calls (subscription lookups) |
Account state machine
active ──[payment_failed]──→ suspended
suspended ──[payment_succeeded]──→ active
active ──[subscription.deleted]──→ suspended
Monitoring
- Alert:
stripe_webhook_failures > 5in 5 minutes (PagerDuty) - Dashboard: Stripe webhook processing latency and error rate
- Logs:
jsonPayload.component="stripe_webhook"in Cloud Logging
Testing locally
# Forward Stripe events to local server
stripe listen --forward-to localhost:8080/v1/webhooks/stripe
# Trigger a test event
stripe trigger invoice.payment_succeeded
Retry behavior
Stripe retries failed webhook deliveries for up to 3 days with exponential backoff. Our endpoint MUST return 200 within 20 seconds or Stripe considers it failed.
If the endpoint is down for an extended period:
- Check Cloud Run service health
- Review Cloud Logging for errors
- Stripe Dashboard > Developers > Webhooks shows delivery attempts
- After fixing, failed events replay automatically