← Technical notes

Confidential / NDA

Order lifecycle and refunds

One checkout can contain orders from several sellers. Each seller order moves on its own, but they share one payment.

Background

One checkout can contain orders from several sellers. Each seller order moves on its own (ship, deliver, cancel, return), but they share one payment.

How it works

  1. Each seller gets a child order with its own items, address, fulfilment record, settlement record and status history.
  2. Paid flow: seller confirms, ships with tracking, marks delivered; the buyer confirms receipt or the order auto-completes after a window.
  3. Seller income is credited to the seller's balance only after a buffer period following completion.
  4. Cancellations: buyer request with seller approval, overdue cancellation by a scheduled job, or admin force-cancel.
  5. Returns: buyer requests, seller approves or rejects, buyer can escalate to admin; when goods come back, stock and any store credit are restored and the refund is issued.
  6. Store-credit refunds complete immediately; cash refunds stay pending until an admin confirms the transfer.

Design decisions

  • Every refund and restore step is idempotent, guarded by a status or timestamp check, so retries are safe.
  • Partial vs full refund on a shared payment: the payment is marked partially refunded while any other order in the same checkout is still paid.
  • Seller income on a timer, not at delivery, to leave room for returns; credited once, guarded by a timestamp, with lock ordering and deadlock retry.
  • Scheduled jobs never overlap.
Loading diagrams…