CoolCMS API

ViesClient
in package

FinalYes

HTTP client of the EU VIES REST service.

POST check-vat-number {countryCode, vatNumber, requesterMemberStateCode, requesterNumber}; with the requester (seller VAT id) VIES returns requestIdentifier = consultation number, the evidence for the tax office. Timeout 3 s, 1 retry when the service did not answer.

Never throws: an unavailable service is ViesResult(valid: null) — nothing blocks a purchase because of VIES. Talks only to VIES, knows nothing about the evidence table (that is VatIdCheckManager).

The HTTP client is injectable so tests use Guzzle's MockHandler; production builds its own.

Table of Contents

Constants

ENDPOINT  : string = 'https://ec.europa.eu/taxation_customs/vies/res...
INVALID_REQUESTER  : string = 'INVALID_REQUESTER_INFO'
UNAVAILABLE_ERRORS  : array<string|int, mixed> = ['SERVICE_UNAVAILABLE', 'MS_UNAVAILABLE', 'TIME...
VIES error codes meaning "no answer, try later" (not "invalid").

Properties

$httpClient  : ClientInterface
$retries  : int
$timeoutSeconds  : float

Methods

__construct()  : mixed
check()  : ViesResult
callOnce()  : ViesResult
findError()  : string|null
findText()  : string|null
isRetryable()  : bool

Constants

ENDPOINT

public string ENDPOINT = 'https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number'

INVALID_REQUESTER

private string INVALID_REQUESTER = 'INVALID_REQUESTER_INFO'

UNAVAILABLE_ERRORS

VIES error codes meaning "no answer, try later" (not "invalid").

private array<string|int, mixed> UNAVAILABLE_ERRORS = ['SERVICE_UNAVAILABLE', 'MS_UNAVAILABLE', 'TIMEOUT', 'VAT_BLOCKED', 'IP_BLOCKED', 'GLOBAL_MAX_CONCURRENT_REQ', 'GLOBAL_MAX_CONCURRENT_REQ_TIME', 'MS_MAX_CONCURRENT_REQ', 'MS_MAX_CONCURRENT_REQ_TIME', 'SERVER_BUSY']

Properties

$httpClient read-only

private ClientInterface $httpClient

$timeoutSeconds read-only

private float $timeoutSeconds = 3.0

Methods

__construct()

public __construct([ClientInterface|null $httpClient = null ][, float $timeoutSeconds = 3.0 ][, int $retries = 1 ]) : mixed
Parameters
$httpClient : ClientInterface|null = null
$timeoutSeconds : float = 3.0
$retries : int = 1

check()

public check(string $countryCode, string $vatNumber[, string|null $requesterCountryCode = null ][, string|null $requesterNumber = null ]) : ViesResult
Parameters
$countryCode : string

VIES member state code (Greece EL)

$vatNumber : string

number without the prefix

$requesterCountryCode : string|null = null
$requesterNumber : string|null = null
Return values
ViesResult

findError()

private findError(array<string|int, mixed> $data) : string|null
Parameters
$data : array<string|int, mixed>
Return values
string|null

findText()

private findText(array<string|int, mixed> $data, string $key) : string|null
Parameters
$data : array<string|int, mixed>
$key : string
Return values
string|null
On this page

Search results