README
Pix-Utils
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.
🚀 Usage
Install the package in your project
yarn add pix-utils
Create Static Pix
import { createStaticPix } from 'pix-utils';
const pix = createStaticPix({
merchantName: 'Thales Ogliari',
merchantCity: 'Sao Miguel do Oeste',
pixKey: 'nubank@thalesog.com',
infoAdicional: 'Gerado por Pix-Utils',
transactionAmount: 1,
txid: '',
});
pix.toBRCode();
// 00020126650014br.gov.bcb.pix0119nubank@thalesog.com0220Gerado por Pix-Utils52040000530398654041.005802BR5914Thales Ogliari6015SAO MIGUEL DO O62070503***6304059A
Create Dynamic Pix
import { createDynamicPix } from 'pix-utils';
const pix = createDynamicPix({
merchantName: 'Thales Ogliari',
merchantCity: 'Sao Miguel do Oeste',
url: 'payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e87',
});
pix.toBRCode();
// 00020126740014br.gov.bcb.pix2552payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e875204000053039865802BR5914Thales Ogliari6015SAO MIGUEL DO O62070503***63040C64
Parse BRCode
const pix = parsePix(
'00020126650014br.gov.bcb.pix0119nubank@thalesog.com0220Gerado por Pix-Utils52040000530398654041.005802BR5914Thales Ogliari6015SAO MIGUEL DO O62070503***6304059A'
);
// {
// type: 'STATIC',
// merchantCategoryCode: '0000',
// transactionCurrency: '986',
// countryCode: 'BR',
// merchantName: 'Thales Ogliari',
// merchantCity: 'SAO MIGUEL DO O',
// pixKey: 'nubank@thalesog.com',
// transactionAmount: 1,
// infoAdicional: 'Gerado por Pix-Utils',
// txid: '***',
// toBRCode: [Function: toBRCode],
// toImage: [Function: toImage]
// }
Export to Base64 Image
const pix = parsePix(
'00020126650014br.gov.bcb.pix0119nubank@thalesog.com0220Gerado por Pix-Utils52040000530398654041.005802BR5914Thales Ogliari6015SAO MIGUEL DO O62070503***6304059A'
);
pix.toImage();
// data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOQAAADkCAYAAACIV4iNAAAAAklEQVR4AewaftIAAAwHSURBVO3BQW4sy7LgQDKh/W...
🛣️ Roadmap
- Generate payments based on parameters
- Static
- Dynamic
- Parse and validate EMV Codes
- Export generated/parsed payment to Image
- Export generated/parsed payment to EMV Code
- Fetch, parse and validate remote payloads from dynamic payments
- Verify if has already expired
- Improve tests
- Doccumentation with all methods, parameters and some examples
- Beautiful README with shields and stuff
- Add dynamic payment tests
🍰 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 🇧🇷