PHP code example of jairforo / php-vat-checker

1. Go to this page and download the library: Download jairforo/php-vat-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jairforo / php-vat-checker example snippets


use JairForo\VATChecker\Exceptions\VATCheckerException;
use JairForo\VATChecker\VATChecker;

try {
    /** @var bool $isValid */
    $isValid = (new VATChecker())->isValid($countryCode, $vatNumber);
} catch (VATCheckerException $exception) {
    // Something went wrong during the request.
}

use JairForo\VATChecker\Exceptions\InvalidVATException;
use JairForo\VATChecker\Exceptions\VATCheckerException;
use JairForo\VATChecker\Objects\VATResponse;
use JairForo\VATChecker\VATChecker;

try {
    /** @var VATResponse $vatResponse */
    $vatResponse = (new VATChecker())->check($countryCode, $vatNumber);
    
    print_r($vatResponse);
} catch (VATCheckerException $exception) {
    if ($exception instanceof InvalidVATException) {
        // The VAT information was invalid.
        return;
    }
    
    // Something else went wrong during the request.
}
bash
composer 

{
  "country_code": "NL",
  "vat_number": "611989431B01",
  "requested_at": {
    "date": "2020-02-02 00:00:00.000000",
    "timezone_type": 1,
    "timezone": "+00:00"
  },
  "company_name": "UNICORN B.V.",
  "address": "UNICORN STREET 007",
  "zipcode": "1108DH",
  "city": "AMSTERDAM",
  "original_address": "UNICORN STREET 007 1108DH AMSTERDAM"
}