View Source QRNBU.Versions.V001 (NBU payment QR v0.3.3)

NBU QR Code Version 001 structure with validation and encoding.

V001 is the plain text format with CRLF line endings as per EPC QR code specification.

Fields

Required Fields

  • :recipient - Name of the recipient (validated by RecipientValidator)
  • :iban - Bank account IBAN (validated by IBANValidator)
  • :recipient_code - Recipient's identification code (validated by RecipientCodeValidator)
  • :purpose - Payment purpose description (validated by PurposeValidator)

Optional Fields

  • :amount - Payment amount as Decimal (validated by AmountValidator)
  • :function - Payment function code: only :uct supported (default: :uct)
  • :encoding - Character encoding: only :utf8 supported (default: :utf8)

NBU Specification Restrictions

V001 has strict limitations per NBU specification:

  • Function code: Only :uct (Unattended Customer Transfer) is allowed
  • Encoding: Only :utf8 is allowed
  • For :ict or :xct function codes, use V003
  • For :cp1251 encoding, use V002 or V003

Examples

iex> QRNBU.Versions.V001.new(%{
...>   recipient: "ТОВ Компанія",
...>   iban: "UA213223130000026007233566001",
...>   recipient_code: "12345678",
...>   purpose: "Оплата товарів"
...> })
{:ok, %QRNBU.Versions.V001{...}}

iex> QRNBU.Versions.V001.new(%{
...>   recipient: "ТОВ Компанія",
...>   iban: "UA213223130000026007233566001",
...>   amount: Decimal.new("100.50"),
...>   recipient_code: "12345678",
...>   purpose: "Оплата товарів",
...>   function: :uct,
...>   encoding: :utf8
...> })
{:ok, %QRNBU.Versions.V001{...}}

Summary

Functions

Encodes a V001 structure into the NBU QR code data string.

Creates a new V001 QR code structure with validation.

Types

@type t() :: %QRNBU.Versions.V001{
  amount: Decimal.t() | nil,
  encoding: :utf8 | :cp1251,
  function: :uct | :ict | :xct,
  iban: String.t(),
  purpose: String.t(),
  recipient: String.t(),
  recipient_code: String.t()
}

Functions

@spec encode(t()) :: {:ok, String.t()} | {:error, String.t()}

Encodes a V001 structure into the NBU QR code data string.

Returns the plain text format with CRLF line endings as per EPC specification.

Parameters

  • v001 - V001 structure to encode

Returns

  • {:ok, String.t()} - Encoded QR data string
  • {:error, String.t()} - Encoding error

Examples

iex> {:ok, v001} = QRNBU.Versions.V001.new(%{...})
iex> QRNBU.Versions.V001.encode(v001)
{:ok, "                       \r\nBCD\r\n001\r\n1\r\nUCT\r\n..."}
@spec new(map()) :: {:ok, t()} | {:error, String.t()}

Creates a new V001 QR code structure with validation.

Parameters

  • attrs - Map with required and optional fields

Returns

  • {:ok, %QRNBU.Versions.V001{}} - Valid V001 structure
  • {:error, String.t()} - Validation error message

Examples

iex> QRNBU.Versions.V001.new(%{
...>   recipient: "ТОВ Компанія",
...>   iban: "UA213223130000026007233566001",
...>   recipient_code: "12345678",
...>   purpose: "Оплата товарів"
...> })
{:ok, %QRNBU.Versions.V001{}}

iex> QRNBU.Versions.V001.new(%{
...>   recipient: "",
...>   iban: "invalid",
...>   recipient_code: "123",
...>   purpose: ""
...> })
{:error, "Recipient name is required"}