Testing Stripe webhooks on localhost
Florian Wartner · 2026-06-28
Stripe delivers events - checkout.session.completed, invoice.paid, customer.subscription.updated - by sending an HTTP POST to an endpoint you register. That endpoint has to be reachable from the public internet, which your localhost is not. The fix is a tunnel: give your dev server a public HTTPS URL, point Stripe at it, and you can build and debug the handler against real events without deploying anything.
npx useburrow http 3000
That prints a public URL like https://your-name.eu.useburrow.dev. Add your route to it and you have a working Stripe endpoint. The rest of this guide is the part people get wrong: verifying the signature correctly and iterating quickly with replay.
1. Tunnel your dev server
Run your app as usual, then open a tunnel to its port in a second terminal:
# terminal 1
npm run dev # or php artisan serve, etc. - listening on :3000
# terminal 2
npx useburrow http 3000
Burrow dials out over an outbound WebSocket, so it works behind any firewall or NAT - no router config, no inbound ports. Copy the printed HTTPS URL.
2. Register the endpoint in Stripe
In the Stripe Dashboard go to Developers -> Webhooks -> Add endpoint. Set the endpoint URL to your tunnel URL plus the route your app listens on, for example:
https://your-name.eu.useburrow.dev/webhooks/stripe
Select the events you care about (start narrow - checkout.session.completed is a good first one), save, and copy the Signing secret (it starts with whsec_). You will need it in the next step.
3. Verify the signature - properly
This is where most localhost setups break. Stripe signs every webhook with a Stripe-Signature header, and your handler must verify it against the raw, unmodified request body. If your framework parses the body into JSON before you verify, the bytes change and the signature check fails.
The rule: verify against the raw body, then parse.
Node / Express:
import express from 'express'
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
const app = express()
// Note express.raw - NOT express.json - on the webhook route.
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), (req, res) => {
const sig = req.headers['stripe-signature']
let event
try {
event = stripe.webhooks.constructEvent(req.body, sig, process.env.STRIPE_WEBHOOK_SECRET)
} catch (err) {
return res.status(400).send(`Webhook signature verification failed: ${err.message}`)
}
if (event.type === 'checkout.session.completed') {
// fulfil the order
}
res.json({ received: true })
})
Laravel handles the raw body for you if you use Cashier's webhook controller, or you can verify manually with \Stripe\Webhook::constructEvent($request->getContent(), $request->header('Stripe-Signature'), $secret). The key detail is the same: pass getContent() (the raw body), not a re-encoded array.
A tunnel does not change any of this. Burrow forwards the request body untouched, so signature verification behaves exactly as it will in production. If verification fails through the tunnel, it would fail when deployed too - which makes the tunnel a useful place to catch the bug early.
4. Trigger and replay
You can trigger a real test event from the Stripe Dashboard, or use the Stripe CLI's stripe trigger checkout.session.completed. Either way the event lands on your local route through the tunnel.
Now the part that saves the most time: open the local inspector at http://127.0.0.1:4040. Every delivery is listed with its method, path, status, and timing. Click one to see the full headers and body, confirm the Stripe-Signature verified, and replay it with one click. Replay re-issues the exact captured request against your local route, so you can iterate on the handler dozens of times without going back to Stripe to fire a new event each time.
Webhook bugs are painful precisely because the event already happened. Replay turns a one-shot event into something you can run on demand while you fix the code.
5. Keep the endpoint URL stable (optional)
By default each tunnel gets a fresh URL, which means re-registering the endpoint in Stripe after a restart. On the Pro plan you can reserve a subdomain or attach a custom domain so the URL stays put:
npx useburrow http 3000 --subdomain acme
# -> https://acme.eu.useburrow.dev (stable across restarts)
Register that once in Stripe and you are done.
Common pitfalls
- 400 signature errors: almost always a parsed-body problem. Verify against the raw bytes before any JSON middleware touches them.
- Wrong signing secret: the dashboard endpoint secret and the Stripe CLI's local secret are different values. Use the one that matches how the event is being sent.
- Returning slow 2xx: acknowledge fast (return 200 quickly) and do heavy work asynchronously, or Stripe will retry and you will process duplicates. Make your handler idempotent.
- Testing only the happy path: replay failure and edge-case events from the inspector to exercise your error handling.
Where to go next
Stripe is the most common case, but the same pattern works for GitHub, Shopify, Clerk, Twilio, and any other provider. See the dedicated Stripe testing use case and the broader webhook testing guide for the general recipe, or the older walkthrough on testing webhooks locally.
Coming from another tool? The ngrok alternative page covers how Burrow compares for webhook work - the short version is an EU-only data path, a local inspector with replay, and an honest free tier.