docs: change config snippets to use defineConfig (#7546)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-30 16:47:28 +03:00
1 parent ddfd757277
commit fe96bd39b1
51 files changed
+489 -718

No files matched your search

@@ -104,31 +104,32 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```js title="medusa-config.js"
const modules = {
const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = defineConfig({
// ...
payment: {
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
options: {
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
options: {
// ...
},
},
},
{
resolve: "medusa-payment-paypal",
options: {
// ...
},
},
],
],
},
},
},
}
}
})
```
The `providers` option is an array of objects that accept the following properties:
- `resolve`: A string indicating the package name of the payment provider module or the payment plugin, or the path to the file defining the payment provider.
- `options`: An optional object of options to pass to the payment provider.
- `resolve`: A string indicating the package name of the payment provider module or the path to it relative to the `src` directory.
- `options`: An optional object of the payment provider module's options. The object must have the following property:
- `config`: An object whose key is the ID of the payment provider, and its value is an object of options to pass to the provider module.
@@ -72,26 +72,6 @@ await paymentModuleService.processEvent({
## Configure Payment Module
To use the Payment Module, enable it in the `modules` object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
options: {
// ...
},
},
}
```
### Module Options
Refer to [this documentation](./module-options/page.mdx) for details on the module's options.
---
@@ -39,30 +39,36 @@ npm install @medusajs/payment-stripe
Next, add the module to the array of providers passed to the Payment Module:
```js title="medusa-config.js"
const modules = {
const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = defineConfig({
// ...
payment: {
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
options: {
config: {
stripe: {
credentials: {
usd: {
apiKey: process.env.STRIPE_USD_API_KEY,
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
options: {
config: {
stripe: {
credentials: {
usd: {
apiKey: process.env.STRIPE_USD_API_KEY,
},
},
},
}
}
}
},
},
},
],
],
},
},
},
}
}
})
```
### Environment Variables