Quick overview
This workflow receives Stripe or Shopify payment webhooks, verifies each request’s HMAC signature (with replay protection for Stripe), and deduplicates retries using an external idempotency key store before acknowledging the webhook with a success or rejection response.
How it works
- Receives an incoming POST webhook request with the raw body enabled.
- Detects whether the request comes from Stripe or Shopify by checking the presence of the provider-specific signature header.
- Verifies the webhook signature using HMAC-SHA256 (including a 300-second timestamp window for Stripe) and outputs a normalized payload with provider, event ID, and event type.
- If the signature is invalid, returns a 401 response indicating an invalid webhook signature.
- If the signature is valid, builds an idempotency key from the provider and event ID and checks an external key-value store to see whether the event was already processed.
- If the event is a duplicate, returns a 200 response acknowledging the webhook as deduplicated.
- If the event is new, records an idempotency lock with a 24-hour TTL, normalizes the event name, and returns a 200 response indicating the webhook is processed.
Setup
- Configure the webhook URL in Stripe and/or Shopify to point to this workflow’s webhook endpoint.
- Set the environment variables
STRIPE_WEBHOOK_SECRET and/or SHOPIFY_WEBHOOK_SECRET to the signing secrets from your Stripe/Shopify webhook settings.
- Provide an idempotency store endpoint in
IDEMPOTENCY_KV_URL that supports a GET lookup by ?key= and a POST to record { key, ttl_seconds }, and adjust the requests if your store uses a different API.