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.

LegendCompletedCancelled / failedClosed / inactive

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.

StateWaits onClockWho can move it
activethe seller, to hand the item to the carrier or to the buyer

meetup_lapse: 3 days (7 days with no time agreed) after the agreed meetup time, or the payment while none is agreed, then the buyer is refunded unless the handover code was typed, and the item is held for the seller; once the seller says they handed it over without the code the clock stops and staff decide (meetup).

ship_deadline: 7 days after the payment, then the buyer is refunded in full and the item is held for the seller (shipping, same_day).

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_acceptancethe buyer, to accept the item or report a problem

auto_accept: 3 days after the delivery or the handover, then the sale completes and the seller is paid.

buyer: buyer_accepted

awaiting_payment_closurethe payment rail, to close the payment

closure_recheck: 5 mins after the closure's last answer, then the rail is asked again whether the payment closed.

payment rail: payment_confirmed, payment_failed

cancelledNothing: the order is overNone
completedNothing: the order is overNone
disputedthe 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_transitthe carrier, to report the delivery

No clock: it waits until someone acts.

staff: admin_cancel

carrier: delivery_confirmed, fulfillment_failed, fulfillment_paused

pending_paymentthe buyer's payment

payment_expiry: 1 day after the order (a PIX QR names its own), then the rail is asked; still unpaid, the order is cancelled.

buyer: buyer_cancel

seller: seller_cancel

staff: admin_cancel

payment rail: payment_confirmed, payment_failed, payment_window_set

reconciliation_requiredstaff, to settle what the two stores disagree on

No clock: it waits until someone acts.

staff: admin_resync

refund_pending_fullthe payment provider, to confirm the refund

No clock: it waits until someone acts.

payment rail: refund_completed, refund_failed

refund_pending_partialthe payment provider, to confirm the refund

No clock: it waits until someone acts.

payment rail: refund_completed, refund_failed

return_awaiting_postthe buyer, to post the return

return_post: 7 days after the return's request, then the claim closes and the seller is paid.

carrier: return_delivered, return_posted

return_deliveredthe seller, to inspect the return

return_inspection: 3 days after the return's delivery, then the buyer is refunded in full.

return_in_transitthe carrier, to deliver the return

No clock: it waits until someone acts.

carrier: return_delivered

returning_requestedthe buyer, to post the return

return_post: 7 days after the return's request, then the claim closes and the seller is paid.

buyer: return_label_purchased

seller: return_requested

On this page