Skip to main content
This page covers how commission is recorded on an order and kept in sync as the order changes.

Commission line

A commission line is the resolved commission for a single order line. It’s represented by the CommissionLine data model (table commission_line, id prefix comline). Each line anchors to either an item (item_id) or a shipping method (shipping_method_id). It records the rate that matched (commission_rate_id, code), the applied rate, and the computed amount.
Lines are generated automatically during checkout. When the cart is split into per-seller orders, refreshOrderCommissionLinesWorkflow runs against each new order. Shipping lines carry a "Shipping Commission" description. Item lines carry none.

Recomputed on change

Commission lines are derived data, not a one-time snapshot. The lines are recomputed whenever an order’s composition changes, such as when an order edit is confirmed, a return is received, or a claim or exchange is created. That keeps the seller’s commission tracking what the customer actually kept. The refresh is idempotent: it deletes any existing lines for the affected items and shipping methods, then inserts the freshly computed set. Re-running it never duplicates lines.
Computed lines carry no id. The module’s upsertCommissionLines deletes by anchor (item_id / shipping_method_id) before inserting, which is what makes repeated refreshes safe.

BigNumber precision

All commission arithmetic uses Medusa’s MathBN (BigNumber). It’s arbitrary precision, so percentages and per-currency amounts never accumulate floating-point error. A percentage amount is subtotal × value ÷ 100. A fixed amount is the per-currency value (or the fallback value). Each is computed in BigNumber before being stored.
Commission lines feed the payout pipeline: when a seller’s payout is calculated, the order’s commission lines are read straight from the commission module and deducted from the amount transferred to the seller.