← Technical notes
Confidential / NDA4 diagrams

Order lifecycle and refunds

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

TL;DR

NDA note: one checkout, one child order per seller, and idempotent refunds on a checkout those orders share.

live trace · Return received and refundfrom the original diagram
Seller API Child order Return case Stock Checkout 01mark return received 02lock row 03state = received 04cancelled, seller income held 05restore on hand, once per order 06refund, partial if sibling orders are still confirmed
  1. 01
    Seller → APImark return received
  2. 02
    API → Child orderlock row
  3. 03
    API → Return casestate = received
  4. 04
    API → Child ordercancelled, seller income held
  5. 05
    API → Stockrestore on hand, once per order
  6. 06
    API → Checkoutrefund, partial if sibling orders are still confirmed
01

Background

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

02

How it works

  1. Each seller gets a child order with its own items, address, fulfilment record, seller income record and status history.
  2. Confirmed 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.
03

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 checkout: the checkout is marked partially refunded while any other order in the same checkout is still confirmed.
  • 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.
All diagrams

Other views

Tap a table to see what it links to.

CHECKOUT_SESSION
CHILD_ORDER
PROVIDER_RECORD
ORDER_LINE
SHIP_TO
FULFILMENT
SELLER_INCOME
STATUS_EVENT
RETURN_CASE
  • CHECKOUT_SESSION groups CHILD_ORDER 1 → many
  • CHECKOUT_SESSION billed by PROVIDER_RECORD 1 → many
  • CHILD_ORDER has ORDER_LINE 1 → 1+
  • CHILD_ORDER has SHIP_TO 1 → 0..1
  • CHILD_ORDER has FULFILMENT 1 → 0..1
  • CHILD_ORDER has SELLER_INCOME 1 → 0..1
  • CHILD_ORDER has STATUS_EVENT 1 → many
  • CHILD_ORDER has RETURN_CASE 1 → many

← Technical notes on the home page