Skip to content

HaciendaEmitirFactura

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.

FieldTypeRequiredDescription
credentials_idcredentialsYesHacienda credential (certificate + ATV)
facturajsonNoInvoice 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.

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
{
"clave": "50601012600310123456700100001010000000001100000001",
"consecutivo": "00100001010000000001",
"estado": "accepted",
"indEstado": "aceptado",
"enProceso": false,
"total": 113,
"iva": 13,
"detalle": "Comprobante aceptado",
"xml": "...",
"respuestaXml": "..."
}
{
"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.