3creativessas/tc-ubl21dian

电子发票预验证核心 - DIAN UBL 2.1

3.0 2020-08-31 18:38 UTC

This package is auto-updated.

Last update: 2024-09-29 06:02:44 UTC


README

电子发票预验证核心 - DIAN UBL 2.1。

标签

  • 1.0: 包含带有二进制安全令牌(SOAP)和XAdES签名(XML)的sha1、sha256和sha512算法的有效测试。
  • 1.1: 包含Web服务消费的主要模板,需要curl作为依赖项。
  • 1.1.1: 解决了规范化错误。
  • 1.2: 包含发送信用证和计算CUDE的有效证据。
  • 1.3: 许可证LGPL。
  • 2.0: 包含发送借记单和文档名称标准的有效证据。

资源

文档

最后更新于2019年11月16日 15:09 | 发布于2019年6月30日

电子发票预验证核心 DIAN UBL 2.1。

标签

  • 1.0: 包含带有二进制安全令牌(SOAP)和XAdES签名(XML)的sha1、sha256和sha512算法的有效测试。
  • 1.1: 包含Web服务消费的主要模板,需要curl作为依赖项。
  • 1.1.1: 解决了规范化错误。
  • 1.2: 包含发送信用证和计算CUDE的有效证据。
  • 1.3: 许可证LGPL。
  • 2.0: 包含发送借记单和文档名称标准的有效证据。

如何安装

使用 composer 安装

composer require 3creativessas/tc-ubl21dian

SOAP基本用法

use DOMDocument;
use Stenfrank\UBL21dian\BinarySecurityToken\SOAP;

$xmlString = <<<XML
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wcf="http://wcf.dian.colombia">
    <soap:Header/>
    <soap:Body>
        <wcf:GetStatus>
            <!--Optional:-->
            <wcf:trackId>123456666</wcf:trackId>
        </wcf:GetStatus>
    </soap:Body>
</soap:Envelope>
XML;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$domDocument = new DOMDocument();
$domDocument->loadXML($xmlString);

$soap = new SOAP($pathCertificate, $passwors);
$soap->Action = 'http://wcf.dian.colombia/IWcfDianCustomerServices/GetStatus';

$soap->sign($domDocument->saveXML());

file_put_contents('./SOAPDIAN21.xml', $soap->xml);

XAdES SHA1基本用法

use DOMDocument;
use Stenfrank\UBL21dian\XAdES\SignInvoice;

$xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<Invoice>
    <ext:UBLExtensions>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
    </ext:UBLExtensions>
</Invoice>
XML;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$domDocument = new DOMDocument();
$domDocument->loadXML($xmlString);

$signInvoice = new SignInvoice($pathCertificate, $passwors, $xmlString, SignInvoice::ALGO_SHA1);

file_put_contents('./SING1.xml', $signInvoice->xml);

XAdES SHA256基本用法

use DOMDocument;
use Stenfrank\UBL21dian\XAdES\SignInvoice;

$xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<Invoice>
    <ext:UBLExtensions>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
    </ext:UBLExtensions>
</Invoice>
XML;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$domDocument = new DOMDocument();
$domDocument->loadXML($xmlString);

$signInvoice = new SignInvoice($pathCertificate, $passwors, $xmlString);

file_put_contents('./SING256.xml', $signInvoice->xml);

XAdES SHA512基本用法

use DOMDocument;
use Stenfrank\UBL21dian\XAdES\SignInvoice;

$xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<Invoice>
    <ext:UBLExtensions>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
        <ext:UBLExtension>
            <ext:ExtensionContent/>
        </ext:UBLExtension>
    </ext:UBLExtensions>
</Invoice>
XML;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$domDocument = new DOMDocument();
$domDocument->loadXML($xmlString);

$signInvoice = new SignInvoice($pathCertificate, $passwors, $xmlString, SignInvoice::ALGO_SHA512);

file_put_contents('./SING512.xml', $signInvoice->xml);

计算软件安全码

// If you assign the values "softwareID" and "pin" the library will calculate and assign "Software Security Code" at the moment of signing the document.
$xadesDIAN->softwareID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$xadesDIAN->pin = '12345';

计算“UUID”(CUFE)

// If you assign the value "technicalKey" the library will calculate and assign "UUID" (CUFE) at the moment of signing the document
$xadesDIAN->technicalKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

计算“UUID”(CUDE)

// If you assign the value "pin" the library will calculate and assign "UUID" (CUDE) at the moment of signing the document
$signCreditNote->pin = 'xxxxx';

Web服务消费(客户端):{#web-service}

use Stenfrank\UBL21dian\Client;
use Stenfrank\UBL21dian\Templates\SOAP\GetStatusZip;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$getStatusZip = new GetStatusZip($pathCertificate, $passwors);
$getStatusZip->trackId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';

// Sign
$getStatusZip->sign();

$client = new Client($getStatusZip);

// DIAN Response Web Service
return $client;

Web服务消费(模板)

use Stenfrank\UBL21dian\Templates\SOAP\GetStatusZip;

$pathCertificate = 'PATH_CERTIFICATE.p12';
$passwors = 'PASSWORS_CERTIFICATE';

$getStatusZip = new GetStatusZip($pathCertificate, $passwors);
$getStatusZip->trackId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';

// Sign to send - DIAN Response Web Service
return $getStatusZip->signToSend();

作者

捐赠

如果这个库帮助您减少开发时间,您可以请我喝杯咖啡 😃。

paypal