VIES VAT number validation

Issue

How to incorporate a form on our website to validate the VIES? I find information to validate it through the website of the European Union.

http://ec.europa.eu/taxation_customs/vies/vieshome.do

And what interest me is validate directly from the form of payment data from my website.

Solution

This websites sends an ordinary HTML form to a server.

The simplest solution is to pass the params in the URL and use file_get_contents to get the response.

The response can then be parsed to extract the information you want. Not tested, but shows the idea:

$country1 = 'PL';
$country2 = 'PL';
$vatnum1 = '123456';
$vatnum2 = '789012';

//Prepare the URL
$url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms='.$country1.'&iso='.$country1.'&vat='.$vatnum1.'&name=&companyType=&street1=&postcode=&city=&requesterMs='.$country2.'&requesterIso='.$country2.'&requesterVat='.$vatnum2.'&BtnSubmitVat=Verify';

$response = file_get_contents($url);
// Do sth with the response
echo $response;

Answered By – Mariusz Jamro

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published