system provider runs when you register none.
Resolve the module service with
MercurModules.PAYOUT from @mercurjs/types. Import the payout workflows from @mercurjs/core/workflows.Key features
The Payout module covers a seller’s connection to the provider and the money sent through it:- One provider per marketplace: the module loads exactly one
IPayoutProvider, shaped like Medusa’s payment providers - Stripe Connect plugin:
@mercurjs/stripe-connector-plugincreates Express accounts, onboarding and login links, and pays each payout as a Connect transfer - One account per store:
createPayoutAccountWorkflowrefuses a second account for the same seller - Re-runnable onboarding:
createOnboardingWorkflowcreates the onboarding record once and updates it after that - One payout per order:
createOrderPayoutsWorkflowpays the order total minus the order’s commission lines, puts orders that aren’t ready on hold, and never pays an order twice - Reversals like refunds:
createPayoutReversalsWorkflowtakes each later refund’s share back, net of its commission - Webhook-driven statuses: provider webhooks refresh accounts and settle payouts through
processPayoutForWebhookWorkflow
How it works
A seller moves from no account to a paid order in 5 steps:- Run
createPayoutAccountWorkflow(orcreateOrRefreshSellerPayoutAccountWorkflow) for the seller. The provider creates a connected account. - Run
createOnboardingWorkflow. The provider returns onboarding data, such as a Stripe onboarding link. - The provider posts webhooks to
/hooks/payout, and thepayout-webhooksubscriber re-reads the account from the provider and sets it topending,active,restricted, orrejected. - Run
createOrderPayoutsWorkflowwith order ids. It computes each seller’s share and asks the provider to pay it. - Run
createPayoutReversalsWorkflowafter refunds. Provider webhooks update payout statuses along the way.
Get started
Learn how accounts, onboarding, and payouts fit together.Accounts & onboarding
The payout account, its onboarding record, and the provider data they carry.
Account lifecycle
Account and payout statuses, and the webhooks that change them.
The payout pipeline
What core ships, what the plugin or your code schedules, and the provider interface.
Examples
Build against payouts in your own server code.Create a payout account
Run
createPayoutAccountWorkflow for a seller.Start onboarding
Create a provider onboarding link with
createOnboardingWorkflow.Process a webhook
Turn a provider webhook into account and payout status changes.
Resources
The data models, links, workflows, service methods, and events behind payouts.Data models
PayoutAccount, Onboarding, Payout, and PayoutReversal, with every field.Links
How payout records link to sellers and orders.
Workflows
The payout workflows, their steps, and their hooks.
Service
Generated and provider-backed methods on the module service.
Events
The webhook event, the failure events, and the data-model events.