richweber-technology / vatfyi-sdk-php
VAT.fyi API tools
Installs: 2 657
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0
This package is auto-updated.
Last update: 2024-12-19 02:19:15 UTC
README
Installing SDK
The recommended way to install SDK is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of SDK:
php composer.phar require richweber-technology/vatfyi-sdk-php
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update SDK using composer:
php composer.phar update
Use
use RichweberTechnology\vatfyi\Client; use RichweberTechnology\vatfyi\components\Company; use RichweberTechnology\vatfyi\components\VatNumber; $client = new Client('YOUR_API_KEY'); $checker = new VatNumber($client); $check = $checker->checkVatNumber('EE102001059'); echo $check . PHP_EOL; echo $checker->isSuccess() . PHP_EOL; echo $checker->isValidNumber() . PHP_EOL; echo $checker->getErrorDescription() . PHP_EOL; $company = $checker->getCompany(); if ($company instanceof Company) { echo $company->getCompanyName() . PHP_EOL; echo $company->getCountryCode() . PHP_EOL; echo $company->getCompanyAddress() . PHP_EOL; echo $company->getVatNumber() . PHP_EOL; }
use RichweberTechnology\vatfyi\Client; use RichweberTechnology\vatfyi\components\Amount; use RichweberTechnology\vatfyi\components\RateDto; use RichweberTechnology\vatfyi\components\VatRate; $client = new Client('YOUR_API_KEY'); $dto = new RateDto('EE', 123.45); $checker = new VatRate($client); $check = $checker->getVatRate($dto); echo $check . PHP_EOL; echo $checker->isSuccess() . PHP_EOL; echo $checker->isVatNumberConfirmed() . PHP_EOL; echo $checker->isVatNumberFailed() . PHP_EOL; echo $checker->getVatNumberFailDescription() . PHP_EOL; echo $checker->getErrorDescription() . PHP_EOL; $company = $checker->getAmount(); if ($company instanceof Amount) { echo $company->getVAT() . PHP_EOL; echo $company->getAmount() . PHP_EOL; echo $company->getVatAmount() . PHP_EOL; echo $company->getTotalAmount() . PHP_EOL; }