-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
example.php
31 lines (24 loc) · 1.07 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* @author Pierre-Henry Soria <[email protected]>
* @copyright (c) 2017-2023, Pierre-Henry Soria. All Rights Reserved.
* @license GNU General Public License; <https://www.gnu.org/licenses/gpl-3.0.en.html>
*/
require 'src/autoloader.php';
use PH7\Eu\Vat\Provider\Europa;
use PH7\Eu\Vat\Validator;
$sEuVatNumber = '0472429986'; // EU VAT number
$sEuCountryCode = 'BE'; // EU two-letter country code
$oVatValidator = new Validator(new Europa, $sEuVatNumber, $sEuCountryCode);
if ($oVatValidator->check()) {
$sRequestDate = $oVatValidator->getRequestDate();
// Optional - explicitly format the date to d-m-Y format
$sFormattedRequestDate = (new DateTime)->format('d-m-Y');
echo 'Business Name: ' . $oVatValidator->getName() . '<br />';
echo 'Address: ' . $oVatValidator->getAddress() . '<br />';
echo 'Request Date: ' . $sFormattedRequestDate . '<br />';
echo 'Member State: ' . $oVatValidator->getCountryCode() . '<br />';
echo 'VAT Number: ' . $oVatValidator->getVatNumber() . '<br />';
} else {
echo 'Invalid VAT number';
}