Tax & VAT Compliance
Relevant source files
The following files were used as context for generating this wiki page:
Polar operates as a Merchant of Record (MoR), which means it assumes the legal liability for capturing, calculating, and remitting international sales taxes (VAT, GST, US Sales Tax) on behalf of its users. This infrastructure allows developers to sell digital products globally without the administrative burden of registering with local tax authorities in multiple jurisdictions.
The system integrates real-time tax calculation services (primarily via Stripe Tax) and provides validation logic for business-to-business (B2B) transactions, including EU VAT reverse charge handling.
Sources: clients/apps/web/src/components/Landing/resources/MORPage.tsx:43-52, clients/apps/web/src/components/Landing/comparison/PolarStripePage.tsx:21-25
Architecture Overview
The Tax & VAT compliance system is divided between the backend business logic and the external integrations that perform heavy lifting for calculations.
The backend uses a modular approach where TaxService acts as the primary coordinator for tax-related operations.
Sources: server/polar/tax/service.py, AGENTS.md:120-125
Merchant of Record (MoR) Model
As a Merchant of Record, Polar is the reseller of the digital goods. This structural difference from a standard Payment Service Provider (PSP) shifts tax liability from the individual developer to the platform.
Key Compliance Features
| Feature | Description |
|---|---|
| Capturing | Automated collection of tax (e.g., 25% VAT for a Swedish consumer) during checkout. |
| Remitting | Filing and paying captured taxes to local authorities on behalf of the seller. |
| B2B Reverse Charge | Identifying business customers via Tax IDs to apply 0% tax where applicable. |
| Global Thresholds | Monitoring and handling varied registration rules (e.g., upfront in UK/EU vs. $500k in Texas). |
Sources: clients/apps/web/src/components/Landing/resources/MORPage.tsx:143-162, clients/apps/web/src/components/Landing/comparison/PolarStripePage.tsx:180-195
Tax ID Validation
To support B2B sales and reverse charge mechanisms, Polar validates customer Tax IDs. The system leverages the stdnum library to ensure IDs match the required format for various countries.
Validation Logic
Validators are implemented as classes with a standard interface. They perform structural checks and, where possible, checksum validation.
class TaxIDValidator(Protocol):
def validate(self, value: str, country: str) -> bool:
...
Sources: server/polar/tax/tax_id.py:15-30
Supported Validator Examples
| Validator Class | Region/Country | Standard Used |
|---|---|---|
EUVATValidator | European Union | stdnum.eu.vat |
GBVATValidator | United Kingdom | stdnum.gb.vat |
USTINValidator | United States | Structural (9 digits) |
CHVATValidator | Switzerland | stdnum.ch.vat |
Sources: server/polar/tax/tax_id.py:35-150
Stripe Tax Integration
Polar utilizes Stripe Tax for real-time calculation of tax rates based on the customer's location and the product's tax category.
Calculation Flow
The StripeTaxCalculator translates Polar's internal order and customer data into Stripe-compatible structures to retrieve a TaxCalculation object.
Implementation Detail: Tax Categories
Stripe requires specific tax codes (e.g., txcd_10000000) to determine the taxability of a product. Polar maps its product types to these codes to ensure accuracy for software licenses, SaaS, and digital downloads.
Sources: server/polar/tax/calculation/stripe.py:50-65
Developer Implementation Guidelines
When extending the tax system, developers must follow strict conventions to maintain compliance accuracy:
- Minimal Validators: Tax ID validators should remain simple, delegating complexity to the
stdnumlibrary. - Domain Object Preference: Service methods should accept full domain objects (like
OrderorCustomer) rather than IDs to ensure the calculator has access to all necessary metadata (e.g., address, tax ID). - Async Patterns: All external API calls for tax calculation or ID validation must use proper async/await patterns.
Sources: AGENTS.md:120-130, AGENTS.md:155-165
Summary
The Tax & VAT Compliance module is a critical component of Polar's value proposition as a Merchant of Record. By centralizing validation in tax_id.py and calculation in calculation/stripe.py, the platform automates the complex legal requirements of global digital commerce, ensuring that sellers remain compliant with international tax laws without manual intervention.