taocomp/php-sdicoop-client

一个用于连接意大利交换系统(也称SdI)Web服务的PHP包

v0.1.10 2019-02-06 10:41 UTC

This package is auto-updated.

Last update: 2024-09-17 18:46:47 UTC


README

一个用于连接意大利交换系统(又称“SdI”)Web服务的PHP包。

(用于向SdI Web服务发送发票和通知的PHP包)。

请参考

查看论坛意大利 - 电子发票以获取服务器配置、互操作性测试等。特别是

Apache配置
SDICoop认证:Apache上的SSL配置 - 电子发票...
互操作性测试
互操作性解决方案测试 - 电子发票 - 论坛意大利

入门

依赖项

  • PHP >=5.5
  • php-curl
  • php-soap

安装

Composer

composer require taocomp/php-sdicoop-client

手动

  • 克隆/下载存储库
  • require_once('/path/to/php-sdicoop-client/vendor/autoload.php');

命名空间

请注意命名空间已更改(v0.1.5),现在是Taocomp\Einvoicing\SdicoopClient

例如,要使用Client

use \Taocomp\Einvoicing\SdicoopClient\Client;

设置

根据意大利交换系统(也称SdI),您需要

  • 客户端密钥
  • 客户端证书
  • CA证书

向SdI Web服务发送发票和通知。

此外,您必须提供要连接的端点和每个Web服务的对应WSDL。

您可以如下配置密钥和证书

Client::setPrivateKey('/path/to/client.key');
Client::setClientCert('/path/to/client.pem');
Client::setCaCert('/path/to/ca.pem');

您也可以根据需要配置代理

Client::setProxyUrl('proxy_url');
Client::setProxyAuth('username:password');

然后您可以通过提供端点/WSDL来实例化客户端。

Web服务SdIRiceviFile(测试)用于发送发票

$client = new Client(array(
    'endpoint' => 'https://testservizi.fatturapa.it/ricevi_file',
    'wsdl'     => '/path/to/php-sdicoop-client/assets/wsdl/SdIRiceviFile_v1.0.wsdl'
));

Web服务SdIRiceviNotifica(测试)用于发送通知

$client = new Client(array(
    'endpoint' => 'https://testservizi.fatturapa.it/ricevi_notifica',
    'wsdl'     => '/path/to/php-sdicoop-client/assets/wsdl/SdIRiceviNotifica_v1.0.wsdl'
));

或者您可以将所有参数(密钥、证书、wsdl、端点)传递给客户端构造函数

$client = new Client(array(
    'key'      => '/path/to/client.key',
    'cert'     => '/path/to/client.pem',
    'ca_cert'  => '/path/to/ca.pem',
    'endpoint' => 'https://testservizi.fatturapa.it/ricevi_file',
    'wsdl'     => '/path/to/php-sdicoop-client/assets/wsdl/SdIRiceviFile_v1.0.wsdl'
));

向SdI发送发票(Web服务“SdIRiceviFile”)

$fileSdI = new FileSdIBase();
$fileSdI->load('/path/to/invoice.xml');
$response = new RispostaSdIRiceviFile($client->RiceviFile($fileSdI));

// Process response:
// -----------------------------------------
// $id       = $response->IdentificativoSdI;
// $datetime = $response->DataOraRicezione;
// $error    = $response->Errore;
// -----------------------------------------

请参见examples/invoice.php以获取一个工作示例。

您还可以发送\Taocomp\Einvoicing\FatturaElettronica对象:请参阅https://github.com/taocomp/php-e-invoice-it

向SdI发送通知(Web服务“SdIRiceviNotifica”,端点测试)

$fileSdI = new FileSdI();
$fileSdI->load('/path/to/notice.xml');
$response = new RispostaSdINotificaEsito($client->NotificaEsito($fileSdI));

// Process response:
// ----------------------------------
// $result          = $response->Esito;
// $discard         = $response->ScartoEsito;
// $discardFilename = $discard->NomeFile;
// $discardFile     = $discard->File;
// ----------------------------------

请参见examples/notice.php以获取一个工作示例。

您还可以发送\Taocomp\Einvoicing\EsitoCommittente对象:请参阅https://github.com/taocomp/php-e-invoice-it

鸣谢

我们想感谢论坛意大利 - 电子发票的所有贡献者,他们分享了他们的代码片段和任何可用的信息。

感谢Luca Cristofalo在他旧的PHP 5.5.38上测试代码。:-)

许可证

GPLv3。