# EU-VAT Validation Function
# Introduction
Chargebee validates VAT Number by sending a validation request to VAT Information Exchange System (VIES (opens new window)), a search engine owned by the European Commision.
# Integration
# Inserting Chargebee.js script in your application
Include the following script in your HTML page. You need to do this only once per page
<script src="https://js.chargebee.com/v2/chargebee.js"></script>
1
# Initializing Chargebee instance
Inside your JavaScript code, initialize chargebee once the page is loaded and get 'chargebee instance' object. This object is used to invoke the various functions.
let cbInstance = Chargebee.init({
site: "mannar-test",
publishableKey: 'test_Zxm7GgZmjdHO3tT8icuGaYkYBvH0QNRr4'
});
// You can access the above created instance anywhere using the following code
let cbInstance = Chargebee.getInstance();
1
2
3
4
5
6
7
2
3
4
5
6
7
# Initialize Chargebee.js functions
Use the load
method to load and initialize the functions module. Then, for instance, use the estimates.createSubscriptionEstimate
to invoke the create subscription estimate function.
let cbInstance = Chargebee.getInstance();
charegbeeInstance.load('functions').then(() => {
// your code here
});
1
2
3
4
2
3
4
# Using the function
# Sample code
let cbInstance = Chargebee.getInstance();
charegbeeInstance.load('functions').then(() => {
const payload = {...}
cbInstance.vat.validateVat(payload).then(data => {
// Your code here
}).catch(err => {
// Your code here
})
});
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# Parameters
country
String 2-letter ISO 3166 alpha-2 country code
vat_number
String EU VAT Number
# Response
# Sample Response
{
"status": "INVALID",
"message": "Customer VAT number is invalid"
}
1
2
3
4
2
3
4
# Response Properties
status
:
Validation Status | Description |
---|---|
VALID | VAT Number validation was successful and the number is valid |
INVALID | VAT Number validation failed. |
UNDETERMINED | No response from VIES, or other errors. |
message
: Describes the response received from VIES.