Download the PHP package patrixshah-uk-vat-checker/hmrc-vat-check without Composer
On this page you can find all versions of the php package patrixshah-uk-vat-checker/hmrc-vat-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download patrixshah-uk-vat-checker/hmrc-vat-check
More information about patrixshah-uk-vat-checker/hmrc-vat-check
Files in patrixshah-uk-vat-checker/hmrc-vat-check
Package hmrc-vat-check
Short Description A Laravel package to check UK VAT numbers by using HMRC Goverment Portal. It's using VAT API version 2.0 with OAuth 2.
License MIT
Informations about the package hmrc-vat-check
HMRC UK VAT Check Laravel Package
A Laravel package to check UK VAT numbers using the HMRC VAT API. This package provides an easy way to integrate VAT number validation in your Laravel application.
Installation
You can install the package via composer. Run the following command:
Configuration
After installing the package, you need to publish the configuration file to customize your API credentials and endpoint URLs.
-
Step 1: Publish Configuration File Run the following Artisan command to publish the configuration file:
This command will create a hmrc_vat.php configuration file in your config directory.
-
Step 2: Set Environment Variables Next, you need to set the required environment variables in your .env file. Add the following lines to your .env file:
Replace the placeholders with your actual HMRC API credentials and URLs.
- Step 3: Clear Configuration Cache To ensure Laravel recognizes your new configuration, clear the configuration cache:
Usage
Once you have installed and configured the package, you can use it to check VAT numbers through an API endpoint.
Example API Usage The package provides an API endpoint that you can use to check a VAT number.
-
Step 1: Define the Route (Optional) If you want to define a custom route in your Laravel application, add the following to your routes/api.php file:
If the route is already defined in the package, you can skip this step.
-
Step 2: Make an API Request You can now make a POST request to the /api/vat/check endpoint with the VAT number:
-
Step 3: Handle the Response If the VAT number is valid, you will receive a JSON response like this:
If there is an error or the VAT number is invalid, you will receive a response like this:
Customization
Configuring HMRC API Credentials You can change the API credentials and other settings by modifying the config/hmrc_vat.php file
Make sure to update these values according to your needs and the environment you are working in.
Author
- Name: Pratik Shah
- LinkedIn: Pratik Shah
License
This package is open-source software licensed under the MIT License.