Skip to main content
The Payout module never references other modules directly. 3 module links in packages/core/src/links connect its records to sellers and orders. Read across them with query.graph, and query a link’s own table by its entry name.

Seller and payout account

Defined in seller-payout-account-link.ts between SellerModule.linkable.seller and PayoutModule.linkable.payoutAccount. Neither side is a list, so a seller has one payout account and an account belongs to one seller. validateSellerPayoutAccountStep enforces the one-account rule before a new link is created.

Payout and seller

Defined in payout-seller-link.ts between PayoutModule.linkable.payout, marked isList: true, and SellerModule.linkable.seller. A seller has many payouts, and each payout has one seller. createOrderPayoutsWorkflow creates this link when it creates a payout.
The Vendor API scopes payouts by querying the link table directly, with entity: "payout_seller" and filters on seller_id and payout_id.

Order and payout

Defined in order-payout-link.ts between Medusa’s OrderModule.linkable.order and PayoutModule.linkable.payout, marked isList: true. createOrderPayoutsWorkflow creates it with the payout. The payout also stores order_id in its own unique column, which is what keeps an order from being paid twice; the link is there so you can read across modules with query.graph:
Reversals aren’t linked to anything: they’re children of their payout, and refund_id names the Medusa refund they reverse.