PHP code example of decoda / nfse-core-client

1. Go to this page and download the library: Download decoda/nfse-core-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

decoda / nfse-core-client example snippets




declare(strict_types=1);

use Fiscal\Core\Security\A1FileCertificateProvider;
use Fiscal\Core\Security\OpenSslXmlSigner;
use Fiscal\Core\Transport\CurlHttpTransport;
use Fiscal\Core\Validation\DomXmlSchemaValidator;
use Nfse\Client\SefinNacionalClient;
use Nfse\Client\DTO\EmitNfseRequest;
use Nfse\Client\DTO\Environment;
use Nfse\Client\Endpoints\SefinEndpointResolver;

$certificateProvider = new A1FileCertificateProvider('/caminho/certificado.pfx', 'senha');
$signer = new OpenSslXmlSigner();

$signedXml = $signer->sign($dpsXml, $certificateProvider->getCertificate());

$client = new SefinNacionalClient(
    environment: Environment::PRODUCTION_RESTRICTED,
    endpointResolver: new SefinEndpointResolver(),
    transport: new CurlHttpTransport(),
    certificateProvider: $certificateProvider,
    xmlValidator: new DomXmlSchemaValidator(),
    emitSchemaPath: '/caminho/xsd/dps.xsd',
);

$response = $client->emit(new EmitNfseRequest($signedXml));