View Source UkraineNbuqrEx.QrData.Builder (ukraine_nbuqr v0.1.0)
A module for building National Bank of Ukraine (NBU) payment Quick Response (QR) code data structures.
Summary
Functions
Builds a QR data struct from the given parameters.
Functions
@spec build(params :: Keyword.t()) :: UkraineNbuqrEx.QrData.t()
Builds a QR data struct from the given parameters.
This builder validates and formats payment information according to NBU QR code specifications. It enforces required fields and length restrictions for various payment details.
Length Restrictions
The following maximum length restrictions are enforced:
- recipient: 70 characters
- amount: 15 characters
- tax_id: 10 characters
- iban: 34 characters
- purpose: 140 characters
Usage
iex> params = [
...> iban: "UA213223130000026007233566001",
...> tax_id: "12345678",
...> amount: "123.45",
...> recipient: "Company Name",
...> purpose: "Payment for services"
...> ]
...> UkraineNbuqrEx.QrData.Builder.build(params)
{:ok, %UkraineNbuqrEx.QrData{recipient: "Company Name", iban: "UA213223130000026007233566001", amount: "UAH123.45", tax_id: "12345678", purpose: "Payment for services"}} = UkraineNbuqrEx.QrData.Builder.build(params)
Required Parameters
All of the following parameters are required:
:iban
- Ukrainian IBAN (must start with "UA"):tax_id
- Valid Ukrainian tax identification number:amount
- Payment amount (will be normalized):recipient
- Name of the payment recipient:purpose
- Purpose of payment
The builder will return an error if any required parameter is missing or invalid.
Validation
- IBAN is validated to ensure it's a valid Ukrainian IBAN
- Tax ID is validated using the UkraineTaxidEx library
- Amount is validated and normalized to ensure proper format
- All text fields are truncated to their maximum allowed lengths