Developers
WP-CLI, REST API and hooks
Encadena's WP-CLI commands, REST endpoints, actions and filters, and the platform-independent engine library inside the plugin.
Last updated by the PluginLoom team
WP-CLI#
| Command | What it does |
|---|---|
wp encadena selftest | Runs the engine against the AEAT's published examples (hashes, signed sample, QR URL, XML schemas) and the offline simulator. Prints PASS or FAIL |
wp encadena status | Mode, environment, taxpayer, record counts by status, AEAT wait time, alarm |
wp encadena records [--limit=<n>] [--format=table|json|csv] | Lists records with huella and previous huella |
wp encadena show <id> [--xml] | One record, the exact hashed text and, with --xml, the stored XML |
wp encadena issue <order_id> | Issues the invoice of an order now |
wp encadena annul <order_id> | Creates the annulment record of an order's invoice |
wp encadena queue [--ignore-wait] | Sends waiting records. --ignore-wait only works with the offline simulator |
wp encadena verify [--events] | Checks the whole chain (and the event register) |
wp encadena export --from=<date> --to=<date> [--format=csv|xml] [--file=<path>] | Export for the accountant |
wp encadena pdf <id> --file=<path> | Writes an invoice PDF |
wp encadena correct <id> | Creates the correction (subsanación) of a rejected record from its order |
wp encadena summary | Writes the event summary now (NO VERI*FACTU mode) |
REST API#
Namespace encadena/v1, for logged-in users with the right capability:
GET /encadena/v1/statusGET /encadena/v1/records?page=&per_page=&status=POST /encadena/v1/records/<id>/retryPOST /encadena/v1/verify
Hooks#
| Hook | Type | Arguments |
|---|---|---|
encadena_record_created | action | the stored record row |
encadena_invoice_issued | action | record row, WC_Order |
encadena_submission_status | action | record id, status, AEAT answer |
encadena_producer | filter | producer details used in the SistemaInformatico block and the declaración responsable |
encadena_license_api | filter | license API base URL |
Capabilities#
manage_encadena (settings, certificate, corrections; administrators) and view_encadena (screens, exports; administrators and shop managers).
The engine library#
The core lives in engine/ under the namespace Encadena\Engine with its own autoloader and no WordPress dependency: record building, the huella, the XML and its validation against the official AEAT schemas, the QR code, XAdES signatures, the SOAP client with flow control, event records, the chain verifier and the PDF writer. It needs PHP 7.4 or newer with dom, libxml, openssl and hash (curl for real submissions). The same engine is meant to power other platforms later.
Run its unit tests with php engine/tests/run.php.
Was this page helpful?