# Tax identifier component

The tax identifier component can collect a customer's tax identification number.

To use the component, you'll need to [create it](#creating-the-tax-identifier-component), [mount it](#mounting-the-tax-identifier-component), and [submit its data](#submitting-the-tax-identifier-component).

The following are some of the following types of tax identifiers the component collects:

{% tabs %}
{% tab title="VAT" %}
When the [checkout-session's](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics) [`customerType` ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics#customer-type)is `business` and the customer's country is Germany, the component collects a Value Added Tax (VAT) number.

<figure><img src="/files/E7hkyh7s2vDpuyZIQBid" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GST" %}
When the [checkout-session's](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics) [`customerType` ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics#customer-type)is `business` and the customer's country is Canada, the component collects a Goods and Services Tax (GST) identifier.

<figure><img src="/files/eIGZ787XIZhmCKE1Dr4M" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="UBN" %}
When the [checkout-session's](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics) [`customerType` ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics#customer-type)is `business` and the customer's country is Taiwan, the component collects a Unified Business Number (UBN).

<figure><img src="/files/q2B7ju8WRpfXChSu598I" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="RFC" %}
When the [checkout-session's](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics) [`customerType` ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions/checkout-sessions-basics#customer-type)is `business` and the customer's country is Mexico, the tax component collects a Registro Federal de Contribuyentes (RFC) number.

<figure><img src="/files/SEJjcnliOOwi22yxdU6j" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

If your site sells outside the United States, particularly in the European Union, you'll likely need to implement the tax identifier component. This is especially true if you allow customers to make purchases on behalf of a business entity (i.e., B2B transactions).

{% hint style="info" %}
If you know, before sending the [create checkout-session request](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions#drop-in-checkout-sessions), whether customers are purchasing as an individual or on behalf of a business, you can define `customerType`. Alternatively, by using the auto-collect customer type feature, you can configure the address component to get this information from customers
{% endhint %}

In some countries, customers must enter a tax identification number when making an eCommerce purchase. To access a list of these countries, refer to [Supported tax identifiers](/digital-river-api/integration-options/checkouts/creating-checkouts/tax-identifiers.md#supported-tax-identifiers).

In the `data` returned by [`onReady`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components/configuring-components.md#onready), you can use [`showTaxIdentifiers`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components/configuring-components.md#showtaxidentifiers) to determine whether the component must be displayed. Additionally, [`onChange`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components/configuring-components.md#onchange) allows you to determine when it's optional and required.

Once customers input a properly formatted value, Digital River creates a [tax identifier](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/tax-identifiers) and associates that object with the [checkout-session](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions). After the customer successfully makes payment and completes their purchase, Digital River adds that same `taxIdentifiers[]` to the [order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders).

You should be aware, however, that a [tax identifier](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/tax-identifiers) won't affect how an [order's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)taxes are calculated unless its [`state`](/digital-river-api/integration-options/checkouts/creating-checkouts/tax-identifiers.md#states-and-triggered-events) is `pending` or `verified`. For details, refer to [How we validate tax identifiers](/digital-river-api/integration-options/checkouts/creating-checkouts/tax-identifiers.md#how-we-validate-tax-identifiers).

## Creating the tax identifier component

To create an instance of the tax identifier component, pass `'taxidentifier'` to [`createComponent()`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components.md#createcomponent-componenttype).

```javascript
let taxIdentifierComponent;
...
taxIdentifierComponent = components.createComponent('taxidentifier');
```

## Mounting the tax identifier component

To attach the tax identifier component to your DOM, pass the `id` of its container to [`mount()`](/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components.md#mount-elementid).

```javascript
<div id="tax-identifier-container" style="display: block"></div>
...
taxIdentifierComponent.mount('tax-identifier-container');
```

## Submitting the tax identifier component

The tax identifier component exposes `done()`, which submits the customer's input and returns a boolean. It requires that you use the [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await) operator and, therefore, must be called inside an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).

```javascript
const taxIdentifierComponentStatus = await taxIdentifierComponent.done();
```

If `done()` returns `true`, then this indicates that (1) customers entered a properly formatted value and Digital River used it to create a [tax identifier](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/tax-identifiers) and associate that object with the [checkout-session](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/drop-in-checkout-sessions) or (2) customers entered an improperly formatted value (or nothing at all), but they're shopping in a country that gives them the option to supply a tax id number when making an eCommerce purchase but doesn't require it.

If `true`, your code can advance customers to the next stage in checkout.

A `false` value indicates that (1) the customer's country requires a tax ID number to make the purchase and (2) customers either didn't provide a value or it's incorrectly formatted, and, as a result, Digital River cannot create a [tax identifier](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/tax-identifiers).

If `false`, your application should contain logic that prevents customers from advancing to the next stage in the checkout.

In this case, the component prompts customers to re-enter a value and typically offers formatting assistance.

{% tabs %}
{% tab title="VAT" %}
The example help text is displayed when the customer's country is Germany, and they're checking out as a business entity.

<figure><img src="/files/EufwtIhZOkrr1KOSPiql" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="UBN/TIN" %}
The example help text is displayed when the customer's country is Taiwan and they're checking out as a business entity.

<figure><img src="/files/9djMLlCGdVsMJ4oXho22" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="RFC" %}
The example help text is displayed when the customer's country is Mexico and they are checking out as a business entity.

<figure><img src="/files/egej5Fc6UnrhUPyelzsS" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# 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/digital-river-api/developer-resources/digitalrivercheckout.js-reference/digitalrivercheckout-object/components/tax-identifier-component.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.
