Workflows
acceptMemberInvitesWorkflow
This documentation provides a reference to theacceptMemberInvitesWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow accepts a member invitation by validating the invite token, creating a new member, updating the invite status, and linking the new member to the authentication system.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/invites/accept/route.ts
Steps
- validateMemberInviteStep: Validates the invite token and retrieves the invite details.
- createMemberStep: Creates the new member.
- updateMemberInviteStep: Marks the invite as accepted.
- setAuthAppMetadataStep: Links the member to the authentication identity.
Input
The invite acceptance details.
Output
The accepted member invite.
createOnboardingForSellerWorkflow
This documentation provides a reference to thecreateOnboardingForSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a payout onboarding flow for a seller. It validates that the seller has a payout account and then initializes the onboarding process with the payment provider.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/payout-account/onboarding/route.ts
Steps
- validatePayoutAccountExistsForSellerStep: Validates that the seller has a payout account.
- createPayoutOnboardingStep: Creates the onboarding flow with the payment provider.
Input
The onboarding creation details.
Output
The created onboarding.
createPayoutAccountForSellerWorkflow
This documentation provides a reference to thecreatePayoutAccountForSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a payout account for a seller and links it to the seller. It validates that no payout account already exists for the seller and then creates the account with the payment provider. This workflow is idempotent.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/payout-account/route.ts
Steps
- validateNoExistingPayoutAccountForSellerStep: Validates that no payout account exists for the seller.
- createPayoutAccountStep: Creates the payout account with the payment provider.
- createRemoteLinkStep: Links the payout account to the seller.
Input
The payout account creation details.
Output
The created payout account.
createSellerWorkflow
This documentation provides a reference to thecreateSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a new seller in the marketplace, including creating the initial member, setting up seller onboarding, linking to authentication, and creating a default shipping profile. It exposes a sellerCreated hook for custom extensions.
Source code
Steps
- createSellerStep: Creates the seller record.
- createMemberStep: Creates the initial member for the seller.
- createSellerOnboardingStep: Creates the onboarding record.
- setAuthAppMetadataStep: Links the member to the authentication identity.
- createSellerShippingProfileStep: Creates a default shipping profile for the seller.
Hooks
- sellerCreated: Hook that fires after a seller is created, providing the
sellerId.
Input
The seller creation details.
Output
The created seller.
createVendorPromotionWorkflow
This documentation provides a reference to thecreateVendorPromotionWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a promotion for a seller. It validates that the campaign belongs to the seller, that the target type is items only, and that all targeted products belong to the seller.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/promotions/route.ts
Steps
- verifyVendorCampaignStep: Validates campaign ownership.
- verifyVendorPromotionStep: Validates the promotion target type.
- verifyVendorTargetPromotionRulesStep: Validates product ownership in target rules.
- createPromotionsWorkflow: Creates the promotion using Medusa’s core workflow.
- createRemoteLinkStep: Links the promotion and campaign to the seller.
Input
The promotion creation details.
Output
Array containing the created promotion.
deleteMemberInvitesWorkflow
This documentation provides a reference to thedeleteMemberInvitesWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow deletes a member invitation.
Source code
Steps
- deleteMemberInvitesStep: Deletes the member invite.
Input
The ID of the member invite to delete.
Output
This workflow does not return a value.deleteMemberWorkflow
This documentation provides a reference to thedeleteMemberWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow deletes a member from a seller’s team.
Source code
Steps
- deleteMemberStep: Deletes the member.
Input
The ID of the member to delete.
Output
This workflow does not return a value.deleteSellerWorkflow
This documentation provides a reference to thedeleteSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow deletes a seller from the marketplace.
Source code
Steps
- deleteSellerStep: Deletes the seller.
Input
The ID of the seller to delete.
Output
This workflow does not return a value.exportSellerProductsWorkflow
This documentation provides a reference to theexportSellerProductsWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow exports all products for a seller to a CSV file. It retrieves the seller’s products and generates a downloadable CSV file containing product details, variants, and pricing information.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/products/export/route.ts
Steps
- getSellerProductsStep: Retrieves all products for the seller.
- generateProductCsvStep: Generates a CSV file from the product data using Medusa’s core step.
- useRemoteQueryStep: Retrieves the file details including the download URL.
Input
The ID of the seller whose products to export.
Output
The generated CSV file details.
importSellerProductsWorkflow
This documentation provides a reference to theimportSellerProductsWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow imports products from a CSV file for a seller. It parses the CSV, validates the products, creates them with “proposed” status, and emits an event to create product requests for admin approval.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/products/import/route.ts
Steps
- parseProductCsvStep: Parses the CSV file into product objects using Medusa’s core step.
- validateProductsToImportStep: Validates and transforms products, setting status to “proposed”.
- createProductsWorkflow: Creates the products using Medusa’s core workflow.
- emitEventStep: Emits an event to trigger product request creation.
Input
The product import details.
Output
Array of created products (in proposed status).
inviteMemberWorkflow
This documentation provides a reference to theinviteMemberWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a member invitation for a seller’s team.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/invites/route.ts
Steps
- createMemberInviteStep: Creates the member invitation.
Input
The invitation details.
Output
The created member invitation.
inviteSellerWorkflow
This documentation provides a reference to theinviteSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow sends an invitation email to a potential seller to join the marketplace platform.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/admin/sellers/invite/route.ts
Steps
- sendSellerInvitationEmailStep: Sends the invitation email.
Input
The invitation details.
Output
The notification details for the sent invitation email.
recalculateOnboardingWorkflow
This documentation provides a reference to therecalculateOnboardingWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow recalculates a seller’s onboarding status by checking various completion criteria including store information, products added, shipping locations configured, and Stripe connection established.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/sellers/me/onboarding/route.ts
Steps
- recalculateOnboardingStep: Recalculates and updates the onboarding status.
Input
The ID of the seller to recalculate onboarding for.
Output
The updated onboarding status.
syncStripeAccountWorkflow
This documentation provides a reference to thesyncStripeAccountWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow synchronizes the status of a payout account with the payment provider (Stripe Connect). It retrieves the latest account status from the provider and updates the local record.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/payout-account/route.ts
Steps
- syncStripeAccountStep: Synchronizes the account status with Stripe.
Input
The ID of the payout account to synchronize.
Output
The synchronized payout account.
updateMemberWorkflow
This documentation provides a reference to theupdateMemberWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow updates a member’s details.
Source code
Steps
- updateMemberStep: Updates the member.
Input
The member update details.
Output
The updated member.
updateSellerWorkflow
This documentation provides a reference to theupdateSellerWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow updates a seller’s details.
Source code
Examples
- API Route
packages/modules/b2c-core/src/api/vendor/sellers/me/route.ts
Steps
- updateSellerStep: Updates the seller.
Input
The seller update details.
Output
The updated seller.
Steps
createMemberInviteStep
Creates a member invitation record. If an error occurs after creation, the step’s compensation function automatically deletes the created invite. Source codeInput
The invitation details.
Output
The created member invitation.
createMemberStep
Creates a member for a seller. If an error occurs after creation, the step’s compensation function automatically deletes the created member. Source codeInput
The member details.
Output
The created member.
createPayoutAccountStep
Creates a payout account with the payment provider. If an error occurs after creation, the step’s compensation function automatically deletes the created account. Source codeInput
The payout account details.
Output
The created payout account.
createPayoutOnboardingStep
Initializes an onboarding flow for a payout account with the payment provider (e.g., creates a Stripe Connect onboarding link). Source codeInput
The onboarding initialization details.
Output
The created onboarding with provider-specific data (e.g., onboarding URL).
createSellerOnboardingStep
Creates an onboarding record for a newly created seller to track their setup progress. Source codeInput
The seller for which to create onboarding.
Output
The created onboarding record.
createSellerShippingProfileStep
Creates a default shipping profile for a seller and links it to the seller. This enables the seller to configure shipping options. Source codeInput
The seller for which to create the shipping profile.
Output
This step does not return a value.createSellerStep
Creates a seller record. It automatically generates a URL-friendly handle from the seller name. If an error occurs after creation, the step’s compensation function automatically deletes the created seller. Source codeInput
The seller details.
Output
The created seller with auto-generated handle.
deleteMemberInvitesStep
Deletes a member invitation. Source codeInput
The ID of the invitation to delete.
Output
This step does not return a value.deleteMemberStep
Deletes a member from a seller’s team. Source codeInput
The ID of the member to delete.
Output
This step does not return a value.deleteSellerStep
Deletes a seller from the marketplace. Source codeInput
The ID of the seller to delete.
Output
This step does not return a value.getSellerProductsStep
Retrieves all products for a seller with comprehensive fields including variants, prices, options, tags, and images. Used for product export functionality. Source codeInput
The ID of the seller whose products to retrieve.
Output
Array of products with full details including variants, prices, options, tags, and images.
recalculateOnboardingStep
Recalculates a seller’s onboarding status by checking multiple completion criteria:- Store information completeness (name, address, tax ID, etc.)
- Products added
- Shipping locations configured
- Stripe connection established
Input
The ID of the seller to recalculate onboarding for.
Output
The updated onboarding status with boolean flags for each completion criterion.
sendSellerInvitationEmailStep
Sends an invitation email to a potential seller with a registration link. Throws an error if the notification provider fails. Source codeInput
The invitation details.
Output
The sent notification details.
syncStripeAccountStep
Synchronizes a payout account’s status with the payment provider by fetching the latest account details from Stripe Connect. Source codeInput
The ID of the payout account to synchronize.
Output
The synchronized payout account.
updateMemberInviteStep
Updates a member invitation, typically to mark it as accepted. Source codeInput
Output
The updated member invitation.
updateMemberStep
Updates a member’s details. Source codeInput
The member update details.
Output
The updated member.
updateSellerStep
Updates a seller’s details. Source codeInput
The seller update details.
Output
The updated seller.
validateMemberInviteStep
Validates a member invitation token and retrieves the associated invite details. Source codeInput
The invite acceptance data including the token.
Output
The validated member invite with seller details.
validateNoExistingPayoutAccountForSellerStep
Validates that a seller does not already have a payout account. Throws an error if a payout account exists. Source codeInput
The ID of the seller to check.
Output
Throws a
DUPLICATE_ERROR if a payout account already exists.validatePayoutAccountExistsForSellerStep
Validates that a seller has a payout account. Throws an error if no payout account exists and returns the payout account ID if found. Source codeInput
The ID of the seller to check.
Output
validateProductsToImportStep
Validates products from a CSV import, parses them according to the product schema, and sets their status to “proposed” for admin approval. Source codeInput
Array of product objects parsed from CSV.
Output
Array of validated product creation DTOs with status set to “proposed”.
verifyVendorCampaignStep
Validates that a campaign belongs to the seller. If no campaign is specified, the validation is skipped. Source codeInput
Output
Throws an
INVALID_DATA error if the campaign doesn’t belong to the seller.verifyVendorPromotionStep
Validates that a vendor promotion uses the correct target type. Vendor promotions must target items only. Source codeInput
Output
Throws an
INVALID_DATA error if target_type is not “items”.verifyVendorTargetPromotionRulesStep
Validates that target promotion rules only use the allowed attribute (items.product.id) and that all targeted products belong to the seller.
Source code
Input
Output
Throws an
INVALID_DATA error if:- Rules use attributes other than “items.product.id”
- Any targeted product doesn’t belong to the seller