Skip to content

se6wagner/apex-VIES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apex-VIES

apex-VIES is a simple force.com API for validating EU VAT IDs and Numbers against the VAT Information Exchange System of the European Union.

A simple UI for running the validation is provided via VIESVATCheck.page (==> VIESVATcheck.component).

Make sure add VIES Webservice Endpoint to your remote settings (Remote Settings config is contained in the src folder)

HOW - TO

API accepts Country Code (e.g. DE for Germany, IT for Italy, ...) and VAT number instead of the complete VAT Id as well. In addition any whitespace characters will be removed automatically as well.

Integer validation

VIES.isValidVATID() methods return a simple integer you can use for validation. Return values

  • 0 = validation failed
  • 1 = valid VAT ID
  • 2 = invalid VAT ID

Basic Example

String vatID = 'DE123456789';
Integer result = VIES.isValidVATID(String vatID);

Extended Example

String vatID = 'DE123456789';
Integer result = VIES.isValidVATID(String vatID);

if(result == 0){
	// HANDLE FAILURES
}
if(result == 1){
	// HANDLE VALID VAT IDs
}
else if(result == 2){
	// HANDLE INVALID VAT IDs
}

Using VIES.VATCheck Data Type

In addition to the simple Integer validation, apex-VIES provides VIES.VATCheck data type wrapping up detailed information like Company Name & Address (if returned by the WebService), Status Codes, Messages ...

String vatID = 'DE123456789';
VIES.VATCheck result = VIES.checkVAT(vatID);

Review VIESTest class for more details.

View VIES Webservice FAQ for detailled information about VIES Service

About

EU VAT Number Validation for force.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published