Back to Problem DungeonStep 1: Requirements
Requirements
Questions to Ask the Interviewer
- Which payment gateways do we support? (Start with Stripe, Razorpay, PayPal — must be extensible)
- Do we need to support refunds? (Yes — full and partial)
- What payment methods? (Credit card, debit card, UPI, net banking, wallets)
- Do we handle webhooks from gateways? (Yes — async payment confirmations)
- Currency support? (Single currency for now, multi-currency later)
- Retry policy on failures? (Yes — with idempotency keys)
- Do we store card details? (No — tokenized via gateway, PCI compliance out of scope)
Functional Requirements
- Process payments through multiple gateways
- Support payment lifecycle: created → processing → completed / failed
- Handle refunds (full and partial)
- Receive and process webhook notifications from gateways
- Generate payment receipts
- Idempotent payment processing (retry-safe)
Non-Functional Requirements
- Idempotency on all payment operations
- Audit trail for every state transition
- Gateway timeout handling (30s max)
- Eventual consistency for webhook-driven updates
Constraints
- No direct card storage (PCI)
- Gateway APIs are external and unreliable
- Webhooks may arrive before or after the synchronous response
- Refund can only happen on completed payments