Giter Site home page Giter Site logo

thalesog / go-pix-utils Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 35 KB

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

License: MIT License

Go 100.00%
emv emv-qr go golang golang-library pix-copia-e-cola pix-qrcode pix-tools

go-pix-utils's Introduction

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:            "[email protected]",
    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 🇧🇷

go-pix-utils's People

Contributors

thalesog avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.