igorgbr

igorgbr

Hi everyone! I just published my first library on Hex: pix_brcode.

What is Pix? Pix is Brazil’s instant payment system, run by the Central Bank. It is used by most of the population and moves billions of transactions a month. Payments are usually made by scanning a QR code or pasting its text version, the “copia e cola” (copy and paste) code. That text is a BR Code: an EMV QR Code (Merchant-Presented Mode) payload with Pix-specific fields and a CRC16 checksum.

Why? Libraries for this are common in the JS ecosystem, but I couldn’t find an actively maintained Elixir package focused on generating and parsing Pix payloads, so I built one.

What it does (v0.1.0):

  • Generates static payloads (Pix key, optional amount, txid, description)
  • Generates dynamic payloads (URL provided by the receiver’s bank)
  • Parses any payload into a struct, validating CRC, structure and the Pix GUI
  • Validates Pix key formats (CPF, CNPJ, phone, e-mail, random key)
  • Zero runtime dependencies
iex> PixBrcode.encode(%{
...>   key: "123e4567-e89b-12d3-a456-426614174000",
...>   amount: 1050,
...>   merchant_name: "Fulano de Tal",
...>   merchant_city: "Sao Paulo"
...> })
{:ok, "00020126580014br.gov.bcb.pix0136123e4567-..."}

iex> PixBrcode.decode(payload)
{:ok, %PixBrcode.Payload{type: :static, key: "123e4567-...", amount: "10.50", ...}}

Tested with real banks: a payload generated by the library was paid from Nubank and received at Itaú, and payloads generated by both banks’ apps are parsed correctly. That test caught something the spec alone didn’t: Nubank sends the GUI in uppercase (BR.GOV.BCB.PIX), so decoding is case-insensitive.

Out of scope for now: QR code image generation (the README shows how to do it with eqrcode) and calls to banks’ Pix APIs.

Feedback, issues and PRs are very welcome, especially from anyone already handling Pix in production.

Hex: pix_brcode | Hex
Docs: pix_brcode v0.1.0 — Documentation

Where Next? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews