← cookbook/stripe-webhooks-grid
7 min read·intermediate·updated just now

Stripe webhooks → live revenue grid

A Cloudflare Worker that verifies Stripe webhook signatures, normalises events, and lands each one into an Instadash grid your finance team can look at.

#stripe#webhooks#finance#cloudflare

What it builds

  • HMAC-SHA256 signature verification (no SDK dependency)
  • Event normalisation into a stable 7-field schema
  • Idempotent writes — Stripe retries dedupe on event_id
  • Local testing via stripe listen + stripe trigger

The key step

async function verifyStripeSignature(payload, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(',').map(p => p.split('=')))
  const key = await crypto.subtle.importKey('raw',
    new TextEncoder().encode(secret),
    { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])
  const sig = await crypto.subtle.sign('HMAC', key,
    new TextEncoder().encode(`${t}.${payload}`))
  return toHex(sig) === v1   // constant-time in real code
}
note
This is the core of the recipe. The full file (including setup, error handling, and the surrounding scaffolding) lives in the GitHub folder linked below — clone or copy it directly.

Run it

bash⎘ copy
git clone https://github.com/instadashio/instadash-recipes
cd instadash-recipes/stripe-webhooks-grid
npx wrangler secret put INSTADASH_KEY
cp .env.example .env       # fill in your keys
npm run deploy

Stack

cloudflare-workerstypescriptstripe
Full source on GitHub

README, runnable code, .env.example, dependencies — all in one folder.

↗ view on github
─ related recipesview all →