- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Tax Calculation with the Tax Provider
In this document, you’ll learn how tax lines are calculated and what a tax provider is.
Tax Lines Calculation#
Tax lines are calculated and retrieved using the getTaxLines method of the Tax Module’s main service. It accepts an array of line items and shipping methods, and the context of the calculation.
For example:
The context object is used to determine which tax regions and rates to use in the calculation. It includes properties related to the address and customer.
The example above retrieves the tax lines based on the tax region for the United States.
The method returns tax lines for the line item and shipping methods. For example:
Using the Tax Provider in the Calculation#
The tax lines retrieved by the getTaxLines
method are actually retrieved from the tax region’s provider.
A tax module provider whose main service implements the logic to shape tax lines. Each tax region has a tax provider.
The Tax Module provides a system
tax provider that only transforms calculated item and shipping tax rates into the required return type.