PHP code example of phpcfdi / sat-estado-cfdi-http-psr

1. Go to this page and download the library: Download phpcfdi/sat-estado-cfdi-http-psr 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/ */

    

phpcfdi / sat-estado-cfdi-http-psr example snippets



declare(strict_types=1);

use PhpCfdi\SatEstadoCfdi\Consumer;
use PhpCfdi\SatEstadoCfdi\HttpPsr\HttpConsumerClient;
use PhpCfdi\SatEstadoCfdi\HttpPsr\HttpConsumerFactoryInterface;

// suponiendo que tienes un objeto factory que tu formaste
/** @var HttpConsumerFactoryInterface $factory */

// construimos el cliente
$client = new HttpConsumerClient($factory);

// creamos el consumidor con nuestro cliente
$consumer = new Consumer($client);

// consumimos el webservice!
$response = $consumer->execute('...expression');

// usamos el resultado
if ($response->cancellable()->isNotCancellable()) {
    echo 'CFDI no es cancelable';
}