HaciendaEmitirFactura
Description
Section titled “Description”Issues an Electronic Invoice to Costa Rica’s Ministerio de Hacienda (version 4.4). The node builds Hacienda’s own XML format, computes the 50-digit numeric key, signs the document with the issuer’s certificate, obtains the OAuth2 token (ATV) and performs the reception POST followed by a status query.
The invoice only becomes tax-valid once Hacienda ACCEPTS it. If the response comes back as received or processing, reconcile it later with HaciendaConsultarEstado.
Configuration
Section titled “Configuration”| Field | Type | Required | Description |
|---|---|---|---|
| credentials_id | credentials | Yes | Hacienda credential (certificate + ATV) |
| factura | json | No | Invoice in JSON: receptor (cedula, tipoCedula, nombre), items (with precioUnitario and codigoTarifa: 08=13%, 01=0%). Optional sequential number. The issuer comes from the credential. If left empty, the input data from the previous node is used. |
Credentials
Section titled “Credentials”This module requires a hacienda credential type with the following fields:
- Certificate (.p12): the issuer’s digital certificate
- Certificate password
- Issuer’s cedula/tax ID (9 to 12 digits)
- ATV user and password (Hacienda’s IDP)
- Environment: sandbox (testing) or production
Output
Section titled “Output”{ "clave": "50601012600310123456700100001010000000001100000001", "consecutivo": "00100001010000000001", "estado": "accepted", "indEstado": "aceptado", "enProceso": false, "total": 113, "iva": 13, "detalle": "Comprobante aceptado", "xml": "...", "respuestaXml": "..."}Usage Example
Section titled “Usage Example”{ "credentials_id": "cred-hacienda-prod", "factura": { "receptor": { "cedula": "3101123456", "tipoCedula": "02", "nombre": "Cliente SA" }, "items": [ { "descripcion": "Consulting service", "cantidad": 1, "precioUnitario": 100, "codigoTarifa": "08" } ] }}- The 50-digit numeric key includes the country code (506) and is what identifies the document before Hacienda.
- VAT (IVA) is calculated using Hacienda’s rate catalog: 08 is the general 13% rate, 01 is exempt (0%).
- The signed XML is persisted before sending, so it can be audited or retried even if the send fails.
- If the status comes back as received or processing, reconcile it later with HaciendaConsultarEstado.
Related Nodes
Section titled “Related Nodes”- HaciendaEmitirNota - Issue a credit or debit note
- HaciendaConsultarEstado - Query the document’s status
- HaciendaRepresentacion - Generate the printable representation with QR