billingserv/uk-vat-validator

A Composer package to validate UK VAT numbers using the HMRC API.

v1.0.3 2025-03-02 21:53 UTC

This package is auto-updated.

Last update: 2025-07-30 22:55:09 UTC


README

BillingServ

VAT Validator is a Composer package developed by BillingServ that allows UK businesses to verify VAT numbers using the HMRC VAT API. This package supports both live and sandbox environments.

Features

  • Verify UK VAT numbers.
  • Obtain a consultation number when a business needs to verify a customer's VAT number.
  • Supports live and sandbox environments.
  • Fully open-source and free to use.

Installation

Requirements

  • PHP 8.0+
  • Composer
  • Laravel

Install via Composer

composer require billingserv/uk-vat-validator

Publish Configuration (Laravel Only)

php artisan vendor:publish --tag=config

Configuration

After installation, add your HMRC API credentials to your .env file:

HMRC_CLIENT_ID=your-client-id
HMRC_CLIENT_SECRET=your-client-secret
HMRC_GRANT_TYPE=client_credentials
HMRC_SCOPE=read:vat
HMRC_USE_SANDBOX=true  # Set to false for live mode

Usage

1. Verify a VAT Number

use VatValidator\VatValidatorService;

$vatService = app(VatValidatorService::class);
$result = $vatService->verifyVatNumber('553557881');
print_r($result);

2. Obtain a Consultation Number

$consultation = $vatService->getConsultationNumber('553557881', '948561936944');
print_r($consultation);

Live and Sandbox Mode

Set HMRC_USE_SANDBOX=true in the .env file to enable sandbox mode. If set to false, the package will use live mode automatically.

Testing

To run tests, use PHPUnit:

vendor/bin/phpunit

License

This package is open-source and available for everyone to use under the MIT License.

Credits

Developed by BillingServ. Contributions are welcome!

Support

For issues, please open an issue on GitHub or contact support@billingserv.com.