go-pix

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2021 License: MIT

README

go-pix

GoDoc Test Status codecov Go Report Card

go-pix is a Go library for generating Pix transactions using Copy and Paste or QR codes.

About Pix

Generated QR code

Pix is a system created by the Brazilian Central Bank to allow instant payments. The new payment method allows immediate money transfer, 24 hours a day, 7 days a week, including weekends and holidays.

The address key is a way to identify the user’s account. There are four types of address keys that users can use:

  • CPF/CNPJ
  • Email address
  • Cellphone number
  • Random key – a set of random number, letters, and symbols

This key binds the basic information to the user’s complete account information, allowing users to send and receive money using only an address key.

Usage

import "github.com/fonini/go-pix/pix"
Generating a Copy and Paste code
options := pix.Options{
    Name: "Jonnas Fonini",
    Key: "jonnasfonini@gmail.com",
    City: "Marau",
    Amount: 20.67,
    Description: "Invoice #4",
}

copyPaste, err := pix.Pix(options)

if err != nil {
	panic(err)
}

fmt.Println(copyPaste) // will output: "00020126580014BR.GOV.BCB.PIX0122jonnasfonini@gmail.com0210Invoice #4520400005303986540520.675802BR5913Jonnas Fonini6005Marau62410503***50300017BR.GOV.BCB.BRCODE01051.0.06304CF13"
Generating a QR code

You can use the Copy and Paste code generated above to generate a QR code

options := QRCodeOptions{Size: 256, Content: copyPaste}

qrCode, err := pix.QRCode(options)

if err != nil {
	panic(err)
}

The qrCode is a byte array, containing a graphical representation of the Copy and Paste code in the form of a QR code.

Generated QR code

Tests

go test ./pix

Directories

Path Synopsis
Package pix generates Brazilian Pix Copy and Paste or QR Codes As a simple example: options := pix.Options{ Name: "Jonnas Fonini", Key: "jonnasfonini@gmail.com", City: "Marau", Amount: 20.67, Description: "Invoice #4", } copyPaste, err := pix.Pix(options) if err != nil { panic(err) } fmt.Println(copyPaste) // will output: "00020126580014BR.GOV.BCB.PIX0122jonnasfonini@gmail.com0210Invoice #4520400005303986540520.675802BR5913Jonnas Fonini6005Marau62410503***50300017BR.GOV.BCB.BRCODE01051.0.06304CF13"
Package pix generates Brazilian Pix Copy and Paste or QR Codes As a simple example: options := pix.Options{ Name: "Jonnas Fonini", Key: "jonnasfonini@gmail.com", City: "Marau", Amount: 20.67, Description: "Invoice #4", } copyPaste, err := pix.Pix(options) if err != nil { panic(err) } fmt.Println(copyPaste) // will output: "00020126580014BR.GOV.BCB.PIX0122jonnasfonini@gmail.com0210Invoice #4520400005303986540520.675802BR5913Jonnas Fonini6005Marau62410503***50300017BR.GOV.BCB.BRCODE01051.0.06304CF13"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL