KatInterview

Card authorization with deferred tips and batch settlement

System DesignModel answer
MediumModel answerSystem Designpaymentsdistributed-systemsidempotency

Last updated

Build a payment platform for retail terminals that authorizes transactions, accepts post-authorization tip adjustments, and settles batches nightly.

You're building a payment platform for retail businesses that accept card payments through point-of-sale terminals. The flow works as follows: when a customer pays, the terminal requests an authorization for the purchase amount. After the authorization succeeds, the customer may add a gratuity, which adjusts the final charge. At the end of each business day, all finalized transactions are packaged and sent to the payment processor for settlement.

Your platform sits between the terminals and the external payment processor. The processor handles communication with card networks and banks; your job is to orchestrate authorization requests, manage tip adjustments, batch transactions for settlement, and verify that everything was processed correctly.

Focus on three areas:

Authorization and tip adjustment: Terminals operate on unreliable networks and will retry failed requests. Design the data model and API contracts so that duplicate authorization attempts don't result in multiple holds, and tip changes are applied correctly even when messages arrive out of order.

Nightly batch settlement: Each evening, gather all completed transactions and submit them to the processor. As transaction volume grows, design a system that distributes this work to finish within the available time window, handles partial failures gracefully, and guarantees each transaction is submitted exactly once.

Settlement reconciliation: After submission, the processor sends back a report of what actually settled. Design how you match these reports against your records, detect discrepancies, and resolve them.

Consider questions like: How many locations and transactions must you support? Do all locations close their day at the same time? When does the deadline for tip entry pass? What format does the processor expect for batch submission? How do you ensure money amounts are represented accurately throughout the pipeline?

Hints

Hint 1

Model transaction states explicitly—from pending authorization through settlement—and make state transitions atomic

Hint 2

Use idempotency keys for every external call and store the processor's response alongside the key to handle retries safely

Hint 3

Partition settlement work by merchant or time window, track progress per partition, and use deterministic job assignment to avoid double-submission on retry