PHPackages                             matiz-studio-creative/sri-toolkit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. matiz-studio-creative/sri-toolkit

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

matiz-studio-creative/sri-toolkit
=================================

PHP toolkit for Ecuador SRI electronic documents: access keys, XML builders, XAdES-BES signing and SOAP delivery.

v1.2.0(3w ago)119↓100%[1 issues](https://github.com/Sebas-DV/sri-toolkit/issues)MITPHPPHP &gt;=8.2CI passing

Since May 18Pushed 2w agoCompare

[ Source](https://github.com/Sebas-DV/sri-toolkit)[ Packagist](https://packagist.org/packages/matiz-studio-creative/sri-toolkit)[ Docs](https://sri-toolkit.matizstudiocreative.com)[ RSS](/packages/matiz-studio-creative-sri-toolkit/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

SRI Toolkit
===========

[](#sri-toolkit)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0c3c60b647dd323c83ec4c9034247414ef6577a7263007bd24a55ee0d74d90fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6174697a2d73747564696f2d63726561746976652f7372692d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matiz-studio-creative/sri-toolkit)[![Total Downloads](https://camo.githubusercontent.com/30b7eda743df14330443f504ac64d2c944563ffd4db18ffd7c3bff35d917bf49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6174697a2d73747564696f2d63726561746976652f7372692d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matiz-studio-creative/sri-toolkit)[![License](https://camo.githubusercontent.com/307f25d9dc3e489ea521efbb0cb3dc78058aa5937804867a9c3908ba6fdef70c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6174697a2d73747564696f2d63726561746976652f7372692d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/f748e5bcf29d0c4db50161858376f85d16ea93f7664f5e8179e8e96d252a51e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6174697a2d73747564696f2d63726561746976652f7372692d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](composer.json)

PHP toolkit for Ecuador SRI electronic documents. It helps generate access keys, build XML documents, sign them with XAdES-BES using PKCS#12 certificates, and send signed XML to the SRI reception and authorization web services.

Documentation
-------------

[](#documentation)

Full documentation is available at [sri-toolkit.matizstudiocreative.com](https://sri-toolkit.matizstudiocreative.com).

Features
--------

[](#features)

- Electronic signing with PKCS#12 certificate files (`.p12` / `.pfx`) using the SRI-compatible XAdES-BES flow.
- Certificate metadata extraction for issuer, serial number and RSA public key material required by the XML signature.
- XML generation for the main SRI electronic documents: invoices, purchase settlements, credit notes, debit notes, delivery guides and withholding receipts.
- XML structures aligned with the official SRI document formats and ready for signing.
- SOAP client for SRI reception and authorization web services.
- Automatic 49-digit SRI access key generation with the modulo 11 verification digit.
- Typed reception and authorization response parsing.
- Support for SRI testing and production environments.
- Testable internals through injectable SOAP, clock, signer and sleeper dependencies.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- PHP extensions:
    - `ext-soap`
    - `ext-openssl`
    - `ext-dom`
    - `ext-libxml`
- Composer

The CI suite currently runs against PHP 8.2, 8.3, 8.4 and 8.5.

Installation
------------

[](#installation)

```
composer require matiz-studio-creative/sri-toolkit
```

Supported Documents
-------------------

[](#supported-documents)

Access key generation exposes the six SRI electronic document codes from the official offline technical sheet:

CodeDocumentAccess key`01`Invoice`DocumentType::Invoice``03`Purchase settlement`DocumentType::PurchaseSettlement``04`Credit note`DocumentType::CreditNote``05`Debit note`DocumentType::DebitNote``06`Remission guide`DocumentType::RemissionGuide``07`Withholding receipt`DocumentType::RetentionVoucher`XML generation currently supports:

CodeDocumentEnumXML version`01`Invoice`XmlDocumentType::Invoice``2.1.0``03`Purchase settlement`XmlDocumentType::PurchaseSettlement``1.1.0``04`Credit note`XmlDocumentType::CreditNote``1.1.0``05`Debit note`XmlDocumentType::DebitNote``1.0.0``06`Delivery guide`XmlDocumentType::DeliveryGuide``1.1.0``07`Withholding receipt`XmlDocumentType::WithholdingReceipt``2.0.0`Catalogs
--------

[](#catalogs)

Common document codes are available through a runtime-overridable catalog registry based on the official offline technical sheet v2.26 and the ICE annex.

```
use MTZ\Toolkit\Catalogs\Catalogs;

$catalogRegistry = Catalogs::registry();

$catalogRegistry->get('vat-rates', '4');        // VAT 15%
$catalogRegistry->list('payment-methods');      // [{ code: '01', ... }, ...
$catalogRegistry->getMeta('vat-rates');         // source, updatedAt, notes
$catalogRegistry->listCatalogs();            // catalog names

$catalogRegistry->override('vat-rates', [
    '4' => ['code' => '4', 'description' => 'VAT 16%', 'rate' => 16],
]);

$catalogRegistry->reset('vat-rates');
```

PHP reserves `list` as a declared method name, so `CatalogRegistry` also exposes `entries('payment-methods')` for static-analysis-friendly code. The magic `$catalogRegistry->list(...)` call is supported for compatibility with the TypeScript API shape.

### Common Document Codes

[](#common-document-codes)

Identification types (`customer.identification_type`, `subject.identification_type`, carriers):

CodeType`04`Taxpayer ID`05`National ID`06`Passport`07`Final consumer`08`Foreign IDVAT (`percentage_code` when tax `code` is `2`):

CodeRateNotes`0`0%VAT 0%`2`12%Historical`3`14%Historical`4`15%Common current rate`5`5%Added by official sheet v2.26`6`0%Not subject to tax`7`0%VAT exempt`8`variableDifferentiated VAT`10`13%Added by official sheet v2.26Payment methods:

CodeDescription`01`No financial system used`15`Debt compensation`16`Debit card`17`Electronic money`18`Prepaid card`19`Credit card`20`Other financial system method`21`Title endorsementVAT withholding (`code: '2'`, `withholding_code`):

CodeRate`9`10%`10`20%`1`30%`11`50%`2`70%`3`100%`7`0%, zero withholding`8`0%, withholding does not applyFull catalog: use `$catalogRegistry->list('vat-withholding')`.

Quick Start
-----------

[](#quick-start)

```
