Tax Module

The Tax Module provides tax-related features in your Medusa and Node.js applications.

How to Use Tax Module's Service#

You can use the Tax Module's main service by resolving from the Medusa container the resource Modules.TAX imported from @medusajs/framework/utils.

For example:


Features#

Tax Settings Per Region#

Set different tax settings for each tax region.

Code
1const taxRegion = await taxModuleService.createTaxRegions({2  country_code: "us",3})

Tax Rates and Rules#

Manage each region's default tax rates and override them with conditioned tax rates.

Code
1const taxRates = await taxModuleService.createTaxRates([2  {3    tax_region_id: "txreg_123",4    name: "Default tax rate",5    is_default: true,6    rate: 10,7  },8  {9    tax_region_id: "txreg_123",10    name: "Shirt product type",11    is_default: false,12    rate: 15,13    rules: [14      {15        reference: "product_type",16        reference_id: "ptyp_1",17      },18    ],19  },20])

Retrieve Cart's Tax Lines#

Calculate and retrieve the tax lines of a cart's line items and shipping methods with tax providers.

Code
1const taxLines = await taxModuleService.getTaxLines(2  [3    {4      id: "cali_123",5      product_id: "prod_123",6      unit_price: 1000,7      quantity: 1,8    },9    {10      id: "casm_123",11      shipping_option_id: "so_123",12      unit_price: 2000,13    },14  ],15  {16    address: {17      country_code: "us",18    },19  }20)

You can use different tax providers for each region to handle tax-line retrieval differently.


Configure Tax Module#

Refer to this documentation for details on the module's options.

Was this page helpful?
Edit this page