View Source QRNBU.Constants (NBU payment QR v0.3.3)
NBU QR Code specification constants.
This module centralizes all magic numbers and strings defined in NBU Resolution No. 97, August 19, 2025.
Categories
- Format identifiers
- Service types (UCT, ICT, XCT)
- Encoding codes
- Version numbers
- Field length limits
- Currency codes
References
NBU Resolution No. 97, dated August 19, 2025 Effective: November 1, 2025
Summary
Functions
Returns the base URL for NBU QR codes.
Returns the default currency code (UAH).
Returns the encoding code for the given encoding type.
Returns the encoding atom for a given encoding code.
Returns the version format number padded to 3 digits.
Returns the IBAN length for Ukraine.
Returns the format label (BCD - Banking QR Code Data).
Returns the line ending character(s) for a given version.
Returns the maximum payment purpose length for a given version.
Returns the maximum recipient name length for a given version.
Returns the service type code for ICT (Instant Credit Transfer).
Returns all supported service types.
Returns the service type code for UCT (Universal Credit Transfer).
Returns the service type code for XCT (Extended Credit Transfer).
Returns all supported currency codes.
Returns all supported version numbers.
Validates if a service type is supported for a given version.
Functions
@spec base_url() :: String.t()
Returns the base URL for NBU QR codes.
Used in V002 and V003 formats to generate URLs with Base64URL encoded data.
@spec currency() :: String.t()
Returns the default currency code (UAH).
Currently only UAH (Ukrainian Hryvnia) is supported.
@spec encoding_code(:utf8 | :cp1251) :: pos_integer()
Returns the encoding code for the given encoding type.
Encoding Codes
:utf8→ 1:cp1251→ 2
Examples
iex> QRNBU.Constants.encoding_code(:utf8)
1
iex> QRNBU.Constants.encoding_code(:cp1251)
2
@spec encoding_from_code(pos_integer()) :: :utf8 | :cp1251 | {:error, String.t()}
Returns the encoding atom for a given encoding code.
Examples
iex> QRNBU.Constants.encoding_from_code(1)
:utf8
iex> QRNBU.Constants.encoding_from_code(2)
:cp1251
@spec format_version(pos_integer()) :: String.t()
Returns the version format number padded to 3 digits.
Examples
iex> QRNBU.Constants.format_version(1)
"001"
iex> QRNBU.Constants.format_version(2)
"002"
iex> QRNBU.Constants.format_version(3)
"003"
@spec iban_length() :: pos_integer()
Returns the IBAN length for Ukraine.
Ukrainian IBANs are always exactly 29 characters.
@spec label() :: String.t()
Returns the format label (BCD - Banking QR Code Data).
This is the first line of all NBU QR codes.
@spec line_ending(pos_integer()) :: String.t()
Returns the line ending character(s) for a given version.
Line Endings
- V001/V002: CRLF (\r\n) - Windows-style
- V003: LF (\n) - Unix-style
Examples
iex> QRNBU.Constants.line_ending(1)
"\r\n"
iex> QRNBU.Constants.line_ending(3)
"\n"
@spec max_purpose_length(pos_integer()) :: pos_integer()
Returns the maximum payment purpose length for a given version.
Limits
- V001/V002: 140 characters
- V003: 280 characters
Examples
iex> QRNBU.Constants.max_purpose_length(2)
140
iex> QRNBU.Constants.max_purpose_length(3)
280
@spec max_recipient_length(pos_integer()) :: pos_integer()
Returns the maximum recipient name length for a given version.
Limits
- V001/V002: 70 characters
- V003: 140 characters
Examples
iex> QRNBU.Constants.max_recipient_length(1)
70
iex> QRNBU.Constants.max_recipient_length(3)
140
@spec service_ict() :: String.t()
Returns the service type code for ICT (Instant Credit Transfer).
Only available in V003 format.
@spec service_types() :: [String.t()]
Returns all supported service types.
Service Types
UCT- Universal Credit Transfer (standard payment)ICT- Instant Credit Transfer (instant payment, V003 only)XCT- Extended Credit Transfer (reserved for future use)
@spec service_uct() :: String.t()
Returns the service type code for UCT (Universal Credit Transfer).
This is the default service type for V001 and V002.
@spec service_xct() :: String.t()
Returns the service type code for XCT (Extended Credit Transfer).
Reserved for future use.
@spec supported_currencies() :: [String.t()]
Returns all supported currency codes.
Currently only UAH is supported per NBU specification.
@spec supported_versions() :: [pos_integer()]
Returns all supported version numbers.
Versions
1- V001 (legacy format, 9 fields)2- V002 (URL-based format, 9 fields)3- V003 (latest format, 17 fields)
@spec valid_service_for_version?(String.t(), pos_integer()) :: boolean()
Validates if a service type is supported for a given version.
Service Type Availability
- V001/V002: UCT only
- V003: UCT, ICT, XCT
Examples
iex> QRNBU.Constants.valid_service_for_version?("UCT", 1)
true
iex> QRNBU.Constants.valid_service_for_version?("ICT", 2)
false
iex> QRNBU.Constants.valid_service_for_version?("ICT", 3)
true