PHPackages                             rocketfellows/vies-vat-validation-php-sdk-interface - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. rocketfellows/vies-vat-validation-php-sdk-interface

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

rocketfellows/vies-vat-validation-php-sdk-interface
===================================================

v1.2.0(2y ago)05192MITPHPPHP &gt;=7.4

Since Dec 3Pushed 2y agoCompare

[ Source](https://github.com/rocketfellows/vies-vat-validation-php-sdk-interface)[ Packagist](https://packagist.org/packages/rocketfellows/vies-vat-validation-php-sdk-interface)[ RSS](/packages/rocketfellows-vies-vat-validation-php-sdk-interface/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (2)

VIES VAT number validation php sdk interface
============================================

[](#vies-vat-number-validation-php-sdk-interface)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan Badge](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)[![Code Coverage Badge](./badge.svg)](./badge.svg)

The package provides VIES VAT number validation php sdk interface.

PHP sdk interface for VIES service for checking the validity of the VAT number. Services that implement this interface are must be designed to send a request and process a response from the VAT validation service, depending on the API (REST/SOAP etc.).

Implementations of this interface are provided in the rocketfellows repositories (either already or in the future).

For more information about VIES VAT number validation services see [https://ec.europa.eu/taxation\_customs/vies/#/technical-information](https://ec.europa.eu/taxation_customs/vies/#/technical-information).

Installation.
-------------

[](#installation)

```
composer require rocketfellows/vies-vat-validation-php-sdk-interface
```

Interface description.
----------------------

[](#interface-description)

### Interface contract.

[](#interface-contract)

---

- `VatNumberValidationServiceInterface` - sdk interface, return value type `VatNumberValidationResult`, input argument `VatNumber`;
- `VatNumber` - validated VAT;
- `VatNumberValidationResult` - validation result;

### Interface exceptions.

[](#interface-exceptions)

---

`InvalidInputServiceException` - exception for api error code `INVALID_INPUT`.
Description: `the provided CountryCode is invalid or the VAT number is empty`.

`ServiceUnavailableException` - exception for api error code `SERVICE_UNAVAILABLE`.
Description: `an error was encountered either at the network level or the Web application level, try again later`.

`MSUnavailableServiceException` - exception for api error code `MS_UNAVAILABLE`.
Description: `the application at the Member State is not replying or not available. Please refer to the Technical Information page to check the status of the requested Member State, try again later`.

`TimeoutServiceException` - exception for api error code `TIMEOUT`.
Description: `the application did not receive a reply within the allocated time period, try again later`.

`InvalidRequesterInfoServiceException` - exception for api error code `INVALID_REQUESTER_INFO`.

`VatBlockedServiceException` - exception for api error code `VAT_BLOCKED`.

`IPBlockedServiceException` - exception for api error code `IP_BLOCKED`.

`GlobalMaxConcurrentReqServiceException` - exception for api error code `GLOBAL_MAX_CONCURRENT_REQ`.
Description: `your Request for VAT validation has not been processed; the maximum number of concurrent requests has been reached. Please re-submit your request later or contact TAXUD-VIESWEB@ec.europa.eu for further information": Your request cannot be processed due to high traffic on the web application. Please try again later`.

`GlobalMaxConcurrentReqTimeServiceException` - exception for api error code `GLOBAL_MAX_CONCURRENT_REQ_TIME`.

`MSMaxConcurrentReqServiceException` - exception for api error code `MS_MAX_CONCURRENT_REQ`.
Description: `your Request for VAT validation has not been processed; the maximum number of concurrent requests for this Member State has been reached. Please re-submit your request later or contact TAXUD-VIESWEB@ec.europa.eu for further information": Your request cannot be processed due to high traffic towards the Member State you are trying to reach. Please try again later`.

`MSMaxConcurrentReqTimeServiceException` - exception for api error code `MS_MAX_CONCURRENT_REQ_TIME`.

`UnknownServiceErrorException` - exception thrown if it was not possible to understand what error code service returned.

`ServiceRequestException` - exception thrown if it was not possible to send a request to service (other errors).

`CountryCodeAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` country code attribute not found.

`RequestDateAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` request date attribute not found.

`ValidationFlagAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` validation flag attribute not found.

`VatNumberAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat number attribute not found.

`VatOwnerAddressAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat owner address attribute not found.

`VatOwnerNameAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat owner name attribute not found.

### Input arguments and return value.

[](#input-arguments-and-return-value)

---

`VatNumber` type description (validated VAT):

- `countryCode` - *string* - two-character country code, according to ISO 3166-1 standard;
- `vatNumber` - *string* - validated VAT number.

`VatNumberValidationResult` type description (validation result):

- `vatNumber` - *VatNumber* - validated VAT number;
- `requestDate` - *string* - request date;
- `isValid` - *bool* - validity flag;
- `name` - *null* | *string* - name;
- `address` - *null* | *string* - address.

Interface implementations.
--------------------------

[](#interface-implementations)

Implementations of this interface are provided in the [rocketfellows](https://github.com/orgs/rocketfellows/repositories) repositories (either already or in the future).

So far, VIES provides two services for validating the VAT number:

- Interactive web interface;
- SOAP web services API;
- REST web services API.

Vat number validation result factory.
-------------------------------------

[](#vat-number-validation-result-factory)

`rocketfellows\ViesVatValidationInterface\VatNumberValidationResultFactory` - a factory designed to create an instance of `rocketfellows\ViesVatValidationInterface\VatNumberValidationResult` from given raw data with required attributes existence check.

Factory functions:

- `public function createFromObject(stdClass $rawData): VatNumberValidationResult` - creates `VatNumberValidationResult` from `stdClass` object raw data;
- `public function createFromArray(array $rawData): VatNumberValidationResult` - creates `VatNumberValidationResult` from array raw data.

Functions throw next exceptions:

- `CountryCodeAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` country code attribute not found.
- `RequestDateAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` request date attribute not found.
- `ValidationFlagAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` validation flag attribute not found.
- `VatNumberAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat number attribute not found.
- `VatOwnerAddressAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat owner address attribute not found.
- `VatOwnerNameAttributeNotFoundException` - exception thrown if while creating instance of `VatNumberValidationResult` vat owner name attribute not found.

### Usage examples.

[](#usage-examples)

Creating `VatNumberValidationResult` from `stdClass` object raw data, where attribute names in raw data in camel case:

```
$factory = new VatNumberValidationResultFactory();

$vatNumberValidationResult = $factory->createFromObject(
    (object) [
        'countryCode' => 'DE',
        'vatNumber' => '12312312',
        'requestDate' => '2023-12-12 20:20:20',
        'valid' => true,
        'name' => 'fooBar',
        'address' => 'barFoo',
    ]
);

var_dump(sprintf('VAT country code: %s', $vatNumberValidationResult->getCountryCode()));
var_dump(sprintf('VAT number: %s', $vatNumberValidationResult->getVatNumber()));
var_dump(sprintf('Request date: %s', $vatNumberValidationResult->getRequestDateString()));
var_dump(sprintf('Is VAT valid: %s', $vatNumberValidationResult->isValid() ? 'true' : 'false'));
var_dump(sprintf('VAT holder name: %s', $vatNumberValidationResult->getName()));
var_dump(sprintf('VAT holder address: %s', $vatNumberValidationResult->getAddress()));
```

```
VAT country code: DE
VAT number: 12312312
Request date: 2023-12-12 20:20:20
Is VAT valid: true
VAT holder name: fooBar
VAT holder address: barFoo
```

Creating `VatNumberValidationResult` from `stdClass` object raw data, where attribute names in raw data in snake case:

```
$factory = new VatNumberValidationResultFactory();

$vatNumberValidationResult = $factory->createFromObject(
    (object) [
        'country_code' => 'DE',
        'vat_number' => '12312312',
        'request_date' => '2023-12-12 20:20:20',
        'valid' => true,
        'name' => 'fooBar',
        'address' => 'barFoo',
    ]
);

var_dump(sprintf('VAT country code: %s', $vatNumberValidationResult->getCountryCode()));
var_dump(sprintf('VAT number: %s', $vatNumberValidationResult->getVatNumber()));
var_dump(sprintf('Request date: %s', $vatNumberValidationResult->getRequestDateString()));
var_dump(sprintf('Is VAT valid: %s', $vatNumberValidationResult->isValid() ? 'true' : 'false'));
var_dump(sprintf('VAT holder name: %s', $vatNumberValidationResult->getName()));
var_dump(sprintf('VAT holder address: %s', $vatNumberValidationResult->getAddress()));
```

```
VAT country code: DE
VAT number: 12312312
Request date: 2023-12-12 20:20:20
Is VAT valid: true
VAT holder name: fooBar
VAT holder address: barFoo
```

Creating `VatNumberValidationResult` from array raw data, where attribute names in raw data in camel case:

```
$factory = new VatNumberValidationResultFactory();

$vatNumberValidationResult = $factory->createFromArray(
    [
        'countryCode' => 'DE',
        'vatNumber' => '12312312',
        'requestDate' => '2023-12-12 20:20:20',
        'valid' => true,
        'name' => 'fooBar',
        'address' => 'barFoo',
    ]
);

var_dump(sprintf('VAT country code: %s', $vatNumberValidationResult->getCountryCode()));
var_dump(sprintf('VAT number: %s', $vatNumberValidationResult->getVatNumber()));
var_dump(sprintf('Request date: %s', $vatNumberValidationResult->getRequestDateString()));
var_dump(sprintf('Is VAT valid: %s', $vatNumberValidationResult->isValid() ? 'true' : 'false'));
var_dump(sprintf('VAT holder name: %s', $vatNumberValidationResult->getName()));
var_dump(sprintf('VAT holder address: %s', $vatNumberValidationResult->getAddress()));
```

```
VAT country code: DE
VAT number: 12312312
Request date: 2023-12-12 20:20:20
Is VAT valid: true
VAT holder name: fooBar
VAT holder address: barFoo
```

Creating `VatNumberValidationResult` from array raw data, where attribute names in raw data in snake case:

```
$factory = new VatNumberValidationResultFactory();

$vatNumberValidationResult = $factory->createFromArray(
    [
        'country_code' => 'DE',
        'vat_number' => '12312312',
        'request_date' => '2023-12-12 20:20:20',
        'valid' => true,
        'name' => 'fooBar',
        'address' => 'barFoo',
    ]
);

var_dump(sprintf('VAT country code: %s', $vatNumberValidationResult->getCountryCode()));
var_dump(sprintf('VAT number: %s', $vatNumberValidationResult->getVatNumber()));
var_dump(sprintf('Request date: %s', $vatNumberValidationResult->getRequestDateString()));
var_dump(sprintf('Is VAT valid: %s', $vatNumberValidationResult->isValid() ? 'true' : 'false'));
var_dump(sprintf('VAT holder name: %s', $vatNumberValidationResult->getName()));
var_dump(sprintf('VAT holder address: %s', $vatNumberValidationResult->getAddress()));
```

```
VAT country code: DE
VAT number: 12312312
Request date: 2023-12-12 20:20:20
Is VAT valid: true
VAT holder name: fooBar
VAT holder address: barFoo
```

Fault code exception factory.
-----------------------------

[](#fault-code-exception-factory)

`rocketfellows\ViesVatValidationInterface\FaultCodeExceptionFactory` - a factory designed to create exceptions based on an error code that the VAT number validation service can return. Error code detection is case insensitive.

Input arguments:

- `$faultCode` - error code that the VAT number validation service can return;
- `$message` - optional - error message that the VAT number validation service can return.

**Creating exceptions, based on error code mapping:**

`InvalidInputServiceException` - exception for api error code `INVALID_INPUT`.
Description: `the provided CountryCode is invalid or the VAT number is empty`.

`ServiceUnavailableException` - exception for api error code `SERVICE_UNAVAILABLE`.
Description: `an error was encountered either at the network level or the Web application level, try again later`.

`MSUnavailableServiceException` - exception for api error code `MS_UNAVAILABLE`.
Description: `the application at the Member State is not replying or not available. Please refer to the Technical Information page to check the status of the requested Member State, try again later`.

`TimeoutServiceException` - exception for api error code `TIMEOUT`.
Description: `the application did not receive a reply within the allocated time period, try again later`.

`InvalidRequesterInfoServiceException` - exception for api error code `INVALID_REQUESTER_INFO`.

`VatBlockedServiceException` - exception for api error code `VAT_BLOCKED`.

`IPBlockedServiceException` - exception for api error code `IP_BLOCKED`.

`GlobalMaxConcurrentReqServiceException` - exception for api error code `GLOBAL_MAX_CONCURRENT_REQ`.
Description: `your Request for VAT validation has not been processed; the maximum number of concurrent requests has been reached. Please re-submit your request later or contact TAXUD-VIESWEB@ec.europa.eu for further information": Your request cannot be processed due to high traffic on the web application. Please try again later`.

`GlobalMaxConcurrentReqTimeServiceException` - exception for api error code `GLOBAL_MAX_CONCURRENT_REQ_TIME`.

`MSMaxConcurrentReqServiceException` - exception for api error code `MS_MAX_CONCURRENT_REQ`.
Description: `your Request for VAT validation has not been processed; the maximum number of concurrent requests for this Member State has been reached. Please re-submit your request later or contact TAXUD-VIESWEB@ec.europa.eu for further information": Your request cannot be processed due to high traffic towards the Member State you are trying to reach. Please try again later`.

`MSMaxConcurrentReqTimeServiceException` - exception for api error code `MS_MAX_CONCURRENT_REQ_TIME`.

`UnknownServiceErrorException` - exception thrown if it was not possible to understand what error code service returned.

### Usage examples

[](#usage-examples-1)

Error code in upper case:

```
$factory = new FaultCodeExceptionFactory();

$exception = $factory->create('INVALID_REQUESTER_INFO');

var_dump(get_class($exception));
```

```
rocketfellows\ViesVatValidationInterface\exceptions\service\InvalidRequesterInfoServiceException
```

Error code in lower upper case:

```
$factory = new FaultCodeExceptionFactory();

$exception = $factory->create('invalid_requester_info');

var_dump(get_class($exception));
```

```
rocketfellows\ViesVatValidationInterface\exceptions\service\InvalidRequesterInfoServiceException
```

Contributing.
-------------

[](#contributing)

Welcome to pull requests. If there is a major changes, first please open an issue for discussion.

Please make sure to update tests as appropriate.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

3

Last Release

906d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81402dcd0a07ad550b7f80f5871e7c302770b29d4c73a52fc35ba697f702d56e?d=identicon)[arslanim](/maintainers/arslanim)

---

Top Contributors

[![arslanim](https://avatars.githubusercontent.com/u/22678154?v=4)](https://github.com/arslanim "arslanim (230 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (27 commits)")

---

Tags

vies-vat-number-validationvies-vat-validation-php-sdkvies-vat-validation-php-sdk-interface

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rocketfellows-vies-vat-validation-php-sdk-interface/health.svg)

```
[![Health](https://phpackages.com/badges/rocketfellows-vies-vat-validation-php-sdk-interface/health.svg)](https://phpackages.com/packages/rocketfellows-vies-vat-validation-php-sdk-interface)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
