docs: add documentation for Locking Module (#11824)
* add locking docs * fix main navbar * added implementation example links * generate refs * update architecture * fix vale error
This commit is contained in:
1 parent
5cf0bf4d93
commit
28b0d08591
94 files changed
+15932
-10857
No files matched your search
@@ -27,6 +27,11 @@ const customOptions: Record<string, Partial<TypeDocOptions>> = {
|
||||
name: "auth-provider",
|
||||
parentIgnore: true,
|
||||
}),
|
||||
locking: getOptions({
|
||||
entryPointPath: "packages/core/types/src/locking/index.ts",
|
||||
tsConfigName: "types.json",
|
||||
name: "locking",
|
||||
}),
|
||||
dml: getOptions({
|
||||
entryPointPath: [
|
||||
"packages/core/utils/src/dml/entity-builder.ts",
|
||||
|
||||
+15
-10
@@ -6,14 +6,14 @@ const authProviderOptions: FormattingOptionsType = {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create an auth provider module and the methods you must implement in its main service.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create an Auth Module Provider and the methods you must implement in its main service.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/auth/provider",
|
||||
tags: ["auth", "server", "how to"],
|
||||
sidebar_label: "Create Auth Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create an Auth Provider Module",
|
||||
fullReplacement: "How to Create an Auth Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -24,6 +24,11 @@ const authProviderOptions: FormattingOptionsType = {
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Implementation Example
|
||||
|
||||
As you implement your Auth Module Provider, it can be useful to refer to an existing provider and how it's implemeted.
|
||||
|
||||
If you need to refer to an existing implementation as an example, check the [Google Auth Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/auth-google).`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
Start by creating a new directory for your module provider.
|
||||
@@ -37,9 +42,9 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-auth\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Auth Provider Service
|
||||
`## 2. Create the Auth Module Provider's Service
|
||||
|
||||
Create the file \`src/modules/my-auth/service.ts\` that holds the module's main service. It must extend the \`AbstractAuthModuleProvider\` class imported from \`@medusajs/framework/utils\`:
|
||||
Create the file \`src/modules/my-auth/service.ts\` that holds the module provider's main service. It must extend the \`AbstractAuthModuleProvider\` class imported from \`@medusajs/framework/utils\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-auth/service.ts"
|
||||
import { AbstractAuthModuleProvider } from "@medusajs/framework/utils"
|
||||
@@ -52,7 +57,7 @@ export default MyAuthProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-auth/index.ts\` with the following content:
|
||||
|
||||
@@ -68,8 +73,8 @@ export default ModuleProvider(Modules.AUTH, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyAuthProviderService\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyAuthProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Auth Module Provider, add it to the \`providers\` array of the Auth Module in \`medusa-config.ts\`:
|
||||
|
||||
@@ -107,9 +112,9 @@ module.exports = defineConfig({
|
||||
`,
|
||||
`## 5. Test it Out
|
||||
|
||||
To test out your authentication provider, use any of the [Authentication Routes](https://docs.medusajs.com/v2/resources/commerce-modules/auth/authentication-route), using your provider's ID as a path parameter.
|
||||
To test out your Authentication Module Provider, use any of the [Authentication Routes](https://docs.medusajs.com/v2/resources/commerce-modules/auth/authentication-route), using your provider's ID as a path parameter.
|
||||
|
||||
For example, to get a registration token for an admin user, send a \`POST\` request to \`/auth/user/my-auth/register\` replacing \`my-auth\` with your authentication provider's ID:
|
||||
For example, to get a registration token for an admin user, send a \`POST\` request to \`/auth/user/my-auth/register\` replacing \`my-auth\` with your Authentication Module Provider's ID:
|
||||
|
||||
\`\`\`bash
|
||||
curl -X POST http://localhost:9000/auth/user/my-auth/register
|
||||
@@ -120,7 +125,7 @@ curl -X POST http://localhost:9000/auth/user/my-auth/register
|
||||
}'
|
||||
\`\`\`
|
||||
|
||||
Change the request body to pass the data required for your authentication provider to register the user.
|
||||
Change the request body to pass the data required for your Authentication Module Provider to register the user.
|
||||
|
||||
If registration is successful, the response will have a \`token\` property.
|
||||
`,
|
||||
|
||||
+13
-8
@@ -6,12 +6,12 @@ const fileOptions: FormattingOptionsType = {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a file provider module and the methods you must implement in its main service.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create a File Module Provider and the methods you must implement in its main service.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/file-provider-module",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a File Provider Module",
|
||||
fullReplacement: "How to Create a File Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -22,6 +22,11 @@ const fileOptions: FormattingOptionsType = {
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Implementation Example
|
||||
|
||||
As you implement your File Module Provider, it can be useful to refer to an existing provider and how it's implemeted.
|
||||
|
||||
If you need to refer to an existing implementation as an example, check the [S3 File Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/file-s3).`,
|
||||
`## Create Module Provider Directory
|
||||
|
||||
Start by creating a new directory for your module provider.
|
||||
@@ -35,9 +40,9 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-file\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the File Provider Service
|
||||
`## 2. Create the File Module Provider's Service
|
||||
|
||||
Create the file \`src/modules/my-file/service.ts\` that holds the implementation of the module's main service. It must extend the \`AbstractFileProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
Create the file \`src/modules/my-file/service.ts\` that holds the implementation of the module provider's main service. It must extend the \`AbstractFileProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-file/service.ts"
|
||||
import { AbstractFileProviderService } from "@medusajs/framework/utils"
|
||||
@@ -50,7 +55,7 @@ export default MyFileProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-file/index.ts\` with the following content:
|
||||
|
||||
@@ -66,8 +71,8 @@ export default ModuleProvider(Modules.FILE, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyFileProviderService\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyFileProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your File Module Provider, add it to the \`providers\` array of the File Module in \`medusa-config.ts\`:
|
||||
|
||||
@@ -107,7 +112,7 @@ module.exports = defineConfig({
|
||||
`,
|
||||
`## 5. Test it Out
|
||||
|
||||
To test out your file provider, use the Medusa Admin or the [Upload API route](https://docs.medusajs.com/v2/api/admin#uploads_postuploads) to upload a file.
|
||||
To test out your File Module Provider, use the Medusa Admin or the [Upload API route](https://docs.medusajs.com/v2/api/admin#uploads_postuploads) to upload a file.
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
+12
-12
@@ -6,14 +6,14 @@ const fulfillmentProviderOptions: FormattingOptionsType = {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a fulfillment provider module and the methods you must implement in its main service.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Fulfillment Module Provider and the methods you must implement in its main service.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/fulfillment/provider",
|
||||
tags: ["fulfillment", "server", "how to"],
|
||||
sidebar_label: "Create Fulfillment Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Fulfillment Provider Module",
|
||||
fullReplacement: "How to Create a Fulfillment Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -24,11 +24,11 @@ const fulfillmentProviderOptions: FormattingOptionsType = {
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Understanding Fulfillment Provider Implementation
|
||||
`## Understanding Fulfillment Module Provider Implementation
|
||||
|
||||
The Fulfillment Module Provider handles processing fulfillments and shipments with a third-party provirder. However, it's not responsible for managing fulfillment concepts within Medusa, such as creating a fulfillment or its shipments. The Fulfillment Module uses your fulfillment provider within core operations.
|
||||
The Fulfillment Module Provider handles processing fulfillments and shipments with a third-party provirder. However, it's not responsible for managing fulfillment concepts within Medusa, such as creating a fulfillment or its shipments. The Fulfillment Module uses your Fulfillment Module Provider within core operations.
|
||||
|
||||
For example, when the merchant creates a fulfillment for an order, the Fulfillment Module uses your fulfillment provider to create the fulfillment in the third-party system, then creates the fulfillment in Medusa. So, you only have to implement the third-party fulfillment processing logic in your fulfillment provider.
|
||||
For example, when the merchant creates a fulfillment for an order, the Fulfillment Module uses your Fulfillment Module Provider to create the fulfillment in the third-party system, then creates the fulfillment in Medusa. So, you only have to implement the third-party fulfillment processing logic in your Fulfillment Module Provider.
|
||||
`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
@@ -43,9 +43,9 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-fulfillment\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Fulfillment Provider Service
|
||||
`## 2. Create the Fulfillment Module Provider Service
|
||||
|
||||
Create the file \`src/modules/my-fulfillment/service.ts\` that holds the module's main service. It must extend the \`AbstractFulfillmentProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
Create the file \`src/modules/my-fulfillment/service.ts\` that holds the module provider's main service. It must extend the \`AbstractFulfillmentProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-fulfillment/service.ts"
|
||||
import { AbstractFulfillmentProviderService } from "@medusajs/framework/utils"
|
||||
@@ -58,7 +58,7 @@ export default MyFulfillmentProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-fulfillment/index.ts\` with the following content:
|
||||
|
||||
@@ -74,8 +74,8 @@ export default ModuleProvider(Modules.FULFILLMENT, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyFulfillmentProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Fulfillment Module Provider, add it to the \`providers\` array of the Fulfillment Module in \`medusa-config.ts\`:
|
||||
|
||||
@@ -109,9 +109,9 @@ module.exports = defineConfig({
|
||||
`,
|
||||
`## 5. Test it Out
|
||||
|
||||
Before you use your fulfillment provider, in the Medusa Admin:
|
||||
Before you use your Fulfillment Module Provider, in the Medusa Admin:
|
||||
|
||||
1. Add the fulfillment provider to a location.
|
||||
1. Add the Fulfillment Module Provider to a location.
|
||||
2. Add in the location a delivery shipping option that uses the provider.
|
||||
|
||||
Then, place an order, choosing the shipping option you created during checkout, and create a fulfillment in the Medusa Admin. The fulfillment is created using your provider.
|
||||
|
||||
+2
@@ -13,6 +13,7 @@ import workflowsOptions from "./workflows.js"
|
||||
import dmlOptions from "./dml.js"
|
||||
import coreFlowsOptions from "./core-flows.js"
|
||||
import jsSdkOptions from "./js-sdk.js"
|
||||
import lockingOptions from "./locking.js"
|
||||
|
||||
const mergerCustomOptions: FormattingOptionsType = {
|
||||
...authProviderOptions,
|
||||
@@ -22,6 +23,7 @@ const mergerCustomOptions: FormattingOptionsType = {
|
||||
...fulfillmentProviderOptions,
|
||||
...helperStepsOptions,
|
||||
...jsSdkOptions,
|
||||
...lockingOptions,
|
||||
...medusaConfigOptions,
|
||||
...medusaOptions,
|
||||
...notificationOptions,
|
||||
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
import { FormattingOptionsType } from "types"
|
||||
import baseSectionsOptions from "../base-section-options.js"
|
||||
|
||||
const lockingOptions: FormattingOptionsType = {
|
||||
"^locking/.*ILockingProvider": {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Locking Module Provider and the methods you must implement in its main service.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/locking-module-provider",
|
||||
tags: ["locking", "server", "how to"],
|
||||
sidebar_label: "Create Locking Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Locking Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
expandProperties: true,
|
||||
sections: {
|
||||
...baseSectionsOptions,
|
||||
member_declaration_title: false,
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Implementation Example
|
||||
|
||||
As you implement your Locking Module Provider, it can be useful to refer to an existing provider and how it's implemeted.
|
||||
|
||||
If you need to refer to an existing implementation as an example, check the [Redis Locking Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/locking-redis).`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
Start by creating a new directory for your module provider.
|
||||
|
||||
If you're creating the module provider in a Medusa application, create it under the \`src/modules\` directory. For example, \`src/modules/my-locking\`.
|
||||
|
||||
If you're creating the module provider in a plugin, create it under the \`src/providers\` directory. For example, \`src/providers/my-locking\`.
|
||||
|
||||
<Note>
|
||||
|
||||
The rest of this guide always uses the \`src/modules/my-locking\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Locking Module Provider Service
|
||||
|
||||
Create the file \`src/modules/my-locking/service.ts\` that holds the module provider's main service. It must implement the \`ILockingProvider\` interface imported from \`@medusajs/framework/types\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-locking/service.ts"
|
||||
import { ILockingProvider } from "@medusajs/framework/types"
|
||||
|
||||
type Options = {
|
||||
url: string
|
||||
}
|
||||
|
||||
class MyLockingProviderService implements ILockingProvider {
|
||||
// TODO implement methods
|
||||
}
|
||||
|
||||
export default MyLockingProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
|
||||
Create the file \`src/modules/my-locking/index.ts\` with the following content:
|
||||
|
||||
\`\`\`ts title="src/modules/my-locking/index.ts"
|
||||
import { ModuleProvider, Modules } from "@medusajs/framework/utils"
|
||||
import MyLockingProviderService from "./service"
|
||||
|
||||
export default ModuleProvider(Modules.LOCKING, {
|
||||
services: [MyLockingProviderService],
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module provider's definition, indicating that the \`MyLockingProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Locking Module Provider, add it to the \`providers\` array of the Locking Module in \`medusa-config.ts\`:
|
||||
|
||||
\`\`\`ts title="medusa-config.ts"
|
||||
module.exports = defineConfig({
|
||||
// ...
|
||||
modules: [
|
||||
{
|
||||
resolve: "@medusajs/medusa/payment",
|
||||
options: {
|
||||
providers: [
|
||||
{
|
||||
// if module provider is in a plugin, use \`plugin-name/providers/my-locking\`
|
||||
resolve: "./src/modules/my-locking",
|
||||
id: "my-lock",
|
||||
// set this if you want this provider to be used by default
|
||||
// and you have other Locking Module Providers registered.
|
||||
is_default: true,
|
||||
options: {
|
||||
url: "http://example.com",
|
||||
// provider options...
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
\`\`\`
|
||||
`,
|
||||
`## 5. Test it Out
|
||||
|
||||
When you start the Medusa application, if your Locking Module Provider is the only registered provider without enabling \`is_default\`, you'll see the following message:
|
||||
|
||||
\`\`\`bash
|
||||
info: Locking module: Using "my-lock" as default.
|
||||
\`\`\`
|
||||
|
||||
This indicates that your Locking Module Provider is being used as the default provider.
|
||||
|
||||
The Locking Module will now use your provider to handle all locking operations.
|
||||
`,
|
||||
`## Useful Guides
|
||||
|
||||
- [How to Use Locking Module](/references/locking-service)
|
||||
`,
|
||||
],
|
||||
},
|
||||
"^locking/.*ILockingModule": {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn about the different methods in the Locking Module's service and how to use them.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/locking-service",
|
||||
tags: ["locking", "server", "how to"],
|
||||
sidebar_label: "Use Locking Module",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Use Locking Module",
|
||||
},
|
||||
expandMembers: true,
|
||||
startSections: [
|
||||
`## Resolve Locking Module's Service
|
||||
|
||||
In your workflow's step, you can resolve the Locking Module's service from the Medusa container:
|
||||
|
||||
\`\`\`ts
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
import { createStep } from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
const step1 = createStep(
|
||||
"step-1",
|
||||
async ({}, { container }) => {
|
||||
const lockingModuleService = container.resolve(
|
||||
Modules.LOCKING
|
||||
)
|
||||
|
||||
// TODO use lockingModuleService
|
||||
}
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
You can then use the Locking Module's service's methods in the step. The rest of this guide details these methods.
|
||||
|
||||
---
|
||||
`,
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
export default lockingOptions
|
||||
+12
-7
@@ -6,14 +6,14 @@ const notificationOptions: FormattingOptionsType = {
|
||||
reflectionGroups: {
|
||||
Constructors: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a notification provider module and the methods you must implement in it.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Notification Module Provider and the methods you must implement in it.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/notification-provider-module",
|
||||
tags: ["notification", "server", "how to"],
|
||||
sidebar_label: "Create Notification Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Notification Provider Module",
|
||||
fullReplacement: "How to Create a Notification Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -24,6 +24,11 @@ const notificationOptions: FormattingOptionsType = {
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Implementation Example
|
||||
|
||||
As you implement your Notification Module Provider, it can be useful to refer to an existing provider and how it's implemeted.
|
||||
|
||||
If you need to refer to an existing implementation as an example, check the [SendGrid Notification Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/notification-sendgrid).`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
Start by creating a new directory for your module provider.
|
||||
@@ -37,11 +42,11 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-notification\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Notification Provider Service
|
||||
`## 2. Create the Notification Module Provider's Service
|
||||
|
||||
Create the file \`src/modules/my-notification/service.ts\` that holds the implementation of the notification service.
|
||||
|
||||
The Notification Provider Module's main service must extend the \`AbstractNotificationProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
The Notification Module Provider's main service must extend the \`AbstractNotificationProviderService\` class imported from \`@medusajs/framework/utils\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-notification/service.ts"
|
||||
import {
|
||||
@@ -56,7 +61,7 @@ export default MyNotificationProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-notification/index.ts\` with the following content:
|
||||
|
||||
@@ -72,8 +77,8 @@ export default ModuleProvider(Modules.NOTIFICATION, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyNotificationProviderService\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyNotificationProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Notification Module Provider, add it to the \`providers\` array of the Notification Module in \`medusa-config.ts\`:
|
||||
|
||||
|
||||
+18
-13
@@ -6,14 +6,14 @@ const paymentProviderOptions: FormattingOptionsType = {
|
||||
maxLevel: 2,
|
||||
},
|
||||
"^payment_provider/.*AbstractPaymentProvider": {
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Payment Provider to be used with the Payment Module.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Payment Module Provider to be used with the Payment Module.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/payment/provider",
|
||||
tags: ["payment", "server", "how to"],
|
||||
sidebar_label: "Create Payment Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Payment Provider",
|
||||
fullReplacement: "How to Create a Payment Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -24,11 +24,16 @@ const paymentProviderOptions: FormattingOptionsType = {
|
||||
reflection_typeParameters: false,
|
||||
},
|
||||
startSections: [
|
||||
`## Understanding Payment Provider Implementation
|
||||
`## Implementation Example
|
||||
|
||||
As you implement your Payment Module Provider, it can be useful to refer to an existing provider and how it's implemeted.
|
||||
|
||||
The Payment Module Provider handles processing payment with a third-party provirder. However, it's not responsible for managing payment concepts within Medusa, such as payment sessions or collections. These concepts are handled by the Payment Module which uses your payment provider within core operations.
|
||||
If you need to refer to an existing implementation as an example, check the [Stripe Payment Module Provider in the Medusa repository](https://github.com/medusajs/medusa/tree/develop/packages/modules/providers/payment-stripe).`,
|
||||
`## Understanding Payment Module Provider Implementation
|
||||
|
||||
For example, when the merchant captures an order's payment, the Payment Module uses the payment provider to capture the payment, the makes updates to the \`Payment\` record associated with the order. So, you only have to implement the third-party payment processing logic in your payment provider.
|
||||
The Payment Module Provider handles processing payment with a third-party provirder. However, it's not responsible for managing payment concepts within Medusa, such as payment sessions or collections. These concepts are handled by the Payment Module which uses your Payment Module Provider within core operations.
|
||||
|
||||
For example, when the merchant captures an order's payment, the Payment Module uses the Payment Module Provider to capture the payment, the makes updates to the \`Payment\` record associated with the order. So, you only have to implement the third-party payment processing logic in your Payment Module Provider.
|
||||
`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
@@ -43,9 +48,9 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-payment\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Payment Provider Service
|
||||
`## 2. Create the Payment Module Provider's Service
|
||||
|
||||
Create the file \`src/modules/my-payment/service.ts\` that holds the module's main service. It must extend the \`AbstractPaymentProvider\` class imported from \`@medusajs/framework/utils\`:
|
||||
Create the file \`src/modules/my-payment/service.ts\` that holds the module provider's main service. It must extend the \`AbstractPaymentProvider\` class imported from \`@medusajs/framework/utils\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-payment/service.ts"
|
||||
import { AbstractPaymentProvider } from "@medusajs/framework/utils"
|
||||
@@ -64,7 +69,7 @@ export default MyPaymentProviderService
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-payment/index.ts\` with the following content:
|
||||
|
||||
@@ -80,8 +85,8 @@ export default ModuleProvider(Modules.PAYMENT, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyPaymentProviderService\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyPaymentProviderService\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Payment Module Provider, add it to the \`providers\` array of the Payment Module in \`medusa-config.ts\`:
|
||||
|
||||
@@ -111,13 +116,13 @@ module.exports = defineConfig({
|
||||
`,
|
||||
`## 5. Test it Out
|
||||
|
||||
Before you use your payment provider, enable it in a region using the Medusa Admin.
|
||||
Before you use your Payment Module Provider, enable it in a region using the Medusa Admin.
|
||||
|
||||
Then, go through checkout to place an order. Your payment provider is used to authorize the payment.
|
||||
Then, go through checkout to place an order. Your Payment Module Provider is used to authorize the payment.
|
||||
`,
|
||||
`## Useful Guides
|
||||
|
||||
- [Storefront Guide: how to implement UI for your payment provider during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment)
|
||||
- [Storefront Guide: how to implement UI for your Payment Module Provider during checkout](https://docs.medusajs.com/resources/storefront-development/checkout/payment)
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
+11
-11
@@ -5,14 +5,14 @@ const taxProviderOptions: FormattingOptionsType = {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a tax provider to use with the Tax Module, and the methods to implement.`,
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Tax Module Provider to use with the Tax Module, and the methods to implement.`,
|
||||
frontmatterData: {
|
||||
slug: "/references/tax/provider",
|
||||
tags: ["tax", "server", "how to"],
|
||||
sidebar_label: "Create Tax Provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Tax Provider",
|
||||
fullReplacement: "How to Create a Tax Module Provider",
|
||||
},
|
||||
shouldIncrementAfterStartSections: true,
|
||||
expandMembers: true,
|
||||
@@ -20,12 +20,12 @@ const taxProviderOptions: FormattingOptionsType = {
|
||||
startSections: [
|
||||
`## Overview
|
||||
|
||||
A tax provider is used to retrieve the tax lines in a provided context. The Tax Module provides a default \`system\` provider. You can create your own tax provider, either in a plugin, in a module provider, or directly in your Medusa application's codebase, then use it in any tax region.`,
|
||||
`## Understanding Tax Provider Implementation
|
||||
A Tax Module Provider is used to retrieve the tax lines in a provided context. The Tax Module provides a default \`system\` provider. You can create your own Tax Module Provider, either in a plugin, in a module provider, or directly in your Medusa application's codebase, then use it in any tax region.`,
|
||||
`## Understanding Tax Module Provider Implementation
|
||||
|
||||
The Tax Module Provider handles calculating taxes with a third-party provirder. However, it's not responsible for managing tax concepts within Medusa, such as creating a tax region. The Tax Module uses your tax provider within core operations.
|
||||
The Tax Module Provider handles calculating taxes with a third-party provirder. However, it's not responsible for managing tax concepts within Medusa, such as creating a tax region. The Tax Module uses your Tax Module Provider within core operations.
|
||||
|
||||
For example, during checkout, the tax provider of the tax region that the customer is in is used to calculate the tax for the cart and order. So, you only have to implement the third-party tax calculation logic in your tax provider.`,
|
||||
For example, during checkout, the Tax Module Provider of the tax region that the customer is in is used to calculate the tax for the cart and order. So, you only have to implement the third-party tax calculation logic in your Tax Module Provider.`,
|
||||
`## 1. Create Module Provider Directory
|
||||
|
||||
Start by creating a new directory for your module provider.
|
||||
@@ -39,9 +39,9 @@ If you're creating the module provider in a plugin, create it under the \`src/pr
|
||||
The rest of this guide always uses the \`src/modules/my-tax\` directory as an example.
|
||||
|
||||
</Note>`,
|
||||
`## 2. Create the Tax Provider Service
|
||||
`## 2. Create the Tax Module Provider's Service
|
||||
|
||||
Create the file \`src/modules/my-tax/service.ts\` that holds the module's main service. It must extend the \`ITaxProvider\` class imported from \`@medusajs/framework/types\`:
|
||||
Create the file \`src/modules/my-tax/service.ts\` that holds the module provider's main service. It must extend the \`ITaxProvider\` class imported from \`@medusajs/framework/types\`:
|
||||
|
||||
\`\`\`ts title="src/modules/my-tax/service.ts"
|
||||
import { ITaxProvider } from "@medusajs/framework/types"
|
||||
@@ -52,7 +52,7 @@ export default class MyTaxProvider implements ITaxProvider {
|
||||
\`\`\``,
|
||||
],
|
||||
endSections: [
|
||||
`## 3. Create Module Definition File
|
||||
`## 3. Create Module Provider Definition File
|
||||
|
||||
Create the file \`src/modules/my-tax/index.ts\` with the following content:
|
||||
|
||||
@@ -68,8 +68,8 @@ export default ModuleProvider(Modules.TAX, {
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
This exports the module's definition, indicating that the \`MyTaxProvider\` is the module's service.`,
|
||||
`## 4. Use Module
|
||||
This exports the module provider's definition, indicating that the \`MyTaxProvider\` is the module provider's service.`,
|
||||
`## 4. Use Module Provider
|
||||
|
||||
To use your Tax Module Provider, add it to the \`providers\` array of the Tax Module in \`medusa-config.ts\`:
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ const allReferences = [
|
||||
"types",
|
||||
"utils",
|
||||
"workflows",
|
||||
"locking",
|
||||
]
|
||||
|
||||
export default allReferences
|
||||
Reference in new issue
Block a user