Skip to content

Set of tools to parse, generate and validate payments of Brazil Instant Payment System (Pix) in Golang

License

Notifications You must be signed in to change notification settings

thalesog/go-pix-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pix-utils

Go-Pix-Utils

License Stars GoDoc Go Report Card

⚠️ This package is under development and is not ready for production

Pix-Utils is a set of tools to parse, generate and validate payments of Brazil Instant Payment System (Pix), making fast and simple to handle charges and proccess then in your project. Originally developed using TypeScript, this is the Go version of the library.

🚀 Features

  • Parse Static Pix EMV
  • Parse Dynamic Pix EMV
  • Validate CRC16
  • Generate Static Pix EMV
  • Generate Dynamic Pix EMV
  • Generate QRCode Image from EMV or Pix

This library also normalize the input data to the Pix standard, so you don't need to worry about it. It follows the Pix Specification, that mainly contains the following guidelines about EMV data structure:

  • Merchant Name: 25 characters
  • Merchant City: 15 characters
  • Pix Key/Payload URL: 77 characters

📦 Installation

Install the package in your project

go get github.com/thalesog/go-pix-utils

Create Static Pix

package main

import (
  "fmt"
  "github.com/thalesog/go-pix-utils/pixUtils"
)

func main() {
  pix := pixUtils.CreateStaticPix(pixUtils.CreateStaticPixParams{
    MerchantName:      "Thales Ogliari",
    MerchantCity:      "São Miguel do Oeste",
    PixKey:            "thalesog@me.com",
    TransactionAmount: 10.00,
    AditionalData:     "Pedido 123",
  })

  fmt.Printf("Pix Type: %s \n", pix.Type)
  fmt.Printf("EMV Code: %s \n", pix.Raw)
  fmt.Printf("Pix Elements: %v \n", pix.Elements)
}

Create Dynamic Pix

package main

import (
  "fmt"
  "github.com/thalesog/go-pix-utils/pixUtils"
)

func main() {
  pix := pixUtils.CreateDynamicPix(pixUtils.CreateDynamicPixParams{
    MerchantName: "Thales Ogliari",
    MerchantCity: "São Miguel do Oeste",
    Url:          "https://pix.thalesogliari.com.br",
  })

  fmt.Printf("Pix Type: %s \n", pix.Type)
  fmt.Printf("EMV Code: %s \n", pix.Raw)
  fmt.Printf("Pix Elements: %v \n", pix.Elements)
}

🍰 Contributing

Please contribute using GitHub Flow. Create a branch, add commits, and open a pull request.

📝 License

This project is under MIT license.

Developed with 💚 by @thalesog 🇧🇷