承接 blockpoint/vat24api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blockpoint/vat24api-php

最新稳定版本:1.4

Composer 安装命令:

composer require blockpoint/vat24api-php

包简介

API wrapper for Vat24API

README 文档

README

Latest Version on Packagist Tests Total Downloads

A PHP wrapper for the Vat24API service, which provides VAT and EORI number validation for EU and UK businesses. This package makes it easy to integrate VAT and EORI validation into your PHP applications.

https://vat24api.com/

Installation

You can install the package via composer:

composer require blockpoint/vat24api-php

Usage

// Create a new Vat24Api instance with your API key
$vat24api = new Blockpoint\Vat24Api\Vat24Api('your-api-key');

// Validate a VAT number
try {
    $response = $vat24api->validateVat('NL', '836176320B01');

    if ($response->hasError()) {
        echo "API Error: " . $response->getErrorMessage() . "\n";
        echo "Status Code: " . $response->getStatusCode() . "\n";
    } elseif ($response->isValid()) {
        echo "VAT number is valid!\n";
        echo "Company name: " . $response->getCompanyName() . "\n";
        echo "Company address: " . $response->getCompanyAddress() . "\n";
    } else {
        echo "VAT number is not valid!\n";
        echo "Reason: " . $response->getFaultString() . "\n";
    }
} catch (\Blockpoint\Vat24Api\Exceptions\Vat24ApiException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

// Validate an EORI number
try {
    $response = $vat24api->validateEori('GB', '123456789000');

    if ($response->hasError()) {
        echo "API Error: " . $response->getErrorMessage() . "\n";
        echo "Status Code: " . $response->getStatusCode() . "\n";
    } elseif ($response->isValid()) {
        echo "EORI number is valid!\n";
        echo "Company name: " . $response->getCompanyName() . "\n";
    } else {
        echo "EORI number is not valid!\n";
        echo "Reason: " . $response->getFaultString() . "\n";
    }
} catch (\Blockpoint\Vat24Api\Exceptions\Vat24ApiException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Available Methods

Validate VAT Number

$response = $vat24api->validateVat('NL', '836176320B01');

You can also perform a mutual validation by providing a requester country code and VAT number:

$response = $vat24api->validateVat('NL', '836176320B01', 'GB', '123456789');

Validate EORI Number

$response = $vat24api->validateEori('GB', '123456789000');

Response Methods

The ValidationResponse object provides the following methods:

  • isValid(): Returns whether the VAT/EORI number is valid
  • hasError(): Returns whether the response contains an API error
  • getErrorMessage(): Returns the error message if any
  • getStatusCode(): Returns the HTTP status code
  • getMessage(): Returns the status message
  • getCountryCode(): Returns the country code
  • getVatNumber(): Returns the VAT number
  • getEoriNumber(): Returns the EORI number
  • getValidationStatus(): Returns the validation status
  • getFaultString(): Returns the fault string if validation failed
  • getRequestDate(): Returns the request date
  • getConsultationNumber(): Returns the consultation number
  • getConsultationAuthority(): Returns the consultation authority
  • getCompanyName(): Returns the company name
  • getCompanyAddress(): Returns the company address
  • toArray(): Returns the raw response data as an array

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-21