API reference
Search
K
Links

External tax calculators

The external tax calculator object and the allowed CRUD operations on the related resource endpoint
External tax calculators let you delegate tax calculation logic to an external service (either just different from the ones supported out-of-the-box by Commerce Layer or completely custom). This way, you can use the order payload to compute your own logic and return the tax rate to be applied to the order.
To create an external tax calculator choose a meaningful name that helps you identify it within your organization and specify the endpoint you have configured externally. Whenever the tax calculation is fired, Commerce Layer triggers a POST request to the tax calculator URL endpoint, sending the order payload (including its line items and their items) in the request body. The external service response (or error) must match the format described in this example.
External tax calculators are subject to a circuit breaker check: if the call to your external endpoint fails consecutively more than 30 times, the circuit breaker opens and any further request to the resource will be skipped. You can check the circuit breaker current status by fetching the circuit_state and circuit_failure_count attributes or manually reset it by passing the _reset_circuit trigger (the circuit is anyway automatically reset anytime a call to your external endpoint succeeds before reaching the counter's threshold).
How-to
Check the related guide for any additional info on how to configure your external tax calculation engine and integrate it with Commerce Layer.