Skip to content

SunatRepresentacion

Generates the printable representation of an Electronic Payment Receipt (CPE) with its QR code. It can take an already-issued CPE (by tipo, serie and numero) and retrieve its real hash from the database, or receive a CPE in JSON to preview the representation before issuing it. Returns a self-contained HTML, printable to PDF, together with the QR content.

FieldTypeRequiredDescription
credentials_idcredentialsYesSUNAT credential (to get the issuer’s RUC and data)
tipotextNoDocument type (01 invoice, 03 boleta). Defaults to 01
serietextNoSeries of the already-issued CPE, to fetch it from the database
numerotextNoNumber of the already-issued CPE
cpejsonNoCPE in JSON to preview, if serie and numero are not provided

This module requires a sunat credential type with the following fields:

  • Certificate (.p12): the issuer’s digital certificate
  • Certificate password
  • Issuer RUC (11 digits)
  • SOL user and SOL password: SUNAT Clave SOL credentials
  • Mode: direct (to SUNAT) or OSE (Electronic Services Operator)
  • OSE URL, if mode is OSE
  • Environment: beta (testing) or production
{
"tipo": "01",
"serie": "F001",
"numero": 125,
"html": "...",
"qrText": "20123456789|01|F001|125|18.00|118.00|2026-08-04|6|20123456789|AbCdEf123...",
"qrImage": "data:image/png;base64,...",
"hash": "AbCdEf123..."
}
{
"credentials_id": "cred-sunat-prod",
"tipo": "01",
"serie": "F001",
"numero": "125"
}

The QR contains a pipe-delimited string with: issuer RUC, document type, serie, numero, IGV, total, issue date, receiver document type, receiver document number and the document’s hash (the signature’s DigestValue).

  • If serie and numero are provided, the node retrieves the already-issued, signed CPE from the database, with its real hash.
  • If no document has been issued yet, a cpe JSON can be passed to preview the representation; in that case the node signs the XML only to compute the QR hash, without sending it to SUNAT.
  • The HTML is self-contained (styles included) and meant to be printed or exported to PDF directly.