SefazNfe.MDFe.QRCode (sefaz_nfe v0.5.0)

Copy Markdown View Source

infMDFeSupl with qrCodMDFe, which an MDF-e 3.00 must carry.

The text is the SVRS portal address with the key and the environment:

{base}?chMDFe={chMDFe}&tpAmb={tpAmb}

base is data (qr_code of priv/endpoints/mdfe_3.00.json, see SefazNfe.Endpoints.mdfe_qr_code_url/1). In off-line contingency (tpEmis 2) the emitter also signs the key and the text gains &sign={base64}: the RSA-SHA1 signature, with the certificate's key, of the 44 digit key as text (NFePHP Factories\QRCode: base64_encode($certificate->sign($chMDFe))). The base64 is not URL-encoded, as NFePHP does and the XSD pattern allows.

The element goes after infMDFe and before Signature; it is not covered by the signature, whose only Reference is infMDFe's Id, so it is spliced into the already signed bytes by byte offset (AD-011). A document that already has an infMDFeSupl is returned as it is.

Summary

Functions

Adds infMDFeSupl to the signed MDF-e xml.

The QR code text. sign is nil for a normal emission, or the base64 signature of the key for contingency.

Functions

put_supl(xml, cert, environment)

@spec put_supl(String.t(), SefazNfe.Certificate.t(), SefazNfe.Endpoints.environment()) ::
  {:ok, String.t()} | {:error, term()}

Adds infMDFeSupl to the signed MDF-e xml.

tpEmis 1 (normal) and 2 (off-line contingency) are supported; anything else is {:error, {:unsupported, {:tp_emis, value}}}.

qr_code(base, key, tp_amb, sign)

@spec qr_code(String.t(), String.t(), String.t(), String.t() | nil) :: String.t()

The QR code text. sign is nil for a normal emission, or the base64 signature of the key for contingency.