> Documentation index: [Saleor](/llms.txt) · [This section](/developer/llms.txt)
> Source: https://docs.saleor.io/developer/app-store/apps/avatax/architecture

# AvaTax App Architecture

<a id="webhook-events"></a>

## Webhook events

The AvaTax App uses the following webhook events for tax reporting and calculations:

-   [`OrderCalculateTaxes`](/api-reference/taxes/objects/calculate-taxes.md)
-   [`CheckoutCalculateTaxes`](/api-reference/taxes/objects/calculate-taxes.md)
-   [`OrderConfirmed`](/api-reference/orders/objects/order-confirmed.md)

<a id="calculating-taxes"></a>

## Calculating taxes

Calculating taxes using external tax providers happens through a synchronous [`CalculateTaxes`](/api-reference/taxes/objects/calculate-taxes.md) webhook event. A [synchronous webhook](/developer/extending/webhooks/synchronous-events/overview.md) awaits a response from the app before continuing.

While the app is waiting for the values of the calculated taxes, the sequence of actions is as follows:

```mermaid
sequenceDiagram
    CalculateTaxes->>+App: Send webhook payload
    App-->>-AppMetadata: Fetch app configuration from metadata
    AppMetadata-->>+App: Return configuration
    App-->>+TaxProvider: Use configuration & webhook payload to create transaction
    TaxProvider-->>-App: Return created transaction
    App-->>-CalculateTaxes: Transform the transaction and return as webhook response
```

During tax calculation, the transactions on the AvaTax side are not recorded. They will not appear in the tax provider's dashboard.

<a id="recording-transactions"></a>

## Recording transactions

Once the order is finalized, we want to send a transaction to the tax provider for tax reporting. This is done through [asynchronous webhook](/developer/extending/webhooks/asynchronous-events.md) events that fire on different order lifecycle actions.

```mermaid
sequenceDiagram
    OrderConfirmed->>+App: Send webhook payload
    App-->>-AppMetadata: Fetch app configuration from metadata
    AppMetadata-->>+App: Return configuration
    App-->>+TaxProvider: Use configuration & webhook payload to create transaction
    TaxProvider-->>-App: Return created transaction
```

Committing transactions will happen during the transaction creation based on the provider configuration.

For example, the transaction is committed on `OrderConfirmed` if the `isAutocommit` flag is set to `true` in the configuration.

<a id="canceling-transactions"></a>

## Canceling transactions

```mermaid
sequenceDiagram
    OrderCancelled->>+App: Send webhook payload
    App-->>-AppMetadata: Fetch app configuration & transaction id from metadata
    AppMetadata-->>+App: Return configuration & transaction id
    App-->>+TaxProvider: Use configuration & webhook payload to cancel/void transaction
    TaxProvider-->>-App: Return
```
