# Tax calculation

Tax calculation in the Salesforce Lightning app is segregated into two separate layers. The inner layer, the `DRB2B_CartTaxCalculations` class, contains both the API connector and messaging functionality.&#x20;

Use the outer layer, `DRB2B_TaxCalculationService` class, as a global service that can be used as a stand-alone integration. This service has a `startCartProcessAsync`method which takes `CartId (id)`and `sfdc_checkout.IntegrationInfo` which returns a `ResponseModel`custom apex object.&#x20;

After making the API call to Digital River, the service uses the checkout service to store the response in the `CartTax` object. The `DRB2B_TaxCalculationService` service is used in both synchronous and asynchronous checkout flows.

Refer to the following example to understand how to use tax calculation in an the asynchronous checkout context:

<figure><img src="/files/jpr47cBTc3UQqxI0bb2N" alt=""><figcaption></figcaption></figure>

As an alternative to the previous example, you can call the tax calculation routine yourself. Refer to the following example to understand how the service can be called in a stand-alone use case:

<figure><img src="/files/HvD8eZ4p644xxbeP6zXI" alt=""><figcaption></figcaption></figure>

The following table provides details on the input parameters used in tax calculations:

| Input variable name | Description                                                                                                                                                                                                                             |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cartId              | <p>Type: Id</p><p></p><p>Identifies the cart in the checkout session.</p>                                                                                                                                                               |
| jobInfo             | <p>Type: <code>sfdc\_checkout.IntegrationInfo</code></p><p></p><p>Used in cases of an asynchronous checkout process used to load exceptions and related messages into a session. This can be NULL when used as stand-alone process.</p> |

The following table provides information on the output parameters used in tax calculations:

| Variable name         | Description                                                                                                                                                                                                                                            |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ResponseModel.status  | <p>Type: String</p><p></p><p>Possible values:<br></p><p>“Error” – This is passed when an exception or validation error occurs because the tax calculation cannot completed.<br></p><p>“Success” – This is passed when tax calculation was success.</p> |
| ResponseModel.message | <p>Type: String</p><p></p><p>Provides the response string message passed on when there is an exception.</p>                                                                                                                                            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalriver.com/salesforce-lightning/salesforce-lightning-b2b-commerce-app-1.6/extend-the-salesforce-lightning-app/tax-calculation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
