Validate European Union (EU) VAT code in PHP

/**
 * validate_VAT.
 *
 * @return mixed: bool (true if VAT is valid, false otherwise) on success, null otherwise
 */
function validate_VAT( $country_code, $vat_number ) {
	$client = new SoapClient( 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' );
	$result = $client->checkVat( array(
		'countryCode' => $country_code,
		'vatNumber'   => $vat_number,
	) );
	return ( isset( $result->valid ) ) ? $result->valid : null;
}

No comments yet.

Leave a Reply