Idempotent Order Placement When the App Retries Checkout

Last updated: November 29, 2026

Quick Overview

Mobile clients retry the place order call on timeouts, which can create duplicate orders and double charges. Implement an order placement wrapper that uses a client supplied idempotency key so each logical checkout creates at most one order, and explain how it behaves across concurrent retries and failures.

Coupang
Software Engineering Fundamentals
Software Engineer
Coupang
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Mobile clients retry the place order call on timeouts, which can create duplicate orders and double charges. Implement an order placement wrapper that uses a client supplied idempotency key so each logical checkout creates at most one order, and explain how it behaves across concurrent retries and failures.

Coupang's checkout runs across many services (inventory reservation, Coupang Pay, order records), and flaky mobile networks in subways and elevators make retries routine. This question checks whether you understand idempotency as a contract with stored outcomes, not just a uniqueness check.

What the Interviewer Expects
  • Scope keys per user and fingerprint the request body
  • Return the stored response for a completed duplicate, reject a key reused with a different payload
  • Handle the in-flight duplicate explicitly (409 or wait), not by running the work twice
  • Decide what happens to the key when the operation fails
  • Move the record to durable storage with a unique constraint in production
  • Give keys a TTL
Key Topics to Cover
Idempotency keys
Concurrency control
Exactly-once effects
API design
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How do you make this safe across many app servers instead of one process lock?
  • The payment succeeded but the order write failed; how do you recover?
  • How long should keys live, and what does the client do after expiry?
  • How would downstream services (Coupang Pay, inventory) stay idempotent too?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

place_order(user_id, idem_key, payload) must create at most one order per (user, key). A retry with the same key and same cart returns the original result. Same key with a different cart is a clie...

High-Level Design

Keep an idempotency record per (user_id, key) with a payload hash, a state (in_progress or done), the stored response and an expiry. The check-and-insert happens atomically; the expensive work r...


Submit Your Answer
Markdown supported

Related Questions