PHP code example of esolutions / xml-simple

1. Go to this page and download the library: Download esolutions/xml-simple 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/ */

    

esolutions / xml-simple example snippets


use ESolutions\XmlSimple\Contracts\XmlDocumentGeneratorContract;
use ESolutions\XmlSimple\Sending\{DocumentSender, SenderConfig, FilenameBuilder};

$gen = app(XmlDocumentGeneratorContract::class)->generate('invoice', $payload, $certFile, $certPass);
// $gen->isOk(), $gen->xml (firmado), $gen->unsignedXml, $gen->getHash(), $gen->validation->errors, $gen->warnings

$config = SenderConfig::fromArray([...]);
$result = (new DocumentSender($config))->send(
    FilenameBuilder::forDocument($ruc, $docTypeId, $series, $number),
    $gen->xml
);
// $result->isAccepted(), $result->getCdrXml(), $result->reachedSunat(), $result->recommendedAction(), $result->toArray()

use ESolutions\XmlSimple\Sending\Services\ConsultCdrService;
use ESolutions\XmlSimple\Validation\Sunat\ErrorCatalog;

$estado = app(ConsultCdrService::class, ['config' => $config])->getStatusCdr($ruc, '01', 'F001', 123);
$mensaje = (new ErrorCatalog())->message('2800');