docs: updates to tax provider and other provider guides (#11626)

This commit is contained in:
Shahed Nasser
2025-02-26 16:13:05 +02:00
committed by GitHub
parent 65eb3aa6c8
commit 0eadcdd555
13 changed files with 246 additions and 138 deletions

View File

@@ -1,12 +1,12 @@
{
"id": 41934,
"id": 0,
"name": "tax-provider",
"variant": "project",
"kind": 1,
"flags": {},
"children": [
{
"id": 41935,
"id": 1,
"name": "ShippingTaxCalculationLine",
"variant": "declaration",
"kind": 2097152,
@@ -24,20 +24,20 @@
"fileName": "provider.ts",
"line": 14,
"character": 12,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L14"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L14"
}
],
"type": {
"type": "reflection",
"declaration": {
"id": 41936,
"id": 2,
"name": "__type",
"variant": "declaration",
"kind": 65536,
"flags": {},
"children": [
{
"id": 41937,
"id": 3,
"name": "shipping_line",
"variant": "declaration",
"kind": 1024,
@@ -55,7 +55,7 @@
"fileName": "provider.ts",
"line": 18,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L18"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L18"
}
],
"type": {
@@ -69,7 +69,7 @@
}
},
{
"id": 41938,
"id": 4,
"name": "rates",
"variant": "declaration",
"kind": 1024,
@@ -87,7 +87,7 @@
"fileName": "provider.ts",
"line": 22,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L22"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L22"
}
],
"type": {
@@ -108,8 +108,8 @@
{
"title": "Properties",
"children": [
41937,
41938
3,
4
]
}
],
@@ -118,14 +118,14 @@
"fileName": "provider.ts",
"line": 14,
"character": 41,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L14"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L14"
}
]
}
}
},
{
"id": 41939,
"id": 5,
"name": "ItemTaxCalculationLine",
"variant": "declaration",
"kind": 2097152,
@@ -143,20 +143,20 @@
"fileName": "provider.ts",
"line": 29,
"character": 12,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L29"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L29"
}
],
"type": {
"type": "reflection",
"declaration": {
"id": 41940,
"id": 6,
"name": "__type",
"variant": "declaration",
"kind": 65536,
"flags": {},
"children": [
{
"id": 41941,
"id": 7,
"name": "line_item",
"variant": "declaration",
"kind": 1024,
@@ -174,7 +174,7 @@
"fileName": "provider.ts",
"line": 33,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L33"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L33"
}
],
"type": {
@@ -188,7 +188,7 @@
}
},
{
"id": 41942,
"id": 8,
"name": "rates",
"variant": "declaration",
"kind": 1024,
@@ -206,7 +206,7 @@
"fileName": "provider.ts",
"line": 37,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L37"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L37"
}
],
"type": {
@@ -227,8 +227,8 @@
{
"title": "Properties",
"children": [
41941,
41942
7,
8
]
}
],
@@ -237,14 +237,14 @@
"fileName": "provider.ts",
"line": 29,
"character": 37,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L29"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L29"
}
]
}
}
},
{
"id": 41943,
"id": 9,
"name": "ITaxProvider",
"variant": "declaration",
"kind": 256,
@@ -253,55 +253,7 @@
"summary": [
{
"kind": "text",
"text": "## Overview\n\nA tax provider is used to retrieve the tax lines in a provided context. The Tax Module provides a default "
},
{
"kind": "code",
"text": "`system`"
},
{
"kind": "text",
"text": " provider. You can create your own tax provider,\neither in a plugin, in a provider module, or directly in your Medusa application's codebase, then use it in any tax region.\n\n---\n\n## How to Create a Tax Provider\n\nA tax provider class is defined in a TypeScript or JavaScript file. The class must implement the\n"
},
{
"kind": "code",
"text": "`ITaxProvider`"
},
{
"kind": "text",
"text": " interface imported from "
},
{
"kind": "code",
"text": "`@medusajs/framework/types`"
},
{
"kind": "text",
"text": ".\n\nThe file can be defined in a plugin, a provider module, or under the "
},
{
"kind": "code",
"text": "`src/services`"
},
{
"kind": "text",
"text": " directory of your Medusa application. You can later pass the package's name or the\npath to the file in the "
},
{
"kind": "code",
"text": "`providers`"
},
{
"kind": "text",
"text": " option of the Tax Module.\n\nFor example:\n\n"
},
{
"kind": "code",
"text": "```ts title=\"src/services/my-tax.ts\"\nimport { ITaxProvider } from \"@medusajs/framework/types\"\n\nexport default class MyTaxProvider implements ITaxProvider {\n // ...\n}\n```"
},
{
"kind": "text",
"text": "\n\n---\n\n## Identifier Property\n\nThe "
"text": "### Identifier Property\n\nThe "
},
{
"kind": "code",
@@ -309,7 +261,7 @@
},
{
"kind": "text",
"text": " property in a tax provider is used when the tax provider is registered in the dependency container or added to the database. A tax provider is represented in the database by the "
"text": " property in a tax provider is used when the tax provider is loaded by the Tax Module and added to the database. A tax provider is represented in the database by the "
},
{
"kind": "code",
@@ -321,11 +273,11 @@
},
{
"kind": "code",
"text": "```ts title=\"src/services/my-tax.ts\"\nexport default class MyTaxProvider implements ITaxProvider {\n static identifier = \"my-tax\"\n // ...\n}\n```"
"text": "```ts title=\"src/modules/my-tax/service.ts\"\nexport default class MyTaxProvider implements ITaxProvider {\n static identifier = \"my-tax\"\n // ...\n}\n```"
},
{
"kind": "text",
"text": "\n\n---\n\n## Constructor\n\nYou can use the "
"text": "\n\n### constructor\n\nYou can use the "
},
{
"kind": "code",
@@ -333,7 +285,7 @@
},
{
"kind": "text",
"text": " of your tax provider to access the resources registered in the dependency container.\n\nYou can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party providers APIs, you can initialize it in the constructor and use it in other methods in the service.\n\nAdditionally, if youre creating your tax provider as a plugin or a provider module to be installed in any Medusa application and you want to access its options, you can access them in the constructor.\n\nFor example:\n\n"
"text": " of your tax provider to access the resources registered in the [Module Container](https://docs.medusajs.com/resources/medusa-container-resources#module-container-resources).\n\nYou can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party providers APIs, you can initialize it in the constructor and use it in other methods in the service.\n\nAdditionally, if youre creating your tax provider as a plugin or a module provider to be installed in any Medusa application and you want to access its options, you can access them in the second parameter of the constructor.\n\nFor example:\n\n"
},
{
"kind": "code",
@@ -347,7 +299,7 @@
},
"children": [
{
"id": 41946,
"id": 12,
"name": "getTaxLines",
"variant": "declaration",
"kind": 2048,
@@ -355,14 +307,14 @@
"sources": [
{
"fileName": "provider.ts",
"line": 171,
"line": 143,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L171"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L143"
}
],
"signatures": [
{
"id": 41947,
"id": 13,
"name": "getTaxLines",
"variant": "signature",
"kind": 4096,
@@ -371,7 +323,7 @@
"summary": [
{
"kind": "text",
"text": "This method is used to retrieve the tax lines of items and shipping methods. It's used\nwhen the "
"text": "This method is used to retrieve the tax lines of items and shipping methods. It's used during checkout \nwhen the "
},
{
"kind": "code",
@@ -379,7 +331,7 @@
},
{
"kind": "text",
"text": " method of the Tax Module's main service is called.\n\nThis method is useful during checkout or when calculating the totals of orders or exchanges."
"text": " method of the Tax Module's main service is called for a tax\nregion that uses this tax provider."
}
],
"blockTags": [
@@ -434,14 +386,14 @@
"sources": [
{
"fileName": "provider.ts",
"line": 171,
"line": 143,
"character": 2,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L171"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L143"
}
],
"parameters": [
{
"id": 41948,
"id": 14,
"name": "itemLines",
"variant": "param",
"kind": 32768,
@@ -458,14 +410,14 @@
"type": "array",
"elementType": {
"type": "reference",
"target": 41939,
"target": 5,
"name": "ItemTaxCalculationLine",
"package": "@medusajs/types"
}
}
},
{
"id": 41949,
"id": 15,
"name": "shippingLines",
"variant": "param",
"kind": 32768,
@@ -482,14 +434,14 @@
"type": "array",
"elementType": {
"type": "reference",
"target": 41935,
"target": 1,
"name": "ShippingTaxCalculationLine",
"package": "@medusajs/types"
}
}
},
{
"id": 41950,
"id": 16,
"name": "context",
"variant": "param",
"kind": 32768,
@@ -558,16 +510,16 @@
{
"title": "Methods",
"children": [
41946
12
]
}
],
"sources": [
{
"fileName": "provider.ts",
"line": 108,
"line": 81,
"character": 17,
"url": "https://github.com/medusajs/medusa/blob/f00e6bf660ab96b9d41bc3d424c8d78c54eaa8e7/packages/core/types/src/tax/provider.ts#L108"
"url": "https://github.com/medusajs/medusa/blob/95eef899f72b72aa138e9db0dffe2a3eeb40f241/packages/core/types/src/tax/provider.ts#L81"
}
]
}
@@ -576,76 +528,76 @@
{
"title": "Interfaces",
"children": [
41943
9
]
},
{
"title": "Type Aliases",
"children": [
41935,
41939
1,
5
]
}
],
"packageName": "@medusajs/types",
"symbolIdMap": {
"41934": {
"0": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": ""
},
"41935": {
"1": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "ShippingTaxCalculationLine"
},
"41936": {
"2": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type"
},
"41937": {
"3": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type.shipping_line"
},
"41938": {
"4": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type.rates"
},
"41939": {
"5": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "ItemTaxCalculationLine"
},
"41940": {
"6": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type"
},
"41941": {
"7": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type.line_item"
},
"41942": {
"8": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "__type.rates"
},
"41943": {
"9": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "ITaxProvider"
},
"41946": {
"12": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "ITaxProvider.getTaxLines"
},
"41947": {
"13": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "ITaxProvider.getTaxLines"
},
"41948": {
"14": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "itemLines"
},
"41949": {
"15": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "shippingLines"
},
"41950": {
"16": {
"sourceFileName": "../../../../packages/core/types/src/tax/provider.ts",
"qualifiedName": "context"
}
@@ -655,7 +607,7 @@
"1": "../../../../packages/core/types/src/tax/provider.ts"
},
"reflections": {
"1": 41934
"1": 0
}
}
}