PHP code example of stea / factura-electronica

1. Go to this page and download the library: Download stea/factura-electronica 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/ */

    

stea / factura-electronica example snippets


use Stea\FacturaElectronica\FacturaElectronicaManager;
use Stea\FacturaElectronica\Enums\TipoDocumento;
use Stea\FacturaElectronica\Dtos\{FacturaExportacionDto, EmisorDto, ReceptorDto, IdentificacionDto, UbicacionDto};

$dto = new FacturaExportacionDto(
    consecutivo: '00100001090000000001',           // you allocate this (sucursal+terminal+tipo+seq)
    fechaEmision: new DateTimeImmutable('now'),
    proveedorSistemas: '3101000000',
    codigoActividadEmisor: '620100',
    emisor: new EmisorDto(
        nombre: 'MI EMPRESA S.A.',
        identificacion: new IdentificacionDto('02', '3101000000'),
        ubicacion: new UbicacionDto('1', '01', '01'),
        correoElectronico: '[email protected]',
    ),
    receptor: new ReceptorDto(
        nombre: 'FOREIGN CLIENT, INC',
        identificacionExtranjero: '00-0000000',
        otrasSenasExtranjero: '123 Main St, City, ST 00000',
    ),
    lineas: [ /* LineaDetalleDto[] */ ],
    moneda: 'USD',
    tipoCambio: 1.0,
);

/** @var FacturaElectronicaManager $manager */
$result = $manager->emitir(TipoDocumento::FacturaExportacion, $dto);
// $result->clave, $result->signedXml, $result->estado

// later, resolve the async status:
$status = $manager->consultar($result->clave); // aceptado | rechazado | procesando ...
bash
php artisan vendor:publish --tag=factura-electronica-config