# `SefazNfe.MDFe.QRCode`
[🔗](https://github.com/devaction-labs/sefaz_nfe/blob/v0.5.0/lib/sefaz_nfe/mdfe/qr_code.ex#L1)

`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.

# `put_supl`

```elixir
@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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
