chore(utils, types): updated TSDocs of AbstractPaymentProvider (#8335)

- Update the TSDocs of `AbstractPaymentProvider`
- Remove old TSDocs of `IPaymentProvider`
- Update the config that generates the payment module provider reference.

Closes DOCS-781
This commit is contained in:
Shahed Nasser
2024-08-01 18:50:34 +03:00
committed by GitHub
parent 4a95a48e94
commit 5ed5b45cce
7 changed files with 629 additions and 241 deletions

View File

@@ -48,7 +48,7 @@ export default {
This exports the module's definition, indicating that the \`MyAuthProviderService\` is the module's service.`,
`## 4. Use Module
To use your Auth Provider Module, add it to the \`providers\` array of the Auth Module:
To use your Auth Module Provider, add it to the \`providers\` array of the Auth Module:
\`\`\`js title="medusa-config.js"
import { Modules } from "@medusajs/utils"

View File

@@ -48,7 +48,7 @@ export default {
This exports the module's definition, indicating that the \`MyFileProviderService\` is the module's service.`,
`## 4. Use Module
To use your File Provider Module, add it to the \`providers\` array of the File Module:
To use your File Module Provider, add it to the \`providers\` array of the File Module:
<Note>

View File

@@ -48,7 +48,7 @@ export default {
This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the module's service.`,
`## 4. Use Module
To use your Fulfillment Provider Module, add it to the \`providers\` array of the Fulfillment Module:
To use your Fulfillment Module Provider, add it to the \`providers\` array of the Fulfillment Module:
\`\`\`js title="medusa-config.js"
import { Modules } from "@medusajs/utils"

View File

@@ -52,7 +52,7 @@ export default {
This exports the module's definition, indicating that the \`MyNotificationProviderService\` is the module's service.`,
`## 4. Use Module
To use your Notification Provider Module, add it to the \`providers\` array of the Notification Module:
To use your Notification Module Provider, add it to the \`providers\` array of the Notification Module:
<Note>

View File

@@ -15,6 +15,78 @@ const paymentProviderOptions: FormattingOptionsType = {
reflectionGroups: {
Properties: false,
},
shouldIncrementAfterStartSections: true,
expandMembers: true,
startSections: [
`## 1. Create Module Directory
Start by creating a new directory for your module. For example, \`src/modules/my-payment\`.`,
`## 2. Create the Payment Provider 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/utils\`:
\`\`\`ts title="src/modules/my-payment/service.ts"
import { AbstractPaymentProvider } from "@medusajs/utils"
type Options = {
apiKey: string
}
class MyPaymentProviderService extends AbstractPaymentProvider<
Options
> {
// TODO implement methods
}
export default MyPaymentProviderService
\`\`\``,
],
endSections: [
`## 3. Create Module Definition File
Create the file \`src/modules/my-payment/index.ts\` with the following content:
\`\`\`ts title="src/modules/my-payment/index.ts"
import MyPaymentProviderService from "./service"
export default {
services: [MyPaymentProviderService],
}
\`\`\`
This exports the module's definition, indicating that the \`MyPaymentProviderService\` is the module's service.`,
`## 4. Use Module
To use your Payment Module Provider, add it to the \`providers\` array of the Payment Module:
\`\`\`js title="medusa-config.js"
import { Modules } from "@medusajs/utils"
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "./modules/my-payment",
id: "my-payment",
options: {
// provider options...
apiKey: "..."
}
}
]
}
}
}
})
\`\`\`
`,
],
},
}