goosfraba/vies-eu-vat-checker

Verifies the validity of a VAT number issued by any Member State

1.0.0 2019-10-21 19:28 UTC

This package is auto-updated.

Last update: 2024-04-22 17:41:01 UTC


README

Verifies the validity of a VAT number issued by any Member State. The library provides a handy API implementation to connect to European Commission SOAP service.

Installation

The best way to install the library is using composer

composer require goosfraba/vies-eu-vat-checker

Usage

Creating an instance of the API

To create a production API instance use the following snippet:

<?php
use Goosfraba\ViesEuVatChecker\CheckVatSoapApi;

$api = CheckVatSoapApi::create();

To create a test API instance use the following snippet:

<?php
use Goosfraba\ViesEuVatChecker\CheckVatSoapApi;
use Goosfraba\ViesEuVatChecker\Wsdl;

$api = CheckVatSoapApi::create(Wsdl::test());

VAT Check service

<?php
use Goosfraba\ViesEuVatChecker\CheckVatSoapApi;
use Goosfraba\ViesEuVatChecker\CheckVatRequest;

$response = $api->checkVat(new CheckVatRequest("LU", "20260743")); // CheckVatResponse

$response->isValid(); // bool - is given VAT number valid
$response->countryCode(); // string - requested number country code
$response->vatNumber(); // string - requested VAT number
$response->requestDate(); // \DateTime - request date
$response->name(); // string - company's name
$response->address(); // string - company's address

Tests

composer install
./vendor/bin/phpunit