https://github.com/fonini/go-pix
go-pix is a Go library for generating Pix Copy and Paste or QR codes. 💳 💰
https://github.com/fonini/go-pix
brazil brcode go go-modules golang hacktoberfest library money
Last synced: about 1 year ago
JSON representation
go-pix is a Go library for generating Pix Copy and Paste or QR codes. 💳 💰
- Host: GitHub
- URL: https://github.com/fonini/go-pix
- Owner: fonini
- License: mit
- Created: 2021-02-27T01:28:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-24T21:20:32.000Z (about 1 year ago)
- Last Synced: 2025-04-02T11:01:59.149Z (about 1 year ago)
- Topics: brazil, brcode, go, go-modules, golang, hacktoberfest, library, money
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 80
- Watchers: 4
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# go-pix
[](https://pkg.go.dev/github.com/fonini/go-pix/pix)
[](https://github.com/fonini/go-pix/actions?query=workflow%3Atests)
[](https://codecov.io/gh/fonini/go-pix)
[](https://goreportcard.com/report/github.com/fonini/go-pix)
[](https://opensource.org/licenses/MIT)
go-pix is a Go library for generating [Pix](https://www.bcb.gov.br/estabilidadefinanceira/pix) transactions using Copy and Paste or QR codes.
## About Pix

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
```go
import "github.com/fonini/go-pix/pix"
```
### Generating a Copy and Paste code
```go
options := pix.Options{
Name: "Jonnas Fonini",
Key: "jonnasfonini@gmail.com",
City: "Marau",
Amount: 20.67, // optional
Description: "Invoice #4", // optional
TransactionID: "***", // optional
}
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"
optionsFromCode, err := pix.ReadPix(copyPaste)
if err != nil {
panic(err)
}
fmt.Println(optionsFromCode)
```
### Generating a QR code from a Copy and Paste code
You can use the Copy and Paste code generated above to generate a QR code
```go
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.

## Banks tested
* Caixa Econômica Federal
* Nubank
* PicPay
* PagSeguro
* Itaú
* Mercado Pago
## Tests
```sh
go test ./pix
```
## License
This open-sourced software is licensed under the [MIT license](https://opensource.org/licenses/MIT).