WebHook Receiver
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."
Related Terms
Event-Driven Architecture
Event-Driven Architecture is like a gossip network. When something happens (order placed!), it broadcasts the news.
Idempotency Key
An idempotency key is a unique ID you attach to a request so the server knows if it's a duplicate.
Message Acknowledgment
Message acknowledgment is telling the queue 'I got this, you can delete it now.' Without acking, the queue keeps the message and might redeliver it.
Webhook
A webhook is like giving someone your phone number so they can call YOU when something happens, instead of you calling them every minute to check.