Order clocks and who acts
Everything on this page is generated from the order machine (packages/commerce/orders/order.plan.ts) and the live markets' config (packages/commerce/config/<market>.ts). Change a window or a state there and this page redraws itself. Nothing here is typed by hand.
An order rests in one state between events. In each state it waits on someone: the buyer, the seller, the carrier, the payment provider or staff. A clock ends the wait if nobody acts. A state with no clock waits for good, and so does any money held on it. Those are drawn in red, and each one is a gap the work in progress closes (order.waits.test.ts lists them, and the list only shrinks).
Every clock
Each arrow is a clock: from the state it runs in to where the order lands when it runs out.
No diagram code provided
Every state
What each state waits on, its clock, and the events each side can send while the order rests there. An event not listed for a state is ignored there.
| State | Waits on | Clock | Who can move it |
|---|---|---|---|
active | the seller, to hand the item to the carrier or to the buyer |
| buyer: buyer_cancel seller: courier_dispatched, handoff_confirmed, label_purchased, seller_cancel, seller_extended_ship_deadline, seller_ready, seller_reported_handover staff: admin_cancel, admin_moved_ship_deadline parties: meetup_arranged carrier: courier_in_transit, delivery_confirmed, fulfillment_failed, fulfillment_paused, label_generated, seller_shipped |
awaiting_acceptance | the buyer, to accept the item or report a problem |
| buyer: buyer_accepted |
awaiting_payment_closure | the payment rail, to close the payment |
| payment rail: payment_confirmed, payment_failed |
cancelled | Nothing: the order is over | None | |
completed | Nothing: the order is over | None | |
disputed | the parties, then staff | No clock: it waits until someone acts. | buyer: dispute_withdrawn seller: return_accepted, return_contested staff: dispute_dismissed, dispute_resolved_partial, dispute_resolved_refund, dispute_resolved_seller parties: dispute_opened |
in_transit | the carrier, to report the delivery | No clock: it waits until someone acts. | staff: admin_cancel carrier: delivery_confirmed, fulfillment_failed, fulfillment_paused |
pending_payment | the buyer's payment |
| buyer: buyer_cancel seller: seller_cancel staff: admin_cancel payment rail: payment_confirmed, payment_failed, payment_window_set |
reconciliation_required | staff, to settle what the two stores disagree on | No clock: it waits until someone acts. | staff: admin_resync |
refund_pending_full | the payment provider, to confirm the refund | No clock: it waits until someone acts. | payment rail: refund_completed, refund_failed |
refund_pending_partial | the payment provider, to confirm the refund | No clock: it waits until someone acts. | payment rail: refund_completed, refund_failed |
return_awaiting_post | the buyer, to post the return |
| carrier: return_delivered, return_posted |
return_delivered | the seller, to inspect the return |
| |
return_in_transit | the carrier, to deliver the return | No clock: it waits until someone acts. | carrier: return_delivered |
returning_requested | the buyer, to post the return |
| buyer: return_label_purchased seller: return_requested |