Skip to main content
Loads a settled order with its seller and payout account, sums the order’s commission lines (item and shipping), and pays out order.total - total commission through the payout provider, linking the payout to the seller. Fails if the seller has no payout account. The order ID doubles as the provider idempotency key, so re-running for the same order is safe. Not wired to a route — run it from your own subscriber or scheduled job once an order is captured and ready to settle.

Usage

import { createPayoutWorkflow } from "@mercurjs/core/workflows"

const { result } = await createPayoutWorkflow(container).run({
  input: { order_id: "order_123" },
})

Input

order_id
string
required
The order to settle; must belong to a seller with a payout account.

Result

result
PayoutDTO
The created payout.
result.id
string
Payout ID.
result.account_id
string
The seller’s payout account.
result.amount
BigNumberInput
Order total minus the order’s commission lines.
result.currency_code
string
The order’s currency.
result.status
string
One of pending, processing, paid, failed, canceled.
result.data
object | null
Provider transfer data; includes order_id and seller_id.