Design a Customer Payment Dispute Platform
eBaySoftware Engineer · Technical ScreenLast updated
Design a resilient payment dispute resolution platform that handles dispute lifecycles, evidence management, deadline enforcement, external payment provider integration, and financial ledger auditability.
Scenario
In an e-commerce marketplace, buyers occasionally encounter issues such as unauthorized transactions, items not received, or items significantly not as described. When informal resolution fails, buyers initiate formal payment disputes. You are tasked with designing the backend for an end-to-end Customer Payment Dispute Platform.
Requirements
Functional Requirements
- Eligibility & Dispute Creation: Validate dispute eligibility against purchase date, order status, and existing dispute policies before opening a dispute.
- Evidence Collection: Allow buyers and sellers to upload documents and text evidence within strict, configurable deadlines (e.g., 5 business days for seller response).
- State Machine & Deadline Tracking: Manage dispute progression across explicit lifecycle stages (e.g.,
OPEN,SELLER_REVIEW,UNDER_INTERNAL_REVIEW,SETTLED_BUYER_FAVOR,SETTLED_SELLER_FAVOR,CLOSED). Automatically advance or close disputes when response windows expire. - Provisional Credit & Financial Settlement: Trigger provisional credits to the buyer or hold funds from seller balances, with idempotent settlements or clawbacks upon final adjudication.
- External Processor Coordination: Coordinate dispute cases with external payment networks and gateways (e.g., card networks, PayPal) using retry-safe, idempotent interfaces.
- Audit Trail & Notifications: Maintain an append-only, tamper-evident audit log of all events and state transitions, while notifying participants asynchronously at key milestones.
Non-Functional Requirements
- Scale: Support 50 million active marketplace users, generating 200,000 new disputes per month (~5,000 active disputes per day) with evidence uploads up to 15 MB per file.
- Consistency: Financial state updates and dispute lifecycle transitions must be strictly consistent and prevent double-refunds or duplicate provisional credits.
- Security: Evidence uploads must be sanitized and protected against malicious payloads, and sensitive customer data must remain strictly access-controlled.
What Your Design Should Cover
- Core APIs: Define endpoints for dispute initiation, evidence submission, status checks, and admin/system resolution.
- Data Model & State Management: Schema design for disputes, evidence metadata, deadlines, and state transitions.
- Architecture Diagram & Flow: System components showing intake, asynchronous worker queues, storage, and external gateway integration.
- Edge Cases & Failure Modes: Handling network timeouts during gateway callbacks, concurrent uploads, race conditions in status transitions, and storage malware scanning.
Hints
Hint 1
Model dispute statuses as an explicit, deterministic state machine enforced via database-level optimistic locking or conditional updates.
Hint 2
Decouple file uploads by generating pre-signed S3 URLs with content-type restrictions, routing files through an asynchronous quarantine and virus-scanning pipeline before marking them as valid evidence.
Hint 3
Use transactional outbox or distributed saga patterns with idempotency keys when coordinating external gateway calls and internal ledger fund movements.
Follow-up questions
- How would you ensure that a race condition between an external gateway's automatic webhook decision and an internal reviewer's manual verdict does not cause a double payout?
- How does your design reliably trigger deadline-expiry transitions at scale without running heavy polling queries across the active dispute table?
- How would you isolate and securely serve user-uploaded PDFs/images to dispute arbiters while minimizing cross-site scripting (XSS) or malware risks?
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.