owowagency / laravel-vatlayer
Laravel Vatlayer is a very small package which helps you connect your Laravel application with the Vatlayer API
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^6.0
- illuminate/support: 6.*|7.*
Requires (Dev)
- matthewbdaly/artisan-standalone: 0.0.*
- mockery/mockery: ~1.0
- orchestra/testbench: ^4.0
- orchestra/testbench-browser-kit: ^4.0
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^8.0
- psy/psysh: ^0.9.9
- sebastian/phpcpd: ^4.0
- squizlabs/php_codesniffer: ^3.4
- vimeo/psalm: ^3.5
This package is auto-updated.
Last update: 2024-10-29 06:11:51 UTC
README
Laravel Vatlayer is a very small package which helps you connect your Laravel application with the Vatlayer API.
Installation
Installation is very quick and easy. Install the package via Composer and you're ready to go.
composer require owowagency/laravel-vatlayer
Setup
The package requires an API key from the Vatlayer API. You can request one here. Once set up, you need to add the following config to your services.php
config file:
'vatlayer' => [ 'key' => env('VATLAYER_KEY'), 'encrypted' => env('VATLAYER_ENCRYPTED', false) ],
You can now set your API key in your .env
file. The encrypted
boolean indicates if the API request should be made over https or http. This depends on the subscription plan you're using. If you're using the free plan you should set this variable to false
, if you've a paid subscription, definitely set this variable to true
.
Usage
The package comes with a Facade helper to quickly call any of the methods. Currently the package only ships with two usable methods.
Execute a validate request
To check if the VAT number has a valid format, valid value and to receive the name and address of the company which belongs to the VAT number you should call the validate($vatNumber)
method.
$response = \Vatlayer::validate('NL123456789B01'); // The response looks like: $response = [ 'valid' => true, 'format_valid' => true, 'query' => 'NL123456789B01', 'country_code' => 'NL', 'vat_number' => '855020970B01', 'company_name' => 'OWOW PROJECTS B.V.', 'company_address' => ' FUUTLAAN 00014 UNIT E 5613AB EINDHOVEN ', ];
Check VAT number
To quickly check if a VAT number is valid use the isValidVatNumber($vatNumber)
method. This method returns a boolean to check if the number has a valid format and is a known European VAT number.
$valid = \Vatlayer::isValidVatNumber('NL123456789B01');