PHP code example of clonixdev / sri-ec

1. Go to this page and download the library: Download clonixdev/sri-ec 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/ */

    

clonixdev / sri-ec example snippets


use DazzaDev\SriEc\Client;

$client = new Client(test: true); // true or false

$client->setCertificate([
    'path' => _DIR_ . '/certificado.p12',
    'password' => 'clave_certificado',
]);

// Ruta donde se guardarán los archivos xml
$client->setFilePath(_DIR_ . '/sri');

// Usar el valor en inglés de la tabla
$client->setDocumentType('invoice');

// Datos del documento
$client->setDocumentData($documentData);

// Enviar el documento
$document = $client->sendDocument();

use DazzaDev\SriEc\Listing;

// Obtener los listados disponibles
$listings = Listing::getListings();

// Consultar los datos de un listado por tipo
$listingByType = Listing::getListing('identification-types');

use DazzaDev\SriEc\RucConsulta\RucConsulta;

$consulta = new RucConsulta();

// Por RUC (13 dígitos)
$resultado = $consulta->porRuc('1790016919001');

// Por razón social (admite coincidencias parciales)
$resultados = $consulta->porRazonSocial('CORPORACION FAVORITA', limit: 20);

[
    'success' => true,
    'count' => 1,
    'total' => 2, // solo en búsqueda por razón social
    'results' => [
        [
            'numero_ruc' => '1790016919001',
            'razon_social' => 'CORPORACION FAVORITA C.A.',
            'nombre_comercial' => 'CORPORACION FAVORITA C.A.',
            'estado_contribuyente' => 'ACTIVO',
            'tipo_contribuyente' => 'SOCIEDAD',
            'obligado_contabilidad' => 'SI',
            'actividad_economica' => 'VENTA AL POR MAYOR...',
            'regimen' => 'GENERAL',
            'categoria' => null,
            'establecimientos' => [
                [
                    'numero_establecimiento' => '001',
                    'nombre_comercial' => 'CORPORACION FAVORITA C.A.',
                    'direccion_completa' => 'PICHINCHA / QUITO / ...',
                    'estado' => 'ABIERTO',
                    'tipo_establecimiento' => 'MAT',
                    'matriz' => 'SI',
                ],
            ],
        ],
    ],
]