goosfraba / krd-rastin-sdk
用于KRD Rastin 2.0协议的SDK
1.0.6
2024-01-16 08:55 UTC
Requires
- php: >=7.4
- jms/serializer: ^3.23
- webit/soap-api: ^3.0.0
Requires (Dev)
- fakerphp/faker: ^1.23
- phpspec/prophecy-phpunit: ^2.1
- phpunit/phpunit: ^10.0
README
本项目为KRD (Krajowy Rejestr Długów) Rastin协议2.0提供了一个高级SDK。
安装
通过composer安装。需要PHP 7.4以上版本。
composer require goosfraba/krd-rastin
使用
SDK创建
创建SDK实例
use Goosfraba\KrdRastin\Soap\KrdRastinSoapApiFactory; use Goosfraba\KrdRastin\Soap\Authorization; $factory = KrdRastinSoapApiFactory::getInstance(); $apiDemo = $factory->createDemo( Authorization::loginAndPassword("demo-login", "demo-password") ); // creates API for DEMO WSDL $apiDemo = $factory->createDemo( Authorization::loginAndPassword("your-prod-login", "your-prod-password") ); // creates API for PROD WSDL
验证消费者的身份号码/地址(VerifyConsumerIdentityNumber方法)
use Goosfraba\KrdRastin\VerifyConsumerIdentityNumberRequest; use Goosfraba\KrdRastin\VerifyConsumerIdentityNumberResponse; use Goosfraba\KrdRastin\Exception\ValidationException; use Goosfraba\KrdRastin\Exception\AuthenticationException; use Goosfraba\KrdRastin\Exception\GenericException; try { /** @var VerifyConsumerIdentityNumberResponse $result */ $result = $api->verifyConsumerIdentityNumber( VerifyConsumerIdentityNumberRequest::create( "13300100037", "OKTAWIUSZ", "DE LORM", Address::create( "GÓRNICZA", "39", "20", "01203", "JÓZEFÓW" ) ) ); } catch (ValidationException $e) { // invalid PESEL (given number is not a valid PESEL number) } catch (AuthenticationException $e) { // invalid login / password } catch (GenericException $e) { // generic API exception, see \SoapFault for details $soapFault = $e->soapFault(); } $result->isPeselValid(); // checks if PESEL is valid (false if given PESEL is not matching the given name) $addressResult = $result->permanentAddressVerificationResult(); // Address validation result object
验证消费者的身份证(VerifyIDCard方法)
use Goosfraba\KrdRastin\VerifyIDCardRequest; use Goosfraba\KrdRastin\VerifyIDCardResponse; try { /** @var VerifyIDCardResponse $result */ $result = $api->verifyIdCard( VerifyIDCardRequest::create( "51011500014", FullName::createWithLastName("ANDRZEJ", "PAWEŁ", "WALCZUK-KOWALSKA"), "VCX", "959351", date_create_immutable("2014-09-24"), date_create_immutable("2024-09-24") ) ); } catch (AuthenticationException $e) { // invalid login / password } catch (GenericException $e) { // generic API exception, see \SoapFault for details $soapFault = $e->soapFault(); } /** * true if the ID Card number details (name, number, dates) * matching the PESEL and the ID Card has not been invalidated */ $result->isValid();
检查消费者的身份证是否已注销(VerifyIsIDCardCanceled方法)
use Goosfraba\KrdRastin\VerifyIsIDCardCanceledRequest; use Goosfraba\KrdRastin\VerifyIsIDCardCanceledResponse; try { /** @var VerifyIsIDCardCanceledResponse $result */ $result = $api->verifyIsIdCardCanceled( VerifyIsIDCardCanceledRequest::create("VCX", "959351") ); } catch (AuthenticationException $e) { // invalid login / password } catch (GenericException $e) { // generic API exception, see \SoapFault for details $soapFault = $e->soapFault(); } /** * TRUE only if the ID Card number exists and it has been cancelled. * Please not it will return FALSE for invalid ID Card so this should be used only along with VerifyIdCard method. */ $isCanceled = $result->isCanceled();
验证消费者是否仍然存活(VerifyConsumerIsAlive方法)
use Goosfraba\KrdRastin\VerifyConsumerIsAliveRequest; use Goosfraba\KrdRastin\VerifyConsumerIsAliveResponse; use Goosfraba\KrdRastin\VerifyConsumerIsAliveStatus; try { /** @var VerifyConsumerIsAliveResponse $result */ $result = $api->verifyConsumerIsAlive( VerifyConsumerIsAliveRequest::create("14221400248", "DELFFINA", "TONDOSSSS") ); } catch (AuthenticationException $e) { // invalid login / password } catch (GenericException $e) { // generic API exception, see \SoapFault for details $soapFault = $e->soapFault(); } /** * Status is one of: * VerifyConsumerIsAliveStatus::alive() * VerifyConsumerIsAliveStatus::notAlive() * VerifyConsumerIsAliveStatus::incorrectData() */ $status = $result->status();
贡献
欢迎您为此仓库贡献新功能/错误修复。