Skip to content

Configure Tax Calculation

⏱ 20 minutes intermediate
📜Corecommerce

Tax compliance is not optional. Every sale must collect the correct tax based on the product type, the customer’s location, and applicable exemptions. Miscalculating tax leads to audit risk, penalties, and customer disputes. Commerce supports both built-in tax tables and external tax providers so you can handle domestic and international tax scenarios accurately.

This guide covers setting up tax categories, configuring a tax provider, managing exemptions, and handling international tax rules.

  1. Define tax categories for your products
  2. Configure tax jurisdictions and rates
  3. Integrate an external tax calculation provider
  4. Handle tax exemptions and international rules

Tax categories group products by their tax treatment. Different product types are taxed at different rates — clothing may be exempt in some states, while digital goods have special rules.

In the Commerce UI:

  1. Navigate to Commerce > Administration > Tax Categories
  2. Click Add Tax Category
  3. Enter a name (e.g., “Taxable Goods”, “Clothing”, “Digital Products”, “Food”)
  4. Assign the category to each variant on its properties tab
Assign tax categories to variants
csharp
using EPiServer;
using EPiServer.Commerce.Catalog.ContentTypes;

public class TaxCategoryService
{
    private readonly IContentRepository _contentRepo;

    public TaxCategoryService(
        IContentRepository contentRepo)
    {
        _contentRepo = contentRepo;
    }

    public void SetTaxCategory(
        ContentReference variantLink,
        string taxCategoryName)
    {
        var variant = _contentRepo
            .Get<VariationContent>(variantLink)
            .CreateWritableClone<VariationContent>();

        variant.TaxCategoryId =
            GetTaxCategoryId(taxCategoryName);

        _contentRepo.Save(variant,
            EPiServer.DataAccess.SaveAction.Publish,
            EPiServer.Security.AccessLevel.NoAccess);
    }

    private int GetTaxCategoryId(string name)
    {
        var taxCategories = CatalogTaxManager
            .GetTaxCategories();
        var row = taxCategories.TaxCategory
            .FirstOrDefault(tc => tc.Name == name);
        return row?.TaxCategoryId ?? 0;
    }
}

Tax jurisdictions define the geographic areas where specific tax rates apply. Set rates per jurisdiction and tax category combination.

In the Commerce UI:

  1. Navigate to Commerce > Administration > Taxes
  2. Create a jurisdiction (e.g., “California”, “EU-Standard”)
  3. Set the rate for each tax category within the jurisdiction
  4. Associate the jurisdiction with the appropriate markets
JurisdictionTax categoryRate
CaliforniaTaxable Goods7.25%
CaliforniaFood (unprepared)0%
New YorkTaxable Goods8.00%
New YorkClothing (under $110)0%
EU-StandardAll goods20%

For complex multi-jurisdiction tax calculation, integrate a tax service like Avalara or Vertex that maintains current rates and rules.

External tax provider integration
csharp
using EPiServer.Commerce.Order;

public class ExternalTaxCalculator : ITaxCalculator
{
    private readonly HttpClient _httpClient;

    public ExternalTaxCalculator(
        HttpClient httpClient)
    {
        _httpClient = httpClient;
    }

    public Money GetTaxTotal(
        IOrderGroup orderGroup,
        IMarket market, Currency currency)
    {
        var shipment = orderGroup
            .GetFirstShipment();
        var address = shipment.ShippingAddress;

        var request = new TaxRequest
        {
            Lines = shipment.LineItems
                .Select(li => new TaxLine
                {
                    ItemCode = li.Code,
                    Quantity = li.Quantity,
                    Amount = li.PlacedPrice
                        * li.Quantity,
                    TaxCode = GetTaxCode(li.Code)
                }).ToList(),
            Destination = new TaxAddress
            {
                City = address.City,
                State = address.RegionCode,
                PostalCode = address.PostalCode,
                Country = address.CountryCode
            }
        };

        var response = _httpClient
            .PostAsJsonAsync(
                "https://api.tax-provider.com/calculate",
                request)
            .GetAwaiter().GetResult();

        var result = response.Content
            .ReadFromJsonAsync<TaxResponse>()
            .GetAwaiter().GetResult();

        return new Money(result.TotalTax, currency);
    }

    private string GetTaxCode(string variantCode)
    {
        // Map variant to tax provider's tax code
        return "P0000000";
    }
}

Tax exemptions apply to specific customers (resellers, nonprofits) or product types. International sales may require VAT handling or reverse charge mechanisms.

Exemption scenarios:

ScenarioImplementation
Reseller exemptionStore the customer’s resale certificate; skip tax on their orders
NonprofitVerify tax-exempt status; apply zero rate
Cross-border EUApply reverse charge for B2B; destination VAT for B2C
Digital goodsApply the tax rate of the customer’s country (EU MOSS rules)
IssueCauseFix
Tax showing as $0 on all ordersNo tax jurisdiction configured for the customer’s addressAdd jurisdictions matching your customers’ locations
Wrong tax rate appliedTax category not assigned to the variantVerify every variant has the correct tax category
External provider returns errorAPI credentials expired or service unavailableCheck credentials and implement a fallback to built-in tax tables
Exempt customer still charged taxExemption not applied to the customer profileVerify the customer’s exemption certificate is linked to their contact