Search…
Tax Identifier element
Create a Tax Identifier collection element that will automatically collect and validate tax identifiers.
With DigitalRiver.js, you can create a Tax Identifier collection element that will automatically collect and validate the tax identifier formats for a specific transaction, which can be styled and placed on your page like other DigitalRiver.js elements.

Creating a Tax Identifier element

To create a Tax Identifier element, use the createElement function exposed through the Digital River object. This object follows the same pattern and allows for the same custom classes and styles as other elements.
The Tax Identifier element also requires an additional taxIdentifier object which accepts:
Attribute
Description
Required/Optional
sessionId
The Payment Session ID. If used, the response will automatically filter to be applicable to the specific transaction.
Required if country and sellingEntity are not provided.
country
The country code that represents the expected billing and/or shipping address of the customer.
Required if sessionId is not provided.
sellingEntity
The Digital River selling entity which is facilitating the transaction.
Optional if sessionId is not provided. If not provided, a default entity will be selected.
type
Either "individual" or "business"
Optional. If the type is provided, the rendered inputs will be limited to the specified type.
Example
1
var options = {
2
taxIdentifier: {
3
country: "IT"
4
},
5
classes: {
6
base: "DRElement",
7
complete: "taxId-complete",
8
empty: "taxId-empty",
9
focus: "taxId-focus",
10
invalid: "taxId-invalid"
11
},
12
style: {
13
base: {
14
color: "#495057",
15
height: "35px",
16
fontSize: "1rem",
17
fontFamily: "apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif",
18
":hover": {
19
color: "#ccc",
20
}
21
},
22
complete: {
23
":hover": {
24
color: "#495057",
25
},
26
},
27
empty: {
28
":hover": {
29
color: "#495057",
30
},
31
},
32
focus: {
33
":hover": {
34
color: "#495057",
35
},
36
},
37
invalid: {
38
color: "red"
39
}
40
}
41
};
42
43
let taxIdentifier = digtialriver.createElement("taxidentifier", options);
44
Copied!

Tax Identifier element functions

Learn how to trigger Tax Identifier element functions.
To create a Tax Identifier element, use the createElement function exposed through the Digital River object. This object follows the same pattern and allows for the same custom classes and styles as other elements.
The Tax Identifier element also requires an additional taxIdentifier object which accepts:
Attribute
Description
Required/Optional
sessionId
The Payment Session ID. If used, the response will automatically filter to be applicable to the specific transaction.
Required if country and sellingEntity are not provided.
country
The country code that represents the expected billing and/or shipping address of the customer.
Required if sessionId is not provided.
sellingEntity
The Digital River selling entity which is facilitating the transaction.
Optional if sessionId is not provided. If not provided, a default entity will be selected.
Example
1
var options = {
2
taxIdentifier: {
3
country: "IT"
4
},
5
classes: {
6
base: "DRElement",
7
complete: "taxId-complete",
8
empty: "taxId-empty",
9
focus: "taxId-focus",
10
invalid: "taxId-invalid"
11
},
12
style: {
13
base: {
14
color: "#495057",
15
height: "35px",
16
fontSize: "1rem",
17
fontFamily: "apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif",
18
":hover": {
19
color: "#ccc",
20
}
21
},
22
complete: {
23
":hover": {
24
color: "#495057",
25
},
26
},
27
empty: {
28
":hover": {
29
color: "#495057",
30
},
31
},
32
focus: {
33
":hover": {
34
color: "#495057",
35
},
36
},
37
invalid: {
38
color: "red"
39
}
40
}
41
};
42
43
let taxIdentifier = digtialriver.createElement("taxidentifier", options);
44
Copied!

Tax Identifier element events

1
taxIdentifier.on("event", handler);
Copied!
Use this functionality to listen to events that you can use to build and enhance your purchase flow.
Event
Triggered When
ready
The created element is loaded and ready to accept an update request.
focus
The element has gained focus.
blur
The element has lost focus.
change
The element's state has changed.

Ready

A Ready event triggers when a Tax Identifier has loaded and is available to take an update() call.
Example
1
taxIdentifier.on("ready", function(event) {
2
//tax identifier element is ready and can accept an update call
3
});
Copied!
Key
Value
elementType
taxidentifier
hasTaxIdentifier
Whether there are applicable tax identifiers. If true, you should mount and display the tax identifier element. If false, you should not mount the element.
businessTaxIdentifierRequired
Whether a business tax identifier is required for this transaction or country/entity combination.
individualTaxIdentifierRequired
Whether an individual tax identifier is required for this transaction or country/entity combination.
Ready Response object
1
{
2
elementType: "taxidentifier",
3
hasTaxIdentifier: true,
4
businessTaxIdentifierRequired: true,
5
individualTaxIdentifierRequired: true
6
}
7
Copied!

Focus

A Focus event triggers when the Tax Identifier element gains focus.
Example
1
taxIdentifier.on("focus", function(event) {
2
//receive the event
3
}
Copied!
Focus Response object
1
{
2
elementType: "taxidentifier"
3
}
Copied!

Blur

A Blur event triggers when the Tax Identifier element loses focus.
Example
1
taxIdentifier.on("blur", function(event) {
2
//receive the event
3
}
Copied!
Blur Response object
1
{
2
elementType: "taxidentifier"
3
}
Copied!

Change

A Change event triggers when the Tax Identifier element changes state.
Example
1
taxIdentifier.on("change", function(event) {
2
console.log("tax identifier change", event);
3
});
Copied!
Key
Value Description
complete
Whether the element is in a complete state. The value entered in the field matches a valid identifier format.
empty
Whether the element is empty.
elementType
The element type.
error
An error object (if applicable).
identifier
Information about the identifier being provided. This object will contain a value, type, and customerType.
Change Response object
1
{
2
complete: true,
3
empty: false,
4
elementType: "taxidentifier",
5
error: null,
6
identifier: {
7
"value": 'IT11223433',
8
"type": "it_natural",
9
"customerType": "individual"
10
}
11
}
12
Copied!
If an error is detected, a Change error object is returned.
Invalid Change Response Object
1
{
2
complete: true,
3
empty: false,
4
elementType: "taxidentifier",
5
"error": {
6
"type": "validation_error",
7
"code": "invalid_tax_identifier",
8
"message": "Your tax identifier is invalid."
9
},
10
identifier: {
11
"value": null,
12
"type": "it_natural",
13
"customerType": "individual"
14
}
15
}
16
Copied!