Design an Idempotent Invoice Payment Endpoint for Retried Requests

Last updated: November 29, 2026

Quick Overview

Design the API for POST /invoices/{id}/payments so that mobile clients and partner integrations can safely retry after timeouts without charging the customer twice. Describe the contract and implement the idempotency handling.

Intuit
Software Engineering Fundamentals
Software Engineer
Intuit
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design the API for POST /invoices/{id}/payments so that mobile clients and partner integrations can safely retry after timeouts without charging the customer twice. Describe the contract and implement the idempotency handling.

QuickBooks Payments and the QuickBooks Online API are used by millions of businesses and third-party apps, and a double charge is one of the worst failures Intuit can ship. Interviewers check that you know how idempotency keys work end to end, including key scope, request fingerprinting, in-flight requests and the interaction with the downstream processor.

What the Interviewer Expects
  • Require a client-generated Idempotency-Key header scoped per merchant
  • Store the key with a request fingerprint and the final response, replaying it on retry
  • Reject reuse of a key with a different body
  • Handle concurrent duplicates while the first request is still in flight
  • Pass the key to the payment processor so a timeout cannot hide a success
Key Topics to Cover
idempotency keys
API design
retries
payments
concurrency
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 long should keys be retained and what happens after expiry?
  • How would you make the key record and the charge atomic across your database and an external processor?
  • What status codes would you return for each case and why?
  • How do you handle a partner that generates a new key on every retry?
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

POST /v3/invoices/{invoice_id}/payments with body {amount_cents, currency, payment_method_id} and header Idempotency-Key. Same key and same body must return the same result, with the charge exec...

High-Level Design

Store rows keyed (merchant_id, idempotency_key) with a unique constraint, holding a SHA-256 fingerprint of the canonical body, a state (processing or done), the saved response and a timestamp. T...


Submit Your Answer
Markdown supported

Related Questions