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
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\nParameters
data- Map with fields: recipient, iban, amount, recipient_code, purpose, functionopts- Options (encoding)
Returns
{:ok, formatted_string} or {:error, reason}.
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):
- Service label (BCD)
- Version format (002)
- Encoding code (1 or 2)
- Function code (UCT only)
- Empty (reserved)
- Recipient name
- IBAN
- Amount (optional, with UAH prefix)
- Recipient code (EDRPOU/Tax ID)
- Empty (reserved)
- Empty (reserved)
- Purpose
- Display (optional)
Parameters
data- Map with fields: recipient, iban, amount, recipient_code, purpose, functionopts- Options (encoding)
Returns
{:ok, qr_string} or {:error, reason}.
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):
- Service label (BCD)
- Version format (003)
- Encoding code (1 or 2)
- Function code (UCT/ICT/XCT)
- Empty (reserved)
- Recipient name
- IBAN
- Amount (optional, with UAH prefix)
- Recipient code (EDRPOU/Tax ID)
- Category/Purpose (ISO 20022)
- Reference (optional)
- Purpose
- Display text (optional)
- Field lock (optional, hex)
- Invoice validity datetime (optional)
- Invoice creation datetime (optional)
- Digital signature (reserved for future)
Parameters
data- Map with all V003 fieldsopts- Options (encoding)
Returns
{:ok, qr_string} or {:error, reason}.