Giter VIP home page Giter VIP logo

gpix's Introduction

GPIX

GPIX is a library that facilitates the generation of dynamic and static br-codes for the central bank of Brazil PIX arrangement.

GPIX GitHub issues GitHub forks GitHub stars GitHub license

How to use

First install the library:

npm i gpix

Then start with PIX.static() or PIX.dinamic() and follow the examples below:

const { PIX } = require('gpix/dist');

// Example 01: BRCODE static with defined amount.
let pix = PIX.static()
    .setReceiverName('Hiago Silva Souza')
    .setReceiverCity('Rio Preto')
    .setReceiverZipCode('15082131') // optional
    .setKey('fcba8826-cbff-46e2-8c40-1b39896402a8')
    .setIdentificator('123') // optional
    .setDescription('Donation with defined amount - GPIX') // optional
    .isUniqueTransaction(true) // optional
    .setAmount(5.0) // optional

console.log('\nDonation with defined amount - GPIX >>>>\n', pix.getBRCode())

// Example 02: Static BRCODE, with no defined amount (user types amount) and the defined identifier is 123
pix = PIX.static()
    .setReceiverName('Hiago Silva Souza')
    .setReceiverCity('Rio Preto')
    .setKey('[email protected]')
    .setDescription('Donation without defined amount - GPIX') // optional

console.log('Donation without defined amount - GPIX >>>>\n', pix.getBRCode())


// Example 03: BRCODE dinamic
let dpix = PIX.dinamic()
    .setReceiverName('Minha Empresa LTDA')
    .setReceiverCity('Rio Preto')
    .setLocation('url-location-psp')
    .setAmount(10.4) // some PSP are not recovering the amount through the charge. Then temporarily enter the amount to avoid problems.

console.log('\nBRCODE dinamic - GPIX >>>>\n', dpix.getBRCode());

// Generating QRCode in base64
(async () => {

    //console.log('QRCODE Static >>> ', await pix.getQRCode())
    //console.log('QRCODE Dinamic >>> ', await dpix.getQRCode())

})();

// Saving QRCode to physical file
(async () => {

    pix.setDescription('Free Donation / QRCODE - GPIX') // optional


    if(await pix.saveQRCodeFile('./qrcode.png')) {
        console.log('success in saving static QR-code')
    } else {
        console.log('error saving QR-code')
    }
})();

Did this lib help you?

If this lib helped you feel free to make a donation =), it can be R$ 0.50 hahahaha. To do so, just read the qrcode below, it was generated with the lib sample file.

QRCode Doação

Author

Hiago Silva Souza <[email protected]> | https://hiago.me/

gpix's People

Contributors

0xflotus avatar carneloot avatar hiagodotme avatar thalesog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpix's Issues

normalizeText removing _ from email type keys

Olá pessoal!
A função _normalizeText está removendo o _ de chaves do tipo email, tornando assim o resultado inválido
Segue um exemplo para reproduzir a situação:

let pix = PIX.static()
    .setReceiverName('Hiago Silva Souza')
    .setReceiverCity('Rio Preto')
    .setKey('[email protected]')
    .setDescription('Donation with defined amount - GPIX')
    .setReceiverZipCode('15082131')
    .setIdentificator('123')
    .setAmount(5.0)

Esperado:

00020101021126780014br.gov.bcb.pix0117hiago_me@hiago.me0235Donation with defined amount - GPIX52040000530398654045.005802BR5917Hiago Silva Souza6009Rio Preto61081508213162070503123630450CE

Recebido:

00020101021126780014br.gov.bcb.pix0117hiago [email protected] with defined amount - GPIX52040000530398654045.005802BR5917Hiago Silva Souza6009Rio Preto6108150821316207050312363048F67

Ajustei a função para permitir o caractere no PR #12

_normalizeText removendo @ em chaves do tipo email

Olá pessoal!
Notei que ao criar qrcodes estáticos, a função _normalizeText está removendo o @ do email, fazendo com que o resultado seja um BRCode/QRCode inválido.

Pelo que analisei, apenas adicionando o @ no seguinte código:
Linha 82 -- lib/pix.ts

return str['normalize']("NFD").replace(/[^A-Z0-9$@%*+-\./:]/gi, ' ')

o problema é solucionado.
@hiagodotme pode nos auxiliar nisso?

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.