Giter Club home page Giter Club 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

hiagodotme avatar thalesog avatar carneloot avatar 0xflotus 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.