taocomp / php-sdicoop-server

A PHP package for implementing web services required by the Italian Exchange System. (Pacchetto PHP per l'implementazione dei webservices TrasmissioneFatture e RicezioneFatture richiesti dal SdI).
GNU General Public License v3.0
18 stars 7 forks source link
e-invoice einvoice fattura fattura-elettronica fattura-pa fatturazione-elettronica invoice italy open-source opensource php sdi sdicoop server soap

+TITLE: PHP SdICoop - Server

A PHP package for implementing web services required by the [[https://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm?l=en][Italian Exchange System (aka "SdI")]].

/(Pacchetto PHP per l'implementazione dei webservices TrasmissioneFatture e RicezioneFatture richiesti dal SdI)./

Please refer to

See [[https://forum.italia.it/c/fattura-pa][Forum Italia - Fatturazione Elettronica]] for server configuration, interoperability tests, etc. In particular:

+BEGIN_SRC

https://test.example.com/trasmissione/index.php

+END_SRC

put the following code in your ~index.php~:

+BEGIN_SRC

<?php require_once('/path/to/php-sdicoop-server/examples/trasmissione-fatture.php');

+END_SRC

** Web Service "RicezioneFatture" Just include ~examples/ricezione-fatture.php~ in your endpoint. For example, if your test endpoint is

+BEGIN_SRC

https://test.example.com/ricezione/index.php

+END_SRC

put the following code in your ~index.php~:

+BEGIN_SRC

<?php require_once('/path/to/php-sdicoop-server/examples/ricezione-fatture.php');

+END_SRC

** Install *** Composer

+BEGIN_SRC

composer require taocomp/php-sdicoop-server

+END_SRC

*** Manually

*** Namespaces Please note namespace is changed (v0.1.1), it is now ~Taocomp\Einvoicing\SdicoopServer~.

So to use e.g. ~WebService~ class:

+BEGIN_SRC

use \Taocomp\Einvoicing\SdicoopServer\WebService;

+END_SRC

** Setup *** Web service "TrasmissioneFatture"

For example, if your handler class is:

+BEGIN_SRC

class MyTrasmissioneFattureHandler { //... }

+END_SRC

saved in ~/path/to/MyTrasmissioneFattureHandler.php~, then the code in your endpoint will be:

+BEGIN_SRC

ini_set("soap.wsdl_cache_enabled", 0); ini_set('soap.wsdl_cache_ttl', 0);

use \Taocomp\Einvoicing\SdicoopServer\WebService;

try { require_once('/path/to/php-sdicoop-server/vendor/autoload.php'); require_once('/path/to/MyTrasmissioneFattureHandler.php');

$wsdl = '/path/to/php-sdicoop-server/assets/wsdl/TrasmissioneFatture_v1.1.wsdl';
$ws = new WebService($wsdl);
$ws->setClass('\MyTrasmissioneFattureHandler');
$ws->handle();

} catch (\Exception $e) { WebService::log($e->getMessage(), LOG_ERR); }

+END_SRC

*** Web service "RicezioneFatture" Follow the same instructions as in "TrasmissioneFatture".

** Logs Both web services write on system log.

For example, when you receive a notice "RicevutaConsegna":

+BEGIN_SRC

Dec 14 23:52:32 web Taocomp\Einvoicing\SdicoopServer\WebService: RicevutaConsegna IdentificativoSdI:7045996 NomeFile:ITXXXXXXXXXXX_00001_RC_002.xml

+END_SRC