burtds / laravel-vatnumber-checker
A simple VAT Number checker package for Laravel.
Installs: 23 473
Dependents: 0
Suggesters: 0
Security: 0
Stars: 45
Watchers: 1
Forks: 5
Open Issues: 0
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.2
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.13
- orchestra/testbench: ^8.13|^9.0
- pestphp/pest: ^2.0
- spatie/laravel-ray: ^1.33
README
About laravel-vatnumber-checker
A small package that allows you to easily retrieve information associated with a VAT number. Verification of validity, company name, and address of the company is only one api call away.
How to use laravel-vatnumber-checker
Installation
You can install the package via composer:
composer require burtds/laravel-vatnumber-checker
Afterwords, you're able to fetch your desired information.
Usage
This packages uses an API provided by the European Commission called "VIES".
We'll need to import the Facade of this package on top of your file.
use Burtds\VatChecker\Facades\VatChecker
Once that is done, you'll be able to use the provide functions. For this example we're using the VAT Number of Vulpo BV.
$validVatNumber = '0749617582' // Vulpo BV's VAT number // returns a raw response of the European Commission's API VatChecker::getRawVatInstance('BE', $validVatNumber); // returns the validity of a VAT number VatChecker::isVatValid('BE', $validVatNumber); // returns the company name related to the VAT number VatChecker::getCompanyName('BE', $validVatNumber); // returns the company address related to the VAT number VatChecker::getCompanyAddress('BE', $validVatNumber);
There is also single parameter support for all methods.
$validVatNumber = 'BE0749617582' // Vulpo BV's VAT number // returns a raw response of the European Commission's API VatChecker::getRawVatInstance($validVatNumber); // returns the validity of a VAT number VatChecker::isVatValid($validVatNumber); ...
Validation Rule
This package also provides a simple validation rule.
use Burtds\VatChecker\Rules\VatNumber; $validatedData = $request->validate([ 'vat_number' => ['required', new VatNumber], ]);
This example will pass the validation when the provided vat number is valid. If not, it will return a neat error message.
Testing & Code Formatting
For testing you can run:
composer test
For formatting the code using Laravel Pint you can run:
composer format
Security Vulnerabilities
If you discover a security vulnerability within this package, please send me an e-mail via bert@bert.gent. I'll get back at you as soon as possible.
Credits
License
This package is open-sourced software licensed under the MIT license.