Files

74 lines
2.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
displayed_sidebar: taxReference
---
import { TypeList } from "docs-ui"
# ITaxProvider
### Identifier Property
Each tax provider has a unique identifier defined in its class. The provider's ID
will be stored as `tp_{identifier}_{id}`, where `{id}` is the provider's `id`
property in the `medusa-config.ts`.
For example:
```ts title="src/modules/my-tax/service.ts"
export default class MyTaxProvider implements ITaxProvider {
static identifier = "my-tax"
// ...
}
```
### constructor
You can use the `constructor` of your Tax Module Provider's service to access the resources registered in the [Module Container](https://docs.medusajs.com/resources/medusa-container-resources#module-container-resources).
You 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.
Additionally, 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.
For example:
```ts
import {
ITaxProvider,
Logger
} from "@medusajs/framework/types"
type InjectedDependencies = {
logger: Logger
}
type Options = {
apiKey: string
}
export default class MyTaxProvider implements ITaxProvider {
static identifier = "my-tax"
protected logger_: Logger
protected options_: Options
// assuming you're initializing a client
protected client
constructor (
{ logger }: InjectedDependencies,
options: Options
) {
this.logger_ = logger
this.options_ = options
// assuming you're initializing a client
this.client = new Client(options)
}
}
```
---
## Methods
- [getIdentifier](../../ITaxProvider/methods/tax.ITaxProvider.getIdentifier/page.mdx)
- [getTaxLines](../../ITaxProvider/methods/tax.ITaxProvider.getTaxLines/page.mdx)