Skip to main content
Commissions are how the marketplace earns revenue. Rather than storing a single commission percentage, Mercur uses a rule-based system where commission rates are matched to order line items based on configurable conditions, with a global default as the fallback.

Commission rates

A CommissionRate defines how much commission the marketplace takes and when it applies.
percentage rates use the scalar value. fixed rates read the per-currency values list and fall back to value when the order’s currency has no entry.

Commission rules

Rules determine when a rate applies. Each rule has a reference (the dimension) and a reference_id (the value to match): A rate with no rules matches everything — that’s what makes the default rate a catch-all.

The matching algorithm

For each line item:
  1. Group the rate’s rules by dimension (reference).
  2. A rate matches when every dimension group has at least one matching rule — AND across dimensions, OR within a dimension. Example: a rate with rules seller: A and product_category: electronics matches only electronics sold by seller A; a rate with two product_category rules matches either category.
  3. Among all matching rates, the most specific wins — the rate scoping on the largest number of distinct dimensions.
  4. Ties break deterministically to the oldest rate.
Example configuration: An electronics item from seller slr_abc gets 8% — the two-dimension rate beats the one-dimension category rate, regardless of creation order.

The calculation pipeline

The getCommissionLines step calculates commissions when an order is placed:
  1. Load all enabled rates with their rules and per-currency values. Rates pinned to a currency_code apply only to orders in that currency.
  2. Match items — for each line item, find matching rates and pick the most specific (see above).
  3. Calculate — the base amount is the item subtotal, plus tax when include_tax is on. Percentage: (base × value) / 100. Fixed: the per-currency amount.
  4. Shipping — governed solely by the global commission: when its include_shipping flag is on, each shipping method gets a commission line calculated from the global rate.
  5. Output — one CommissionLine per commissioned item and shipping method.
All commission calculations use BigNumber arithmetic for precision. This is critical for financial accuracy — standard floating-point math can introduce rounding errors.

API examples

Set up the global commission (Admin API)

Create a scoped rate with rules (Admin API)

Create a fixed rate with per-currency amounts

List commission rates

Commission lines

A CommissionLine is the calculated commission for a single line item or shipping method: Commission lines are linked to order line items via a read-only link, so an order’s items can be queried together with their commission data in a single request.

How commission connects to payouts

Commission lines are the bridge between orders and seller earnings:
  1. An order is completed → commission lines are calculated for each item
  2. When the order is credited to the seller’s payout account, the total commission is subtracted:
  3. The marketplace retains the commission amount
This separation means commission rates can be changed at any time without affecting already-calculated orders — the CommissionLine records serve as a permanent audit trail.

Next steps

Payouts

How seller earnings settle after commission.

Order Groups

The per-seller orders commissions are calculated on.