Skip to content

WebHook Receiver

Medium — good to knowBackend

ELI5 — The Vibe Check

A webhook receiver is an endpoint in your app that other services call when something happens. Instead of constantly asking Stripe 'any new payments?', Stripe calls YOUR endpoint when a payment comes in. You're the receiver — you just sit there waiting for the doorbell to ring. The key is verifying it's actually Stripe at the door and not an imposter.

Real Talk

A webhook receiver is an HTTP endpoint that accepts incoming webhook payloads from external services. Implementation requirements include signature verification (HMAC validation), idempotent processing (handling redeliveries), quick response times (respond 200 before processing), async processing via job queues, and proper error handling with retry expectations.

Show Me The Code

app.post('/webhooks/stripe', async (req, res) => {
  const sig = req.headers['stripe-signature'];
  let event;
  try {
    event = stripe.webhooks.constructEvent(req.body, sig, webhookSecret);
  } catch (err) {
    return res.status(400).send('Invalid signature');
  }
  // Respond immediately, process async
  res.status(200).json({ received: true });
  await queue.add('stripe-event', event);
});

When You'll Hear This

"Always verify the webhook signature before processing." / "The webhook receiver should respond 200 immediately and process the event asynchronously."

Made with passive-aggressive love by manoga.digital. Powered by Claude.