Skip to content

A small laravel package that allows you to easily retrieve information associated with a VAT number.

License

Notifications You must be signed in to change notification settings

BurtDS/laravel-vatnumber-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Version on Packagist GitHub Workflow Status Total Downloads

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 [email protected]. I'll get back at you as soon as possible.

Credits

License

This package is open-sourced software licensed under the MIT license.

About

A small laravel package that allows you to easily retrieve information associated with a VAT number.

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages