Design a Refund Ledger for Wallet and Gift Card Balances
Last updated: November 29, 2026
Quick Overview
Design the ledger that records customer wallet and gift card balances on Flipkart, supporting credits from refunds and cashback, debits at checkout, and an auditable history, with strict correctness under retries.
Flipkart
November 29, 20260
0
0 solved
Design the ledger that records customer wallet and gift card balances on Flipkart, supporting credits from refunds and cashback, debits at checkout, and an auditable history, with strict correctness under retries.
Flipkart issues refunds and cashback into stored value balances at very high volume, especially after sale events and returns. The interviewer looks for double entry thinking, idempotency, and how balances stay correct when payment and order services retry.
What the Interviewer Expects
- Use an append only double entry ledger rather than mutable balance rows only
- Make every posting idempotent with a client supplied key
- Prevent negative balances under concurrent debits
- Explain how balances are derived and cached
- Cover reconciliation with payment gateways and the order system
- Handle expiring balances like promotional cashback
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you handle a refund that arrives before the original debit is recorded?
- How would you shard this ledger as accounts grow to hundreds of millions?
- How would you support partial reversals, such as one item of a three item order?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: credit (refund, cashback, gift card load), debit (checkout), hold and capture for checkout, balance query, statement history, expiry of promotional credits.
Non functional: no los...
High-Level Design
Callers (Order, Returns, Payments, Promotions) -> Ledger API -> relational store sharded by account_id.
Tables: accounts(id, currency, status), journal(txn_id, idem_key, type, created_at), ...