Ostorya dev docs

Commerce

The COD order lifecycle

How a cash-on-delivery order moves from placed to paid, and which mutations move it.

Most Ostorya orders are paid in cash when the parcel arrives. Between the order and the cash there is a phone call, a delivery company and a remittance. Each step is a mutation, and stock moves with it.

  1. 1

    Placed

    orderCreate (or the storefront checkout) finds or creates the customer by phone, runs risk checks (blocked number, refused before, same phone within 24 h, many orders from one IP) and moves stock to reserved.

  2. 2

    Confirmation call

    An agent calls the customer and logs it with orderConfirmationCallLog: CONFIRMEDmoves stock from reserved to committed; CANCELLED cancels and puts stock back; CALL_BACK needs a time in the future. During the call the agent can upsell with orderEditBegin → add/set quantity/discount → orderEditCommit.

  3. 3

    Shipped

    fulfillmentCreate (confirmed orders only) hands the parcel to a delivery company and takes committed stock out. Tracking events follow with fulfillmentEventCreate: SHIPPED … DELIVERED, REFUSED, RETURNED or LOST.

  4. 4

    Delivered or refused

    DELIVERED adds to the customer's delivered count. REFUSED/RETURNED add to their refused count (risk for next time); RETURNED units go to quality_control stock until checked.

  5. 5

    Cash collected

    The delivery company pays back the cash it collected. codRemittanceImport matches its statement by tracking number or order number and flags problems (not found, wrong amount, not delivered…); codRemittanceReconcile records the payments and marks the orders paid. orderMarkAsPaid does it for one order.

Stock states

Inventory quantities are kept per state: available, reserved, committed, damaged, safety_stock, quality_control, incoming. on_hand is computed. Every change is recorded and can't be edited afterwards.

For a WhatsApp app#

Confirming orders on WhatsApp instead of a call fits this flow: read open orders, message the customer, then log the result with orderConfirmationCallLog like an agent would. The customer's WhatsApp number and marketing consent are on Customer.