Design an Idempotent Payments API
Square's real Payments API takes an idempotency_key as a field in the request body, and the timed-out payment is the failure it exists to absorb. The setup is concrete. A seller dips a card on a Square Reader or checks out online, and the app posts a payment. The request reaches the server and the authorization succeeds. Then the response is lost coming back. A timeout. The app now has no idea whether the buyer was charged. Retry blindly and it charges twice. Give up and it may have taken money for a sale it cannot confirm. That single failure, a lost response over an unreliable network, is the problem in full, and idempotency is the answer.
Start by naming what is and is not achievable. Exactly-once delivery over a network is impossible: any message can be lost, and the sender can never tell a lost request apart from a lost response. So we aim for the next best thing. The seller's app retries until it gets an answer, which gives us at-least-once delivery, and the server makes processing idempotent, so a repeated request produces the same single result. At-least-once delivery plus idempotent processing gives you effectively-once, the property money movement needs. Say that out loud early. It frames every decision that follows.
POST /v2/payments, so put the key on the write path before anyone asks for it. Block's pitch to sellers is economic empowerment, which in engineering terms means never quietly losing or double-taking a small merchant's money. The panel rewards explicit engagement with the fintech specifics. A candidate who opens with throughput math has misread the round. Open with the lost response.- 3 diagrams
- 5 sections
- about 40 min
Premium lessonBlock interview guide
These took digging.
What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.
100 companies. Checked every month.
Unlock all 100 companies$49 a year · less than $1 a week · Cancel anytime
Block interview guideKnow what Block asks before you walk in.
13 coding · 5 system design · 14 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.