Raw
1 import { CardList } from "docs-ui"
2
3 export const metadata = {
4 title: `Tax Module Provider`,
5 }
6
7 # {metadata.title}
8
9 In this guide, you’ll learn about the Tax Module Provider and how it's used.
10
11 <Note title="Looking for no-code docs?">
12
13 Refer to this [Medusa Admin User Guide](!user-guide!/settings/tax-regions) to learn how to manage tax provider of a tax region using the dashboard.
14
15 </Note>
16
17 ## What is a Tax Module Provider?
18
19 The Tax Module Provider handles tax line calculations in the Medusa application. It integrates third-party tax services, such as TaxJar, or implements custom tax calculation logic.
20
21 The Medusa application uses the Tax Module Provider whenever it needs to calculate tax lines for a cart or order, or when you [calculate the tax lines using the Tax Module's service](../tax-calculation-with-provider/page.mdx).
22
23 ![Diagram showcasing the communication between Medusa the Tax Module Provider, and the third-party tax provider.](https://res.cloudinary.com/dza7lstvk/image/upload/v1746790996/Medusa%20Resources/tax-provider-service_kcgpne.jpg)
24
25 ### Default Tax Provider
26
27 The Tax Module provides a `system` tax provider that acts as a placeholder tax provider. It performs basic tax calculation, as you can see in the [Create Tax Module Provider](/references/tax/provider#gettaxlines) guide.
28
29 This provider is installed by default in your application and you can use it with tax regions.
30
31 <Note title="Tip">
32
33 The identifier of the system tax provider is `tp_system`.
34
35 </Note>
36
37 ### Other Tax Providers
38
39 <CardList
40 items={[
41 {
42 href: "/integrations/guides/avalara",
43 title: "Avalara",
44 badge: {
45 variant: "blue",
46 children: "Tutorial"
47 }
48 }
49 ]}
50 className="mb-1"
51 />
52
53 ---
54
55 ## How to Create a Custom Tax Provider?
56
57 A Tax Module Provider is a module whose service implements the `ITaxProvider` imported from `@medusajs/framework/types`.
58
59 The module can have multiple tax provider services, where each are registered as separate tax providers.
60
61 Refer to the [Create Tax Module Provider](/references/tax/provider) guide to learn how to create a Tax Module Provider.
62
63 After you create a tax provider, you can choose it as the default Tax Module Provider for a region in the [Medusa Admin dashboard](!user-guide!/settings/tax-regions).
64
65 ---
66
67 ## How are Tax Providers Registered?
68
69 ### Configure Tax Module's Providers
70
71 The Tax Module accepts a `providers` option that allows you to configure the providers registered in your application.
72
73 Learn more about this option in the [Module Options](../module-options/page.mdx) guide.
74
75 ### Registration on Application Start
76
77 When the Medusa application starts, it registers the Tax Module Providers defined in the `providers` option of the Tax Module.
78
79 For each Tax Module Provider, the Medusa application finds all tax provider services defined in them to register.
80
81 ### TaxProvider Data Model
82
83 A registered tax provider is represented by the [TaxProvider data model](/references/tax/models/TaxProvider) in the Medusa application.
84
85 This data model is used to reference a service in the Tax Module Provider and determine whether it's installed in the application.
86
87 ![Diagram showcasing the TaxProvider data model](https://res.cloudinary.com/dza7lstvk/image/upload/v1746791254/Medusa%20Resources/tax-provider-model_r6ktjw.jpg)
88
89 The `TaxProvider` data model has the following properties:
90
91 - `id`: The unique identifier of the tax provider. The ID's format is `tp_{identifier}_{id}`, where:
92 - `identifier` is the value of the `identifier` property in the Tax Module Provider's service.
93 - `id` is the value of the `id` property of the Tax Module Provider in `medusa-config.ts`.
94 - `is_enabled`: A boolean indicating whether the tax provider is enabled.
95
96 ### How to Remove a Tax Provider?
97
98 You can remove a registered tax provider from the Medusa application by removing it from the `providers` option in the Tax Module's configuration.
99
100 Then, the next time the Medusa application starts, it will set the `is_enabled` property of the `TaxProvider`'s record to `false`. This allows you to re-enable the tax provider later if needed by adding it back to the `providers` option.