Returns and Refund Management System

Reverse logistics and exactly-once refunds

Design a returns system that checks eligibility, issues labels, tracks the parcel back, grades the item, decides where it goes next and refunds the customer the right amount exactly once.

Overview

A returns system runs an order backwards. The customer asks to send something back, the system checks the policy, issues a label, tracks the parcel to a returns center, where someone inspects it, and then decides two things: what happens to the item (back on the shelf, sold as open-box, sent to liquidation, recycled) and how much money goes back, to which payment method.

Returns are a large part of retail. The US National Retail Federation (NRF) estimated that retailers expected 16.9% of their 2024 sales to be returned, about $890 billion, and 93% of the retailers it surveyed said fraud and other exploitive behavior was a significant issue for their business. So the system must be cheap to run at volume, pleasant for honest customers, and hard to abuse.

The interview usually centers on the money. A refund is a payment in reverse: it has to be correct to the cent, happen exactly once, and survive retries and failures in systems you do not control.

Questions to ask first

  • How many returns? — About 15% of 1 million orders a day: 150,000 returns a day, peaks after the holidays
  • Where do refunds go? — The original payment method by default; store credit or an exchange if the customer picks it
  • When is the customer refunded? — After inspection by default; at the carrier drop-off for low-risk returns
  • Partial returns and partial refunds? — Yes: any subset of lines, and deductions for damage where the policy allows
  • Marketplace sellers? — Out of scope; first-party stock only
  • Who is the payment provider? — A card processor with a refunds API and webhooks (examples use Stripe's documented behavior)

What you will be able to do

  • Walk a return through its states from request to refund, and say who moves it at each step.
  • Compute a line's refund amount to the cent, with discounts and tax spread correctly.
  • Record a refund so that retries, duplicate webhooks and concurrent approvals can never pay twice or pay more than was charged.
  • Choose when to refund (drop-off or inspection) by risk, and explain the trade.
  • Decide where a returned item goes, and handle a refund that fails after it succeeded.

Key concepts

  • Return merchandise authorization (RMA)
  • Policy snapshot per order
  • Refundable balance
  • Idempotency keys
  • Refund state machine
  • Pro-rated discounts and tax
  • Risk tiers
  • Grading and disposition
  • Outbox and webhooks

Functional requirements

  • Check which lines of an order can be returned, under the policy that applied when it was bought
  • Create a return (RMA) and issue a label or drop-off code
  • Track the parcel from carrier scans; handle returns that arrive in several parcels
  • Record inspection: grade, photos, notes; decide the item's next channel
  • Refund to the original payment method, or issue store credit or an exchange
  • Score risk and apply a policy tier (refund at drop-off, after inspection, or after review)
  • Show the customer the status of the return and the refund

Non-functional requirements

  • A refund is paid at most once and never exceeds the amount captured (strict correctness)
  • Every refund is traceable from the return, through the provider, to the ledger
  • Eligibility answers in under 300 ms at p99 (a target we chose)
  • Refunds are issued within one business day of the trigger event (a target we chose)
  • Provider outages delay refunds; they never lose or duplicate them

Interview questions

  • How do you make sure a refund is never paid twice?
  • Two partial returns on the same order are approved at the same moment. What stops them from refunding more than the charge?
  • Why not call the payment provider inside the database transaction?
  • How do you compute the refund for one line of a discounted order?
  • When should a customer get their money back?
  • What happens when a refund fails after it succeeded?
  • How do you detect return abuse without hurting good customers?
  • How does a returned item get back into stock?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio