@mercurjs/docs 2.2.1 → 2.3.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/home.mdx +107 -0
- package/content/learn/architecture.mdx +168 -83
- package/content/learn/introduction.mdx +161 -56
- package/content/learn/migration-to-2-0.mdx +187 -0
- package/content/learn/why-mercur.mdx +91 -0
- package/content/platform/attribute/concepts/attribute-types.mdx +59 -0
- package/content/platform/attribute/concepts/global-vs-inline.mdx +50 -0
- package/content/platform/attribute/concepts/variant-axes.mdx +61 -0
- package/content/platform/attribute/guides/attach-attributes-to-a-product.mdx +69 -0
- package/content/platform/attribute/guides/create-a-variant-axis.mdx +83 -0
- package/content/platform/attribute/guides/create-an-attribute.mdx +81 -0
- package/content/platform/attribute/overview.mdx +87 -0
- package/content/platform/attribute/reference/data-models.mdx +56 -0
- package/content/platform/attribute/reference/events.mdx +41 -0
- package/content/platform/attribute/reference/links.mdx +45 -0
- package/content/platform/attribute/reference/service.mdx +49 -0
- package/content/platform/attribute/reference/workflows.mdx +45 -0
- package/content/platform/catalog/concepts/master-products.mdx +54 -0
- package/content/platform/catalog/concepts/product-seller-allowlist.mdx +48 -0
- package/content/platform/catalog/concepts/status-lifecycle.mdx +58 -0
- package/content/platform/catalog/concepts/variants-categories-collections.mdx +49 -0
- package/content/platform/catalog/guides/allowlist-stores.mdx +59 -0
- package/content/platform/catalog/guides/create-a-master-product.mdx +70 -0
- package/content/platform/catalog/guides/publish-or-reject-a-product.mdx +79 -0
- package/content/platform/catalog/overview.mdx +90 -0
- package/content/platform/catalog/reference/data-models.mdx +66 -0
- package/content/platform/catalog/reference/events.mdx +41 -0
- package/content/platform/catalog/reference/links.mdx +44 -0
- package/content/platform/catalog/reference/service.mdx +52 -0
- package/content/platform/catalog/reference/workflows.mdx +40 -0
- package/content/platform/commission/concepts/order-commission-lines.mdx +65 -0
- package/content/platform/commission/concepts/rule-matching.mdx +86 -0
- package/content/platform/commission/concepts/rules-and-rates.mdx +84 -0
- package/content/platform/commission/guides/batch-update-rules.mdx +58 -0
- package/content/platform/commission/guides/create-a-rate.mdx +72 -0
- package/content/platform/commission/guides/refresh-order-commission-lines.mdx +55 -0
- package/content/platform/commission/overview.mdx +86 -0
- package/content/platform/commission/reference/data-models.mdx +75 -0
- package/content/platform/commission/reference/events.mdx +58 -0
- package/content/platform/commission/reference/links.mdx +45 -0
- package/content/platform/commission/reference/service.mdx +51 -0
- package/content/platform/commission/reference/workflows.mdx +40 -0
- package/content/platform/offer/concepts/pricing-and-inventory.mdx +72 -0
- package/content/platform/offer/concepts/shipping.mdx +48 -0
- package/content/platform/offer/concepts/what-is-an-offer.mdx +65 -0
- package/content/platform/offer/guides/bulk-create-offers.mdx +84 -0
- package/content/platform/offer/guides/create-an-offer.mdx +83 -0
- package/content/platform/offer/guides/manage-offer-inventory.mdx +53 -0
- package/content/platform/offer/overview.mdx +84 -0
- package/content/platform/offer/reference/data-models.mdx +56 -0
- package/content/platform/offer/reference/events.mdx +39 -0
- package/content/platform/offer/reference/links.mdx +60 -0
- package/content/platform/offer/reference/service.mdx +53 -0
- package/content/platform/offer/reference/workflows.mdx +38 -0
- package/content/platform/order-group/concepts/computed-totals.mdx +59 -0
- package/content/platform/order-group/concepts/order-splitting.mdx +61 -0
- package/content/platform/order-group/concepts/the-order-group.mdx +64 -0
- package/content/platform/order-group/guides/list-order-groups.mdx +67 -0
- package/content/platform/order-group/guides/retrieve-an-order-group.mdx +63 -0
- package/content/platform/order-group/guides/split-a-cart.mdx +58 -0
- package/content/platform/order-group/overview.mdx +83 -0
- package/content/platform/order-group/reference/data-models.mdx +40 -0
- package/content/platform/order-group/reference/events.mdx +37 -0
- package/content/platform/order-group/reference/links.mdx +45 -0
- package/content/platform/order-group/reference/service.mdx +50 -0
- package/content/platform/order-group/reference/workflows.mdx +39 -0
- package/content/platform/payout/concepts/account-lifecycle.mdx +75 -0
- package/content/platform/payout/concepts/accounts-and-onboarding.mdx +70 -0
- package/content/platform/payout/concepts/payout-pipeline.mdx +99 -0
- package/content/platform/payout/guides/create-a-payout-account.mdx +59 -0
- package/content/platform/payout/guides/process-a-provider-webhook.mdx +74 -0
- package/content/platform/payout/guides/start-provider-onboarding.mdx +50 -0
- package/content/platform/payout/overview.mdx +86 -0
- package/content/platform/payout/reference/data-models.mdx +61 -0
- package/content/platform/payout/reference/events.mdx +48 -0
- package/content/platform/payout/reference/links.mdx +36 -0
- package/content/platform/payout/reference/service.mdx +53 -0
- package/content/platform/payout/reference/workflows.mdx +32 -0
- package/content/platform/product-edit/concepts/change-actions.mdx +66 -0
- package/content/platform/product-edit/concepts/change-pipeline.mdx +69 -0
- package/content/platform/product-edit/concepts/status-and-auto-confirm.mdx +66 -0
- package/content/platform/product-edit/guides/confirm-or-decline-a-change.mdx +76 -0
- package/content/platform/product-edit/guides/edit-a-product.mdx +74 -0
- package/content/platform/product-edit/guides/request-a-revision.mdx +54 -0
- package/content/platform/product-edit/overview.mdx +85 -0
- package/content/platform/product-edit/reference/data-models.mdx +65 -0
- package/content/platform/product-edit/reference/events.mdx +47 -0
- package/content/platform/product-edit/reference/links.mdx +39 -0
- package/content/platform/product-edit/reference/service.mdx +43 -0
- package/content/platform/product-edit/reference/workflows.mdx +49 -0
- package/content/platform/review/concepts/product-vs-seller-reviews.mdx +63 -0
- package/content/platform/review/concepts/ratings-and-moderation.mdx +64 -0
- package/content/platform/review/concepts/the-review-model.mdx +56 -0
- package/content/platform/review/guides/compute-aggregate-ratings.mdx +57 -0
- package/content/platform/review/guides/create-a-review.mdx +55 -0
- package/content/platform/review/guides/moderate-a-review.mdx +58 -0
- package/content/platform/review/guides/respond-to-a-review.mdx +61 -0
- package/content/platform/review/overview.mdx +87 -0
- package/content/platform/review/reference/data-models.mdx +36 -0
- package/content/platform/review/reference/events.mdx +61 -0
- package/content/platform/review/reference/links.mdx +43 -0
- package/content/platform/review/reference/service.mdx +54 -0
- package/content/platform/review/reference/workflows.mdx +31 -0
- package/content/platform/store/concepts/lifecycle.mdx +62 -0
- package/content/platform/store/concepts/store-entity.mdx +53 -0
- package/content/platform/store/concepts/team.mdx +50 -0
- package/content/platform/store/guides/create-a-store.mdx +55 -0
- package/content/platform/store/guides/manage-the-team.mdx +55 -0
- package/content/platform/store/guides/moderate-a-store.mdx +59 -0
- package/content/platform/store/overview.mdx +86 -0
- package/content/platform/store/reference/data-models.mdx +89 -0
- package/content/platform/store/reference/events.mdx +43 -0
- package/content/platform/store/reference/links.mdx +71 -0
- package/content/platform/store/reference/service.mdx +51 -0
- package/content/platform/store/reference/workflows.mdx +35 -0
- package/content/references/api/admin/commission-rates/create-commission-rate.mdx +1 -1
- package/content/references/api/admin/commission-rates/list-commission-rates.mdx +2 -2
- package/content/references/api/admin/commission-rates/update-commission-rate.mdx +1 -1
- package/content/references/api/admin/offers/batch-create-offers.mdx +3 -3
- package/content/references/api/admin/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/admin/product-attributes/create-attribute-value.mdx +2 -2
- package/content/references/api/admin/product-attributes/create-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-attributes/update-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-changes/confirm-product-change.mdx +1 -1
- package/content/references/api/admin/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/admin/products/create-product.mdx +1 -1
- package/content/references/api/admin/products/preview-product.mdx +1 -1
- package/content/references/api/admin.mdx +4 -5
- package/content/references/api/conventions.mdx +9 -7
- package/content/references/api/store/carts/add-line-item.mdx +1 -1
- package/content/references/api/store/offers/list-offers.mdx +1 -1
- package/content/references/api/store/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/store.mdx +4 -13
- package/content/references/api/vendor/members/accept-member-invite.mdx +1 -1
- package/content/references/api/vendor/offers/batch-create-offers.mdx +4 -0
- package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +2 -0
- package/content/references/api/vendor/offers/create-offer.mdx +13 -1
- package/content/references/api/vendor/offers/list-offers.mdx +4 -0
- package/content/references/api/vendor/offers/retrieve-offer.mdx +4 -0
- package/content/references/api/vendor/offers/update-offer.mdx +12 -0
- package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +1 -1
- package/content/references/api/vendor/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/vendor/products/create-product-variant.mdx +1 -1
- package/content/references/api/vendor/products/create-product.mdx +1 -1
- package/content/references/api/vendor/products/delete-product.mdx +1 -1
- package/content/references/api/vendor/products/update-product.mdx +1 -1
- package/content/references/api/vendor/sellers/create-seller.mdx +2 -2
- package/content/references/api/vendor/sellers/list-sellers.mdx +1 -1
- package/content/references/api/vendor.mdx +6 -5
- package/content/references/configuration.mdx +16 -33
- package/content/references/overview.mdx +34 -52
- package/content/references/panel-extensions/create-page.mdx +194 -0
- package/content/references/panel-extensions/custom-fields.mdx +256 -0
- package/content/references/panel-extensions/overview.mdx +102 -0
- package/content/references/panel-extensions/widgets.mdx +212 -0
- package/content/resources/ai/mcp.mdx +2 -2
- package/content/resources/ai/overview.mdx +21 -16
- package/content/resources/ai/skills.mdx +67 -0
- package/content/resources/best-practices/api-routes.mdx +55 -43
- package/content/resources/best-practices/custom-fields.mdx +116 -92
- package/content/resources/best-practices/frontend.mdx +62 -50
- package/content/resources/best-practices/module-links.mdx +48 -34
- package/content/resources/best-practices/modules.mdx +53 -27
- package/content/resources/best-practices/overview.mdx +45 -17
- package/content/resources/best-practices/subscribers-and-jobs.mdx +37 -24
- package/content/resources/best-practices/types.mdx +38 -23
- package/content/resources/best-practices/workflows.mdx +33 -21
- package/content/resources/customization/custom-fields.mdx +15 -15
- package/content/resources/customization/extend-a-workflow.mdx +7 -4
- package/content/resources/customization/extending-panels.mdx +55 -52
- package/content/resources/deployment/medusa-cloud.mdx +21 -20
- package/content/resources/deployment/self-host.mdx +123 -0
- package/content/resources/integrations/overview.mdx +38 -0
- package/content/resources/integrations/stripe-connect.mdx +39 -38
- package/content/resources/tutorials/add-a-block.mdx +25 -18
- package/content/resources/tutorials/add-a-widget.mdx +32 -23
- package/content/resources/tutorials/add-order-detail-button.mdx +33 -20
- package/content/resources/tutorials/attributes-and-variant-axes.mdx +28 -27
- package/content/resources/tutorials/build-a-block.mdx +26 -15
- package/content/resources/tutorials/custom-api-route.mdx +32 -20
- package/content/resources/tutorials/custom-panel-page.mdx +21 -12
- package/content/resources/tutorials/customize-navigation.mdx +30 -23
- package/content/resources/tutorials/extend-forms-and-tables.mdx +36 -28
- package/content/resources/tutorials/extend-onboarding.mdx +38 -35
- package/content/resources/tutorials/master-products-and-offers.mdx +28 -23
- package/content/telemetry.mdx +3 -3
- package/content/user-guide/admin/attributes/how-tos/create-an-attribute.mdx +64 -0
- package/content/user-guide/admin/attributes/how-tos/manage-possible-values.mdx +40 -0
- package/content/user-guide/admin/attributes/overview.mdx +22 -0
- package/content/user-guide/admin/commissions/how-tos/create-a-commission-rule.mdx +63 -0
- package/content/user-guide/admin/commissions/how-tos/edit-the-global-commission.mdx +48 -0
- package/content/user-guide/admin/commissions/how-tos/manage-a-commission-rule.mdx +45 -0
- package/content/user-guide/admin/commissions/overview.mdx +25 -0
- package/content/user-guide/admin/overview.mdx +20 -12
- package/content/user-guide/admin/product-requests/how-tos/review-a-new-product.mdx +58 -0
- package/content/user-guide/admin/product-requests/how-tos/review-a-product-edit.mdx +48 -0
- package/content/user-guide/admin/product-requests/overview.mdx +25 -0
- package/content/user-guide/vendor/offers/how-tos/create-an-offer.mdx +59 -0
- package/content/user-guide/vendor/offers/how-tos/update-prices-and-stock.mdx +40 -0
- package/content/user-guide/vendor/offers/overview.mdx +22 -0
- package/content/user-guide/vendor/onboarding.mdx +79 -0
- package/content/user-guide/vendor/orders/how-tos/fulfill-an-order.mdx +49 -0
- package/content/user-guide/vendor/orders/how-tos/mark-an-order-as-delivered.mdx +33 -0
- package/content/user-guide/vendor/orders/how-tos/process-a-return.mdx +42 -0
- package/content/user-guide/vendor/orders/how-tos/refund-an-order.mdx +38 -0
- package/content/user-guide/vendor/orders/how-tos/ship-an-order.mdx +40 -0
- package/content/user-guide/vendor/orders/overview.mdx +31 -0
- package/content/user-guide/vendor/overview.mdx +23 -12
- package/content/user-guide/vendor/products/how-tos/edit-a-product.mdx +44 -0
- package/content/user-guide/vendor/products/how-tos/submit-a-product.mdx +63 -0
- package/content/user-guide/vendor/products/overview.mdx +22 -0
- package/llms.txt +176 -142
- package/package.json +1 -1
- package/content/learn/concepts.mdx +0 -84
- package/content/learn/installation.mdx +0 -117
- package/content/learn/mirakl-alternative.mdx +0 -86
- package/content/migration/from-1-x-to-2-0.mdx +0 -152
- package/content/migration/from-2-0-to-2-1.mdx +0 -105
- package/content/migration/overview.mdx +0 -58
- package/content/references/api/store/search/search.mdx +0 -136
- package/content/references/modules/commission.mdx +0 -106
- package/content/references/modules/custom-fields.mdx +0 -45
- package/content/references/modules/media.mdx +0 -55
- package/content/references/modules/offer.mdx +0 -64
- package/content/references/modules/payout.mdx +0 -121
- package/content/references/modules/product-attribute.mdx +0 -111
- package/content/references/modules/product-edit.mdx +0 -80
- package/content/references/modules/search.mdx +0 -112
- package/content/references/modules/seller.mdx +0 -175
- package/content/references/panel-extension-api.mdx +0 -337
- package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +0 -48
- package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +0 -36
- package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +0 -39
- package/content/references/workflows/cart/update-cart-seller-promotions.mdx +0 -42
- package/content/references/workflows/commission/batch-commission-rules.mdx +0 -49
- package/content/references/workflows/commission/create-commission-rates.mdx +0 -41
- package/content/references/workflows/commission/delete-commission-rates.mdx +0 -34
- package/content/references/workflows/commission/refresh-order-commission-lines.mdx +0 -30
- package/content/references/workflows/commission/update-commission-rates.mdx +0 -35
- package/content/references/workflows/media/set-category-images.mdx +0 -41
- package/content/references/workflows/media/set-collection-images.mdx +0 -41
- package/content/references/workflows/member/accept-member-invite.mdx +0 -33
- package/content/references/workflows/member/add-seller-member.mdx +0 -30
- package/content/references/workflows/member/create-member-invites.mdx +0 -34
- package/content/references/workflows/member/delete-member-invite.mdx +0 -24
- package/content/references/workflows/member/remove-seller-member.mdx +0 -28
- package/content/references/workflows/member/resend-member-invite.mdx +0 -28
- package/content/references/workflows/member/update-member-role.mdx +0 -28
- package/content/references/workflows/member/update-member.mdx +0 -35
- package/content/references/workflows/offer/batch-offer-inventory-items.mdx +0 -62
- package/content/references/workflows/offer/create-offers.mdx +0 -65
- package/content/references/workflows/offer/delete-offers.mdx +0 -35
- package/content/references/workflows/offer/update-offers.mdx +0 -53
- package/content/references/workflows/order/cancel-order-fulfillment.mdx +0 -34
- package/content/references/workflows/order/confirm-claim-request.mdx +0 -25
- package/content/references/workflows/order/confirm-exchange-request.mdx +0 -25
- package/content/references/workflows/order/confirm-order-edit-request.mdx +0 -25
- package/content/references/workflows/order/confirm-return-receive.mdx +0 -25
- package/content/references/workflows/order/create-order-fulfillment.mdx +0 -45
- package/content/references/workflows/order-group/get-order-group-detail.mdx +0 -29
- package/content/references/workflows/order-group/get-order-groups-list.mdx +0 -38
- package/content/references/workflows/overview.mdx +0 -72
- package/content/references/workflows/payout/create-onboarding.mdx +0 -36
- package/content/references/workflows/payout/create-payout-account.mdx +0 -33
- package/content/references/workflows/payout/create-payout.mdx +0 -30
- package/content/references/workflows/payout/process-payout-for-webhook.mdx +0 -34
- package/content/references/workflows/product/confirm-products.mdx +0 -48
- package/content/references/workflows/product/create-products.mdx +0 -63
- package/content/references/workflows/product/link-sellers-to-product-category.mdx +0 -40
- package/content/references/workflows/product/link-sellers-to-product.mdx +0 -40
- package/content/references/workflows/product/reject-product.mdx +0 -48
- package/content/references/workflows/product/request-product-change.mdx +0 -48
- package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +0 -49
- package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +0 -46
- package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-attribute/create-product-attributes.mdx +0 -56
- package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +0 -30
- package/content/references/workflows/product-attribute/delete-product-attributes.mdx +0 -30
- package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +0 -29
- package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +0 -44
- package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +0 -41
- package/content/references/workflows/product-attribute/update-product-attributes.mdx +0 -48
- package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +0 -39
- package/content/references/workflows/product-edit/cancel-product-change.mdx +0 -49
- package/content/references/workflows/product-edit/confirm-product-change.mdx +0 -57
- package/content/references/workflows/product-edit/create-product-change.mdx +0 -72
- package/content/references/workflows/product-edit/reject-product-change.mdx +0 -54
- package/content/references/workflows/product-edit/stage-product-change.mdx +0 -75
- package/content/references/workflows/seller/approve-seller.mdx +0 -36
- package/content/references/workflows/seller/create-seller-account.mdx +0 -59
- package/content/references/workflows/seller/create-seller-defaults.mdx +0 -22
- package/content/references/workflows/seller/create-sellers.mdx +0 -65
- package/content/references/workflows/seller/delete-seller-professional-details.mdx +0 -37
- package/content/references/workflows/seller/delete-sellers.mdx +0 -24
- package/content/references/workflows/seller/invite-seller.mdx +0 -28
- package/content/references/workflows/seller/suspend-seller.mdx +0 -37
- package/content/references/workflows/seller/terminate-seller.mdx +0 -37
- package/content/references/workflows/seller/unsuspend-seller.mdx +0 -36
- package/content/references/workflows/seller/unterminate-seller.mdx +0 -36
- package/content/references/workflows/seller/update-seller-address.mdx +0 -55
- package/content/references/workflows/seller/update-seller-payment-details.mdx +0 -52
- package/content/references/workflows/seller/update-seller-professional-details.mdx +0 -48
- package/content/references/workflows/seller/update-sellers.mdx +0 -57
- package/content/resources/ai/llms.mdx +0 -74
- package/content/resources/integrations/notifications.mdx +0 -39
- package/content/resources/integrations/search.mdx +0 -122
- package/content/resources/tutorials/configure-commissions.mdx +0 -127
- package/content/resources/tutorials/first-marketplace.mdx +0 -45
- package/content/resources/tutorials/handle-product-requests.mdx +0 -80
- package/content/resources/tutorials/import-export-products.mdx +0 -96
- package/content/resources/tutorials/seller-payouts-stripe.mdx +0 -89
- package/content/resources/tutorials/store-setup-checklist.mdx +0 -214
- package/content/tools/api-client.mdx +0 -155
- package/content/tools/cli.mdx +0 -196
- package/content/tools/dashboard-sdk.mdx +0 -35
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Start provider onboarding"
|
|
3
|
+
sidebarTitle: "Start onboarding"
|
|
4
|
+
description: "Kick off provider onboarding with createOnboardingWorkflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to start provider onboarding for a payout
|
|
8
|
+
account from server code. Onboarding is what moves an account from `PENDING`
|
|
9
|
+
toward `ACTIVE`. For Stripe Connect, it produces the hosted link the seller uses
|
|
10
|
+
to submit their details.
|
|
11
|
+
|
|
12
|
+
## Run the workflow
|
|
13
|
+
|
|
14
|
+
`createOnboardingWorkflow` asks the provider to produce onboarding data and
|
|
15
|
+
stores it as an `Onboarding` record on the account.
|
|
16
|
+
|
|
17
|
+
```ts title="src/api/custom/onboarding/route.ts"
|
|
18
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
19
|
+
import { createOnboardingWorkflow } from "@mercurjs/core/workflows"
|
|
20
|
+
|
|
21
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
22
|
+
const { result } = await createOnboardingWorkflow(req.scope).run({
|
|
23
|
+
input: {
|
|
24
|
+
account_id: req.params.id,
|
|
25
|
+
context: {
|
|
26
|
+
return_url: "https://store.example.com/settings/payouts",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
res.status(201).json({ onboarding: result })
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The provider-specific payload (for Stripe Connect, the onboarding URL) is stored
|
|
36
|
+
in the record's `data` field for you to return to the seller.
|
|
37
|
+
|
|
38
|
+
<Tip>
|
|
39
|
+
Running the workflow again on an account that already has an onboarding record
|
|
40
|
+
**updates** it in place instead of creating a second one. It is safe to call
|
|
41
|
+
whenever a seller needs a fresh link.
|
|
42
|
+
</Tip>
|
|
43
|
+
|
|
44
|
+
## Reaching `ACTIVE`
|
|
45
|
+
|
|
46
|
+
Onboarding kicks off the flow, but the account only becomes `ACTIVE` when the
|
|
47
|
+
provider confirms it via webhook. Handle that step in
|
|
48
|
+
[Process a webhook](/platform/payout/guides/process-a-provider-webhook), and see
|
|
49
|
+
[Account lifecycle](/platform/payout/concepts/account-lifecycle) for the full
|
|
50
|
+
state model.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Payout"
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
description: "Onboard sellers to a payment provider and settle their earnings automatically."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use Mercur to control how each seller is onboarded and settled, while the
|
|
8
|
+
payment provider handles KYC.
|
|
9
|
+
|
|
10
|
+
Settlement you control is the Payout domain. Once an order is placed and
|
|
11
|
+
fulfilled, it splits each seller's share out to their own connected account, so
|
|
12
|
+
funds are settled per seller rather than pooled. The seller's share is the order
|
|
13
|
+
total minus commission. Onboarding is provider-driven, with the payment provider
|
|
14
|
+
carrying KYC, and the domain ships with a pluggable provider interface and a
|
|
15
|
+
**Stripe Connect** implementation out of the box. It also runs a fully automated
|
|
16
|
+
capture-and-transfer pipeline driven by scheduled jobs and provider webhooks.
|
|
17
|
+
|
|
18
|
+
<Note>
|
|
19
|
+
**Provider-agnostic.** The module talks to exactly one registered payout
|
|
20
|
+
provider through a single interface. Stripe Connect ships by default; any
|
|
21
|
+
other processor is a drop-in implementation of the same `IPayoutProvider`
|
|
22
|
+
contract.
|
|
23
|
+
</Note>
|
|
24
|
+
|
|
25
|
+
## Key features
|
|
26
|
+
|
|
27
|
+
- **Pluggable provider interface:** one `IPayoutProvider` contract, with Stripe Connect included.
|
|
28
|
+
- **Payout accounts and onboarding:** a per-seller account plus a provider onboarding record.
|
|
29
|
+
- **Webhook-driven lifecycle:** account status (`PENDING` → `ACTIVE` ↔ `RESTRICTED` / `REJECTED`) tracks the provider.
|
|
30
|
+
- **Automated pipeline:** a capture-check job, payment capture, a daily payout job, and transfer, with no manual steps.
|
|
31
|
+
- **Commission-aware transfers:** each payout is the order total minus its commission lines.
|
|
32
|
+
- **Tunable timing:** authorization window, seller-action window, capture buffer, and required fulfillment status.
|
|
33
|
+
|
|
34
|
+
## Get started
|
|
35
|
+
|
|
36
|
+
Learn how the domain fits together.
|
|
37
|
+
|
|
38
|
+
<CardGroup cols={2}>
|
|
39
|
+
<Card title="Accounts & onboarding" icon="id-card" href="/platform/payout/concepts/accounts-and-onboarding">
|
|
40
|
+
The payout account, its onboarding record, and provider data.
|
|
41
|
+
</Card>
|
|
42
|
+
<Card title="Account lifecycle" icon="arrows-rotate" href="/platform/payout/concepts/account-lifecycle">
|
|
43
|
+
Statuses and the webhook-driven transitions between them.
|
|
44
|
+
</Card>
|
|
45
|
+
<Card title="The payout pipeline" icon="arrows-turn-right" href="/platform/payout/concepts/payout-pipeline">
|
|
46
|
+
Capture check, capture, daily payout, transfer, and the provider interface.
|
|
47
|
+
</Card>
|
|
48
|
+
</CardGroup>
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
Build against the Payout domain in your own code.
|
|
53
|
+
|
|
54
|
+
<CardGroup cols={2}>
|
|
55
|
+
<Card title="Create a payout account" icon="plus" href="/platform/payout/guides/create-a-payout-account">
|
|
56
|
+
Run `createPayoutAccountWorkflow` for a seller.
|
|
57
|
+
</Card>
|
|
58
|
+
<Card title="Start onboarding" icon="link" href="/platform/payout/guides/start-provider-onboarding">
|
|
59
|
+
Kick off provider onboarding with `createOnboardingWorkflow`.
|
|
60
|
+
</Card>
|
|
61
|
+
<Card title="Process a webhook" icon="bell" href="/platform/payout/guides/process-a-provider-webhook">
|
|
62
|
+
Turn a provider webhook into account and payout status updates.
|
|
63
|
+
</Card>
|
|
64
|
+
</CardGroup>
|
|
65
|
+
|
|
66
|
+
## Resources
|
|
67
|
+
|
|
68
|
+
Data models, workflows, service methods, and events for the Payout domain.
|
|
69
|
+
|
|
70
|
+
<CardGroup cols={2}>
|
|
71
|
+
<Card title="Data models" icon="table" href="/platform/payout/reference/data-models">
|
|
72
|
+
The `PayoutAccount`, `Onboarding`, and `Payout` entities.
|
|
73
|
+
</Card>
|
|
74
|
+
<Card title="Links" icon="link" href="/platform/payout/reference/links">
|
|
75
|
+
How the Payout domain links to sellers and orders.
|
|
76
|
+
</Card>
|
|
77
|
+
<Card title="Workflows" icon="diagram-project" href="/platform/payout/reference/workflows">
|
|
78
|
+
Account, onboarding, payout, and webhook workflows.
|
|
79
|
+
</Card>
|
|
80
|
+
<Card title="Service" icon="gear" href="/platform/payout/reference/service">
|
|
81
|
+
Module service methods for working with records directly.
|
|
82
|
+
</Card>
|
|
83
|
+
<Card title="Events" icon="bell" href="/platform/payout/reference/events">
|
|
84
|
+
Events that drive the payout pipeline.
|
|
85
|
+
</Card>
|
|
86
|
+
</CardGroup>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Data models"
|
|
3
|
+
sidebarTitle: "Data models"
|
|
4
|
+
description: "The data models owned by the Payout domain."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Payout domain is owned by the **Payout module**. This reference lists its
|
|
8
|
+
data models and their fields. For the full module overview, see the
|
|
9
|
+
[Payout overview](/platform/payout/overview).
|
|
10
|
+
|
|
11
|
+
## PayoutAccount
|
|
12
|
+
|
|
13
|
+
Table `payout_account`, id prefix `pacc`. A seller's connection to the payment
|
|
14
|
+
provider. This is the record funds are transferred to.
|
|
15
|
+
|
|
16
|
+
| Field | Type | Notes |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `id` | text | Primary key |
|
|
19
|
+
| `status` | enum | `PayoutAccountStatus`, default `pending` |
|
|
20
|
+
| `data` | json | Provider-specific account data |
|
|
21
|
+
| `context` | json | Nullable; per-request provider hints |
|
|
22
|
+
|
|
23
|
+
Relations: `onboarding` (one-to-one, nullable), `payouts` (one-to-many).
|
|
24
|
+
|
|
25
|
+
## Onboarding
|
|
26
|
+
|
|
27
|
+
Table `onboarding`, id prefix `onb`. Provider setup state for a payout account
|
|
28
|
+
(for Stripe Connect, the onboarding link).
|
|
29
|
+
|
|
30
|
+
| Field | Type | Notes |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `id` | text | Primary key |
|
|
33
|
+
| `data` | json | Nullable; provider onboarding data |
|
|
34
|
+
| `context` | json | Nullable; per-request provider hints |
|
|
35
|
+
| `account_id` | text | Belongs to a `PayoutAccount` |
|
|
36
|
+
|
|
37
|
+
<Note>
|
|
38
|
+
`Onboarding` is one-to-one with `PayoutAccount`. Re-running the onboarding
|
|
39
|
+
workflow updates the existing record rather than creating a second one.
|
|
40
|
+
</Note>
|
|
41
|
+
|
|
42
|
+
## Payout
|
|
43
|
+
|
|
44
|
+
Table `payout`, id prefix `pout`. A single transfer of a seller's earnings for
|
|
45
|
+
one order.
|
|
46
|
+
|
|
47
|
+
| Field | Type | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `id` | text | Primary key |
|
|
50
|
+
| `display_id` | number | Auto-incrementing, human-readable |
|
|
51
|
+
| `currency_code` | text | The payout's currency |
|
|
52
|
+
| `amount` | bigNumber | Order total minus commission |
|
|
53
|
+
| `data` | json | Nullable; provider transfer data |
|
|
54
|
+
| `status` | enum | `PayoutStatus`, default `pending` |
|
|
55
|
+
| `account_id` | text | Belongs to a `PayoutAccount` |
|
|
56
|
+
|
|
57
|
+
## Enums
|
|
58
|
+
|
|
59
|
+
**`PayoutAccountStatus`:** `pending`, `active`, `restricted`, `rejected`.
|
|
60
|
+
|
|
61
|
+
**`PayoutStatus`:** `pending`, `processing`, `paid`, `failed`, `canceled`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Event reference"
|
|
3
|
+
sidebarTitle: "Events"
|
|
4
|
+
description: "Events that drive the payout pipeline, for subscribers and side effects."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Payout domain is event-driven. Scheduled jobs emit events, and subscribers
|
|
8
|
+
react to them to capture payments and transfer funds. Subscribe to these events
|
|
9
|
+
to run your own side effects, such as notifications, ledger syncing, or follow-up
|
|
10
|
+
workflows, instead of polling.
|
|
11
|
+
|
|
12
|
+
```ts title="src/subscribers/payout-requested.ts"
|
|
13
|
+
import type { SubscriberArgs, SubscriberConfig } from "@medusajs/framework"
|
|
14
|
+
|
|
15
|
+
export default async function payoutRequestedHandler({
|
|
16
|
+
event,
|
|
17
|
+
container,
|
|
18
|
+
}: SubscriberArgs<{ order_id: string }>) {
|
|
19
|
+
const orderId = event.data.order_id
|
|
20
|
+
// ...notify the seller, write to an external ledger, etc.
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const config: SubscriberConfig = {
|
|
24
|
+
event: "payout.requested",
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Pipeline events
|
|
29
|
+
|
|
30
|
+
| Event | Emitted when | Handled by |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `order.capture_requested` | Capture check finds an order ready to capture | The payment-capture subscriber runs `capturePaymentWorkflow` |
|
|
33
|
+
| `order.authorization_expired` | Capture check finds an authorization that already expired | Order is flagged so it isn't retried |
|
|
34
|
+
| `payout.requested` | Daily job finds a captured order not yet paid out | The transfer subscriber runs `createPayoutWorkflow` |
|
|
35
|
+
|
|
36
|
+
## Webhook events
|
|
37
|
+
|
|
38
|
+
| Event | Emitted when | Handled by |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `payout.webhook_received` | A provider webhook arrives | The `payout-webhook` subscriber runs `processPayoutForWebhookWorkflow` |
|
|
41
|
+
|
|
42
|
+
<Note>
|
|
43
|
+
`order.capture_requested`, `order.authorization_expired`, and
|
|
44
|
+
`payout.requested` are defined on the `PayoutEvents` enum in `@mercurjs/types`.
|
|
45
|
+
The webhook subscriber resolves `payout.webhook_received` to a provider action
|
|
46
|
+
before updating status. See
|
|
47
|
+
[Account lifecycle](/platform/payout/concepts/account-lifecycle).
|
|
48
|
+
</Note>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Links to other modules"
|
|
3
|
+
sidebarTitle: "Links"
|
|
4
|
+
description: "How the Payout domain links to sellers and orders across the marketplace."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Modules in Mercur never reference each other directly. They connect through
|
|
8
|
+
**module links**. The Payout module links to the Seller and Order modules. Once a
|
|
9
|
+
link is defined, you retrieve related records with `query.graph` using the link
|
|
10
|
+
alias.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const { data: sellers } = await query.graph({
|
|
14
|
+
entity: "seller",
|
|
15
|
+
fields: ["id", "name", "payout_account.*", "payouts.*"],
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Sellers
|
|
20
|
+
|
|
21
|
+
| Linked module | Relationship |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| **Seller** (account) | A store has **one** payout account (`seller` ↔ `payout_account`). |
|
|
24
|
+
| **Seller** (payouts) | A store has **many** payouts (`seller` ↔ `payout`, list). |
|
|
25
|
+
|
|
26
|
+
## Orders
|
|
27
|
+
|
|
28
|
+
| Linked module | Relationship |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| **Order** | An order has **many** payouts (`order` ↔ `payout`, list). |
|
|
31
|
+
|
|
32
|
+
<Note>
|
|
33
|
+
A payout is linked to both the order it settles and the seller it pays. The
|
|
34
|
+
account link is one-to-one, while the seller-payouts and order-payouts links
|
|
35
|
+
are lists.
|
|
36
|
+
</Note>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Service reference"
|
|
3
|
+
sidebarTitle: "Service"
|
|
4
|
+
description: "The Payout module service: methods for working with records directly."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Payout module exposes a service you can resolve from the Medusa container to
|
|
8
|
+
read and write records directly, without going through a workflow. Use it inside
|
|
9
|
+
custom services, subscribers, or scheduled jobs.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { MercurModules } from "@mercurjs/types"
|
|
13
|
+
|
|
14
|
+
const payoutModuleService = container.resolve(MercurModules.PAYOUT)
|
|
15
|
+
|
|
16
|
+
const [payouts, count] = await payoutModuleService.listAndCountPayouts({
|
|
17
|
+
status: "paid",
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Generated methods
|
|
22
|
+
|
|
23
|
+
Each data model gets a standard set of auto-generated methods. For `Payout`:
|
|
24
|
+
|
|
25
|
+
| Method | Description |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `retrievePayout(id, config?)` | Retrieve a payout by id |
|
|
28
|
+
| `listPayouts(filters?, config?)` | List payouts matching filters |
|
|
29
|
+
| `listAndCountPayouts(filters?, config?)` | List payouts with a total count |
|
|
30
|
+
| `updatePayouts(data)` | Update one or more payouts |
|
|
31
|
+
| `deletePayouts(ids)` | Delete one or more payouts |
|
|
32
|
+
|
|
33
|
+
The same set exists for `PayoutAccount` and `Onboarding` (e.g.
|
|
34
|
+
`retrievePayoutAccount`, `listPayoutAccounts`, `updateOnboardings`).
|
|
35
|
+
|
|
36
|
+
## Provider-integrated methods
|
|
37
|
+
|
|
38
|
+
These overrides call the configured provider as part of the operation. Prefer
|
|
39
|
+
them over the raw generated creates.
|
|
40
|
+
|
|
41
|
+
| Method | Description |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `createPayoutAccount(input)` | Create the account and the provider's connected account |
|
|
44
|
+
| `createOnboarding(input)` | Create or update onboarding via the provider |
|
|
45
|
+
| `createPayouts(input)` | Initiate a transfer through the provider (account must be `ACTIVE`) |
|
|
46
|
+
| `getWebhookActionAndData(input)` | Ask the provider to parse a raw webhook payload |
|
|
47
|
+
| `getOptions()` | Read the module's configured options (with defaults applied) |
|
|
48
|
+
|
|
49
|
+
<Warning>
|
|
50
|
+
Prefer [workflows](/platform/payout/reference/workflows) for anything that
|
|
51
|
+
touches the provider or links records. The generated `updatePayouts` /
|
|
52
|
+
`updatePayoutAccounts` write status directly and do **not** call the provider.
|
|
53
|
+
</Warning>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Workflows"
|
|
3
|
+
sidebarTitle: "Workflows"
|
|
4
|
+
description: "Payout account, onboarding, payout, and webhook workflows."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This reference lists the workflows for the Payout domain. Import them from
|
|
8
|
+
`@mercurjs/core/workflows` and run them against the Medusa container.
|
|
9
|
+
|
|
10
|
+
## Account & onboarding workflows
|
|
11
|
+
|
|
12
|
+
| Workflow | Input | Purpose |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `createPayoutAccountWorkflow` | `{ seller_id, data?, context? }` | Create a payout account, call the provider, link it to the store |
|
|
15
|
+
| `createOnboardingWorkflow` | `{ account_id, data?, context? }` | Create or update the account's onboarding record via the provider |
|
|
16
|
+
|
|
17
|
+
## Payout workflows
|
|
18
|
+
|
|
19
|
+
| Workflow | Input | Purpose |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `createPayoutWorkflow` | `{ order_id }` | Compute the seller's share (total − commission) and initiate a transfer |
|
|
22
|
+
| `processPayoutForWebhookWorkflow` | `PayoutWebhookResult` | Apply a provider webhook to account or payout status |
|
|
23
|
+
|
|
24
|
+
<Note>
|
|
25
|
+
`createPayoutWorkflow` reads the order with its seller, payout account, and
|
|
26
|
+
commission lines, then uses the order id as the transfer's idempotency key so
|
|
27
|
+
a re-run never double-pays.
|
|
28
|
+
</Note>
|
|
29
|
+
|
|
30
|
+
To work with records directly instead of through a workflow, see the
|
|
31
|
+
[Service reference](/platform/payout/reference/service). For the events that
|
|
32
|
+
drive these workflows, see the [Event reference](/platform/payout/reference/events).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Change actions"
|
|
3
|
+
sidebarTitle: "Change actions"
|
|
4
|
+
description: "The typed actions that make up a change and the details they carry."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn how the individual operations inside a change are
|
|
8
|
+
modeled.
|
|
9
|
+
|
|
10
|
+
## Product change action
|
|
11
|
+
|
|
12
|
+
Each operation inside a change is a `ProductChangeAction` (table
|
|
13
|
+
`product_change_action`, id prefix `prodchact`). An action belongs to a parent
|
|
14
|
+
`ProductChange`, targets a `product_id`, and names the operation in its `action`
|
|
15
|
+
field. The operation's payload lives in the `details` JSON, and an `applied`
|
|
16
|
+
boolean records whether it has already been written to the product.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const action = {
|
|
20
|
+
product_id: "prod_123",
|
|
21
|
+
action: "UPDATE",
|
|
22
|
+
details: { field: "title", value: "New title" },
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Actions carry an autoincrementing `ordering` so a change with several operations
|
|
27
|
+
applies them deterministically.
|
|
28
|
+
|
|
29
|
+
## Action types
|
|
30
|
+
|
|
31
|
+
The `action` field is one of the `ProductChangeActionType` values. Each type
|
|
32
|
+
reads a different shape out of `details`:
|
|
33
|
+
|
|
34
|
+
| Action | `details` shape | Applies |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `UPDATE` | `{ field, value }` | A single product field update |
|
|
37
|
+
| `STATUS_CHANGE` | `{ status }` | A product status change |
|
|
38
|
+
| `VARIANT_ADD` | `{ variant }` | Create a variant |
|
|
39
|
+
| `VARIANT_UPDATE` | `{ variant_id, fields }` | Update a variant (scalars + image links) |
|
|
40
|
+
| `VARIANT_REMOVE` | `{ variant_id }` | Delete a variant |
|
|
41
|
+
| `ATTRIBUTE_ADD` | `{ attribute }` | Attach a product attribute |
|
|
42
|
+
| `ATTRIBUTE_UPDATE` | `{ update }` | Change an attached attribute |
|
|
43
|
+
| `ATTRIBUTE_REMOVE` | `{ attribute_id }` | Detach an attribute |
|
|
44
|
+
| `PRODUCT_ADD` | None | Record a product creation in the trail |
|
|
45
|
+
| `PRODUCT_DELETE` | None | Delete the product |
|
|
46
|
+
| `CHANGE_REQUESTED` | `{ message }` | Record an operator revision request |
|
|
47
|
+
|
|
48
|
+
<Note>
|
|
49
|
+
`CHANGE_REQUESTED` mutates nothing. It's an audit-only marker for a revision
|
|
50
|
+
request. The operator's message rides on both the action's `details.message`
|
|
51
|
+
and the parent change's `external_note`. See
|
|
52
|
+
[Status & auto-confirm](/platform/product-edit/concepts/status-and-auto-confirm).
|
|
53
|
+
</Note>
|
|
54
|
+
|
|
55
|
+
## How actions apply
|
|
56
|
+
|
|
57
|
+
When a change is confirmed, its **not-yet-applied** actions are bucketed by type
|
|
58
|
+
and dispatched to the matching Medusa workflows in one pass: product updates,
|
|
59
|
+
variant creates/updates/deletes, and the attribute batch. Each action is then
|
|
60
|
+
flipped to `applied: true` so a re-run never applies it twice.
|
|
61
|
+
|
|
62
|
+
<Tip>
|
|
63
|
+
Audit-trail changes (publish approvals, revision requests) are stored with
|
|
64
|
+
their actions already `applied`, so confirming them is a no-op on the product
|
|
65
|
+
itself. They exist purely as history.
|
|
66
|
+
</Tip>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "The change pipeline"
|
|
3
|
+
sidebarTitle: "The change pipeline"
|
|
4
|
+
description: "The ProductChange record, its immutability, and the audit trail."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn how a product edit is captured and why the
|
|
8
|
+
pipeline is built on immutable records.
|
|
9
|
+
|
|
10
|
+
## Product change
|
|
11
|
+
|
|
12
|
+
A product change is a single reviewable edit to one product, represented by the
|
|
13
|
+
`ProductChange` data model (table `product_change`, id prefix `prodch`). It
|
|
14
|
+
references the target product through `product_id`, carries the `status` of the
|
|
15
|
+
review, and records who created and resolved it (`created_by`, `confirmed_by`,
|
|
16
|
+
`declined_by`, `canceled_by`) with matching timestamps.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const productChangeModuleService = container.resolve(MercurModules.PRODUCT_EDIT)
|
|
20
|
+
|
|
21
|
+
const change = await productChangeModuleService.retrieveProductChange(id, {
|
|
22
|
+
relations: ["actions"],
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A change owns one or more `ProductChangeAction` records (`actions`). The change
|
|
27
|
+
is the reviewable unit; the actions are the individual operations it will apply.
|
|
28
|
+
See [Change actions](/platform/product-edit/concepts/change-actions).
|
|
29
|
+
|
|
30
|
+
<Note>
|
|
31
|
+
A product can have **only one active (pending) change at a time**. Staging a
|
|
32
|
+
new change while one is still pending is rejected. The vendor resolves or
|
|
33
|
+
cancels the open change first.
|
|
34
|
+
</Note>
|
|
35
|
+
|
|
36
|
+
## Immutability & the audit trail
|
|
37
|
+
|
|
38
|
+
A change is never rewritten in place. It is created, its actions are appended,
|
|
39
|
+
and it is resolved by moving `status` forward and stamping the actor and time.
|
|
40
|
+
Because nothing is overwritten, the set of `ProductChange` rows on a product is a
|
|
41
|
+
durable history of who changed what and who approved it.
|
|
42
|
+
|
|
43
|
+
Some events aren't vendor edits at all, such as a publish approval or a revision
|
|
44
|
+
request. They still belong in the history. Those are recorded as changes created
|
|
45
|
+
already `confirmed`, so the audit trail captures them without waiting on review.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
await recordProductAuditChangeWorkflow(container).run({
|
|
49
|
+
input: {
|
|
50
|
+
actor_id: "user_123",
|
|
51
|
+
changes: [
|
|
52
|
+
{
|
|
53
|
+
product_id: "prod_123",
|
|
54
|
+
external_note: "Approved for publish",
|
|
55
|
+
actions: [
|
|
56
|
+
{ product_id: "prod_123", action: "STATUS_CHANGE", details: { status: "published" } },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
<Tip>
|
|
65
|
+
Read a product's full history through the read-only `product.changes` link
|
|
66
|
+
(see the [Links reference](/platform/product-edit/reference/links)) rather than
|
|
67
|
+
querying the module directly. The link keeps the audit trail attached to the
|
|
68
|
+
product.
|
|
69
|
+
</Tip>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Status & auto-confirm"
|
|
3
|
+
sidebarTitle: "Status & auto-confirm"
|
|
4
|
+
description: "The change status lifecycle, revision requests, and auto-confirm."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn about the states a change moves through and when
|
|
8
|
+
it resolves without operator review.
|
|
9
|
+
|
|
10
|
+
## Status
|
|
11
|
+
|
|
12
|
+
A change's state is held in the `status` field of the `ProductChange` model,
|
|
13
|
+
typed by the `ProductChangeStatus` enum. A change moves through four statuses:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌───────────┐
|
|
17
|
+
│ pending │
|
|
18
|
+
└─────┬─────┘
|
|
19
|
+
┌───────────┼───────────┐
|
|
20
|
+
confirm decline cancel
|
|
21
|
+
▼ ▼ ▼
|
|
22
|
+
┌───────────┐ ┌──────────┐ ┌──────────┐
|
|
23
|
+
│ confirmed │ │ declined │ │ canceled │
|
|
24
|
+
└───────────┘ └──────────┘ └──────────┘
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Status | Meaning |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `pending` | Awaiting operator review. The default for a staged edit |
|
|
30
|
+
| `confirmed` | Approved; its actions are applied to the product |
|
|
31
|
+
| `declined` | Rejected by the operator; nothing is applied |
|
|
32
|
+
| `canceled` | Withdrawn (e.g. by the vendor) before review |
|
|
33
|
+
|
|
34
|
+
<Note>
|
|
35
|
+
Only a `pending` change can be confirmed, declined, or canceled. The
|
|
36
|
+
resolution workflows validate the current status first, so a change is
|
|
37
|
+
resolved exactly once.
|
|
38
|
+
</Note>
|
|
39
|
+
|
|
40
|
+
## Revision requests
|
|
41
|
+
|
|
42
|
+
When an operator wants a submission reworked rather than approved or rejected,
|
|
43
|
+
they **request a revision**. This is recorded as a `CHANGE_REQUESTED` audit
|
|
44
|
+
action (a `confirmed` audit change) carrying the operator's message, and it emits
|
|
45
|
+
`product.change-requested`. The product stays with the vendor to revise and
|
|
46
|
+
resubmit. A revision request is a signal in the audit trail, not a fourth
|
|
47
|
+
resolution of the pending change.
|
|
48
|
+
|
|
49
|
+
## Auto-confirm
|
|
50
|
+
|
|
51
|
+
Staging a change runs `autoConfirmProductChangeWorkflow`. Whether it confirms
|
|
52
|
+
immediately depends on the marketplace's review setting:
|
|
53
|
+
|
|
54
|
+
- **Review off:** the change is confirmed and applied in the same run, so
|
|
55
|
+
low-friction edits don't wait for an operator.
|
|
56
|
+
- **Review on:** the change stays `pending` for an operator to resolve.
|
|
57
|
+
|
|
58
|
+
You can also force auto-confirm for a specific change (for example a
|
|
59
|
+
trusted-source import) via the `auto_confirm` flag on the staging workflow,
|
|
60
|
+
regardless of the review setting.
|
|
61
|
+
|
|
62
|
+
<Tip>
|
|
63
|
+
Auto-confirm reuses the exact same `confirmProductChangeWorkflow` as a manual
|
|
64
|
+
approval, so an auto-confirmed change is applied and audited identically to one
|
|
65
|
+
an operator approves by hand.
|
|
66
|
+
</Tip>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Confirm or decline a change"
|
|
3
|
+
sidebarTitle: "Confirm or decline"
|
|
4
|
+
description: "Resolve a pending product change from server code."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to resolve a pending change from your own server
|
|
8
|
+
code. Each resolution has a dedicated workflow so the side effects (applying
|
|
9
|
+
actions, events, compensation) run consistently.
|
|
10
|
+
|
|
11
|
+
## Confirm a change
|
|
12
|
+
|
|
13
|
+
`confirmProductChangeWorkflow` marks the changes `confirmed`, applies their
|
|
14
|
+
pending actions to the product, and emits `product-change.confirmed`.
|
|
15
|
+
|
|
16
|
+
```ts title="src/api/custom/confirm/route.ts"
|
|
17
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
18
|
+
import { confirmProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
19
|
+
|
|
20
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
21
|
+
await confirmProductChangeWorkflow(req.scope).run({
|
|
22
|
+
input: {
|
|
23
|
+
ids: [req.params.id],
|
|
24
|
+
confirmed_by: req.auth_context?.actor_id,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
res.sendStatus(200)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<Note>
|
|
33
|
+
Confirmation only applies actions that aren't already `applied`, so re-running
|
|
34
|
+
it never writes the same edit twice.
|
|
35
|
+
</Note>
|
|
36
|
+
|
|
37
|
+
## Decline a change
|
|
38
|
+
|
|
39
|
+
`rejectProductChangeWorkflow` moves a `pending` change to `declined` without
|
|
40
|
+
touching the product, and emits `product-change.declined`.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { rejectProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
44
|
+
|
|
45
|
+
await rejectProductChangeWorkflow(container).run({
|
|
46
|
+
input: {
|
|
47
|
+
id: "prodch_123",
|
|
48
|
+
declined_by: "user_123",
|
|
49
|
+
declined_reason: "Images don't meet guidelines",
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Cancel a change
|
|
55
|
+
|
|
56
|
+
When the change should be withdrawn rather than judged (for example the vendor
|
|
57
|
+
retracting their own submission), use `cancelProductChangeWorkflow`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { cancelProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
61
|
+
|
|
62
|
+
await cancelProductChangeWorkflow(container).run({
|
|
63
|
+
input: { id: "prodch_123", canceled_by: "user_123" },
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
<Warning>
|
|
68
|
+
Confirm, decline, and cancel all require the change to be `pending`. Resolving
|
|
69
|
+
an already-resolved change fails validation. A change is resolved exactly once.
|
|
70
|
+
</Warning>
|
|
71
|
+
|
|
72
|
+
## React to resolutions
|
|
73
|
+
|
|
74
|
+
To run your own side effects when a change resolves, subscribe to the events
|
|
75
|
+
these workflows emit rather than polling. See the
|
|
76
|
+
[Event reference](/platform/product-edit/reference/events).
|