View Source QRNBU.Encoders.Formatter (NBU payment QR v0.3.3)

Formats NBU QR code data strings for different versions.

Handles the specific format requirements for each version:

  • V001: Plain text format with CRLF line endings
  • V002: Base64URL format with prefix
  • V003: Base64URL format with prefix (extended fields)

NBU QR Code Prefixes

  • V002: https://qr.bank.gov.ua/
  • V003: https://qr.bank.gov.ua/

Summary

Functions

Formats QR data for V001 (plain text with CRLF).

Formats QR data for V002 (Base64URL with prefix).

Formats QR data for V003 (Base64URL with prefix and extended fields).

Types

@type encoding() :: :utf8 | :cp1251
@type function_code() :: :uct | :ict | :xct
@type version() :: 1 | 2 | 3

Functions

Link to this function

format_v001(data, opts \\ [])

View Source
@spec format_v001(
  map(),
  keyword()
) :: {:ok, String.t()} | {:error, String.t()}

Formats QR data for V001 (plain text with CRLF).

Format Structure

[23 spaces]\r\n
BCD\r\n
001\r\n
1\r\n
UCT\r\n
\r\n
{recipient}\r\n
{iban}\r\n
{amount with UAH prefix}\r\n
{recipient_code}\r\n
\r\n
\r\n
{purpose}\r\n
\r\n

Parameters

  • data - Map with fields: recipient, iban, amount, recipient_code, purpose, function
  • opts - Options (encoding)

Returns

{:ok, formatted_string} or {:error, reason}.

Link to this function

format_v002(data, opts \\ [])

View Source
@spec format_v002(
  map(),
  keyword()
) :: {:ok, String.t()} | {:error, String.t()}

Formats QR data for V002 (Base64URL with prefix).

Format Structure

https://qr.bank.gov.ua/{base64url_encoded_data}

Data String Structure

Fields separated by LF (0x0A):

  1. Service label (BCD)
  2. Version format (002)
  3. Encoding code (1 or 2)
  4. Function code (UCT only)
  5. Empty (reserved)
  6. Recipient name
  7. IBAN
  8. Amount (optional, with UAH prefix)
  9. Recipient code (EDRPOU/Tax ID)
  10. Empty (reserved)
  11. Empty (reserved)
  12. Purpose
  13. Display (optional)

Parameters

  • data - Map with fields: recipient, iban, amount, recipient_code, purpose, function
  • opts - Options (encoding)

Returns

{:ok, qr_string} or {:error, reason}.

Link to this function

format_v003(data, opts \\ [])

View Source
@spec format_v003(
  map(),
  keyword()
) :: {:ok, String.t()} | {:error, String.t()}

Formats QR data for V003 (Base64URL with prefix and extended fields).

Format Structure

https://qr.bank.gov.ua/{base64url_encoded_data}

Data String Structure (17 fields)

Fields separated by LF (0x0A):

  1. Service label (BCD)
  2. Version format (003)
  3. Encoding code (1 or 2)
  4. Function code (UCT/ICT/XCT)
  5. Empty (reserved)
  6. Recipient name
  7. IBAN
  8. Amount (optional, with UAH prefix)
  9. Recipient code (EDRPOU/Tax ID)
  10. Category/Purpose (ISO 20022)
  11. Reference (optional)
  12. Purpose
  13. Display text (optional)
  14. Field lock (optional, hex)
  15. Invoice validity datetime (optional)
  16. Invoice creation datetime (optional)
  17. Digital signature (reserved for future)

Parameters

  • data - Map with all V003 fields
  • opts - Options (encoding)

Returns

{:ok, qr_string} or {:error, reason}.