goosfraba/vies-eu-vat-checker

验证任何成员国颁发的增值税号的合法性

1.0.0 2019-10-21 19:28 UTC

This package is auto-updated.

Last update: 2024-09-22 18:41:11 UTC


README

验证任何成员国颁发的增值税号的合法性。该库提供了一个便捷的API实现,用于连接到欧盟委员会的SOAP服务。

安装

安装库的最佳方式是使用composer

composer require goosfraba/vies-eu-vat-checker

用法

创建API实例

要创建生产API实例,请使用以下代码片段

<?php
use Goosfraba\ViesEuVatChecker\CheckVatSoapApi;

$api = CheckVatSoapApi::create();

要创建测试API实例,请使用以下代码片段

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

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

增值税检查服务

<?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

测试

composer install
./vendor/bin/phpunit