Full Stack Developer Interview Question

How would you make sure a payment webhook never charges or provisions a customer twice?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Treat delivery as at least once and make the handler idempotent. Verify the signature first, then store the provider event id behind a unique constraint and return 200 immediately if you have already seen it. Do the state change and the id insert inside one transaction so a crash cannot half apply it. Keep the handler fast by queuing slow work, and let the provider retry when you genuinely fail.

Why interviewers ask this

Payments are where correctness bugs cost money and trust, so the interviewer wants evidence you have thought about distributed delivery guarantees. They are listening for idempotency enforced at the database rather than with an in memory set, for signature verification, and for what your handler returns on failure. Candidates who have run this in production usually mention out of order events, which is the second bug everyone hits.

How to structure your answer

  • Establish that webhook delivery is at least once.
  • Describe idempotency enforced by a unique constraint.
  • Put the effect and the marker in one transaction.
  • Explain what you return on success and on failure.

Example answer

Spoken example, first person

The assumption I start from is that the provider will deliver the same event more than once, out of order, and sometimes hours late, because all three happen. So the handler verifies the signature and timestamp first, then inserts the provider event id into a processed_events table with a unique index. If that insert conflicts, we have handled it, and I return 200 straight away rather than doing the work again. The important detail is that the insert and the actual effect, granting the subscription or recording the payment, happen in the same transaction, so a process dying halfway cannot leave one without the other. Anything slow, like sending a receipt email, goes on a queue with its own idempotency key. I also store the event timestamp and ignore an event older than the state I already have, which is what saves you when a cancellation arrives before the upgrade that preceded it. On failures I return a 500 deliberately so the provider retries, and I alert if an event lands in the dead letter queue.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What do you do when events arrive out of order?
  • How would you replay events after fixing a bug in the handler?
  • How do you handle a message that fails every retry?

Related full stack developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot