Skip to content
RED SAGSkills
mediumBackend Developer interview question

Your service receives webhooks from a payment provider. How do you make handling them secure and reliable?

What the interviewer wants to hear

  • Verify the signature on the raw body and check timestamps
  • Respond quickly with 2xx and process asynchronously
  • Deduplicate by event id because deliveries can repeat
  • Handle out-of-order events, for example by fetching current state
  • Monitor failures and support replay or reconciliation

Model answer

First, security: I verify the HMAC signature over the raw request body using a constant-time comparison, and reject events with old timestamps to stop replays. Then I store the event and return 200 quickly, because providers time out and retry if the handler is slow. The real processing happens in a background worker that reads from a queue or the stored events table. Providers deliver at least once, so I deduplicate using the event id with a unique constraint, which makes processing idempotent. Events can also arrive out of order, for example "refunded" before "paid", so I either compare timestamps or versions, or fetch the latest object state from the provider API before updating. Finally, I alert when processing fails, keep failed events for replay, and run a periodic reconciliation job that compares our records with the provider's in case a webhook was missed entirely.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Backend Developer questions