Design an Offline Merchant Payment System with Reconciliation
OpenAISoftware Engineer · Technical ScreenLast updated
This question tests your ability to design a distributed payment architecture that supports asynchronous transactions and reliable reconciliation between offline Point-of-Sale (POS) terminals and a centralized ledger.
Scenario
Design a system for a retail merchant with 10,000 POS terminals that must be able to accept payments even when internet connectivity is intermittent or unavailable. Once the connection is restored, these payments must be synchronized with a central server and reconciled against bank records.
Requirements
- Functional:
- POS terminals must authorize and store payments locally if offline.
- System must provide eventual consistency across all distributed nodes.
- Reconciliation process must identify discrepancies between POS logs and actual bank deposits.
- Non-Functional:
- High availability during network partitions.
- Strict data integrity (no transaction loss).
- Low-latency response for the initial customer payment.
Scope
Provide a high-level design that includes:
- A data model for transaction records that tracks state (e.g., PENDING, SYNCED, RECONCILED).
- The communication strategy between terminals and the central backend.
- A reconciliation strategy to handle mismatched records.
- Handling of duplicate transaction submissions if a network connection drops mid-upload.
Expectations
- Draw/describe the components: POS terminal, local database, message queue, backend API, and reconciliation engine.
- Define the API endpoints for synchronization.
- Discuss the trade-offs between 'optimistic' offline authorization and fraud risks.
Hints
Hint 1
Consider using an idempotency key generated at the POS level for every transaction to prevent double-charging during synchronization retries.
Hint 2
The reconciliation process should involve a multi-stage comparison: comparing terminal logs to backend entries, and then comparing backend entries to bank settlement reports.
Hint 3
Think about the state machine of a transaction, ensuring that a transaction can only move forward in the lifecycle (e.g., from 'Created' to 'Synced' to 'Reconciled').
Follow-up questions
- How would you handle a scenario where a customer's card is declined by the bank, but the POS terminal authorized it while the merchant was offline?
- If the central server experiences a spike in traffic during a re-sync event, how would you implement flow control or rate limiting for the POS terminals?
- How would you evolve this design to handle millions of transactions per hour across multiple geographic regions?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.