New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gpix

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gpix - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

dist/lib/idinamic.d.ts

56

dist/examples.js

@@ -40,26 +40,27 @@ "use strict";

var pix_1 = require("./lib/pix");
// Exemplo 01: BRCODE estático, com valor definido
var pix = pix_1.PIX.estatico();
pix.setNomeRecebedor('Hiago Silva Souza');
pix.setCidadeRecebedor('Rio Preto');
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8');
pix.setIdentificador('123'); // opcional
pix.setCepRecebedor('15082131'); // opcional
pix.setDescricao('Doação com valor fixo - GPIX'); // opcional
pix.setValor(5.0); // opcional
console.log('\nDoação com valor fixo - GPIX >>>>\n', pix.getBRCode());
pix = pix_1.PIX.estatico();
// Exemplo 02: BRCODE estático, sem valor definido (usuário digita valor) e o identificador definido é 123
pix.setNomeRecebedor('Hiago Silva Souza');
pix.setCidadeRecebedor('Rio Preto');
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8');
pix.setDescricao('Doação Livre - GPIX'); // opcional
console.log('Doação Livre - GPIX >>>>\n', pix.getBRCode());
// Exemplo 03: BRCODE dinâmico
var dpix = pix_1.PIX.dinamico();
dpix.setNomeRecebedor('Logical Delivery LTDA');
dpix.setCidadeRecebedor('Rio Preto');
dpix.setUrlPadraoPix('url-location-instituicao');
console.log('\nBRCODE dinâmico - GPIX >>>>\n', dpix.getBRCode());
// Gerando QRCodes em base64
// Exemplo 01: BRCODE static with defined amount.
var pix = pix_1.PIX.static();
pix.setReceiverName('Hiago Silva Souza');
pix.setReceiverCity('Rio Preto');
pix.setReceiverZipCode('15082131'); // opcional
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8');
pix.setIdentificator('123'); // opcional
pix.setDescription('Donation with defined amount - GPIX'); // opcional
pix.setAmount(5.0); // opcional
console.log('\nDonation with defined amount - GPIX >>>>\n', pix.getBRCode());
pix = pix_1.PIX.static();
// Exemplo 02: Static BRCODE, with no defined amount (user types amount) and the defined identifier is 123
pix.setReceiverName('Hiago Silva Souza');
pix.setReceiverCity('Rio Preto');
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8');
pix.setDescription('Donation without defined amount - GPIX'); // optional
console.log('Donation without defined amount - GPIX >>>>\n', pix.getBRCode());
// Exemplo 03: BRCODE dinamic
var dpix = pix_1.PIX.dinamic();
dpix.setReceiverName('Minha Empresa LTDA');
dpix.setReceiverCity('Rio Preto');
dpix.setLocation('url-location-psp');
console.log('\nBRCODE dinamic - GPIX >>>>\n', dpix.getBRCode());
// Gerando QRCode em base64
// Generating QRCode in base64
(function () { return __awaiter(void 0, void 0, void 0, function () {

@@ -70,2 +71,3 @@ return __generator(this, function (_a) {

}); })();
// Saving QRCode to physical file
// Salvando QRCode em arquivo físico

@@ -76,10 +78,10 @@ (function () { return __awaiter(void 0, void 0, void 0, function () {

case 0:
pix.setDescricao('Doacao Livre / QRCODE - GPIX'); // opcional
pix.setDescription('Free Donation / QRCODE - GPIX'); // opcional
return [4 /*yield*/, pix.saveQRCodeFile('./qrcode.png')];
case 1:
if (_a.sent()) {
console.log('sucesso ao salvar qr-code estático');
console.log('success in saving static QR-code');
}
else {
console.log('erro ao salvar qr-code');
console.log('error saving QR-code');
}

@@ -86,0 +88,0 @@ return [2 /*return*/];

@@ -18,3 +18,3 @@ "use strict";

}
return ((crc ^ 0) & 0xffff).toString(16).toUpperCase();
return (((crc ^ 0) & 0xffff).toString(16).toUpperCase()).padStart(4, "0");
};

@@ -21,0 +21,0 @@ return CRC;

@@ -1,27 +0,27 @@

import { IDinamico } from "./idinamico";
import { IEstatico } from "./iestatico";
export declare class PIX implements IDinamico, IEstatico {
private _is_transacao_unica;
private _chave;
private _nome_recebedor;
private _cidade_recebedor;
private _valor;
private _cep_recebedor;
private _identificador_transacao;
private _descricao_transacao;
private _url_padrao_pix;
import { IDinamic } from "./idinamic";
import { IStatic } from "./istatic";
export declare class PIX implements IDinamic, IStatic {
private _is_unique_transaction;
private _key;
private _receiver_name;
private _receiver_city;
private _amout;
private _zip_code;
private _identificator;
private _description;
private _location;
private constructor();
static estatico(): IEstatico;
static dinamico(): IDinamico;
setUrlPadraoPix(url_padrao_pix: string): void;
setChave(chave: string): void;
setCepRecebedor(cep: string): void;
setNomeRecebedor(nome_recebedor: string): void;
setIdentificador(identificador_transacao: string): void;
setDescricao(descricao_transacao: string): void;
setCidadeRecebedor(cidade_recebedor: string): void;
setValor(valor: number): void;
isTransacaoUnica(_is_transacao_unica: boolean): void;
static static(): IStatic;
static dinamic(): IDinamic;
setLocation(location: string): void;
setKey(key: string): void;
setReceiverZipCode(zipCode: string): void;
setReceiverName(name: string): void;
setIdentificator(identificator: string): void;
setDescription(description: string): void;
setReceiverCity(city: string): void;
setAmount(amout: number): void;
isUniqueTransaction(is_unique_transaction: boolean): void;
private _rightPad;
private _normalizarTexto;
private _normalizeText;
getBRCode(): string;

@@ -28,0 +28,0 @@ getQRCode(): Promise<string | null>;

@@ -45,50 +45,50 @@ "use strict";

function PIX() {
this._is_transacao_unica = false;
this._chave = '';
this._nome_recebedor = '';
this._cidade_recebedor = '';
this._valor = 0;
this._cep_recebedor = '';
this._identificador_transacao = '';
this._descricao_transacao = '';
this._url_padrao_pix = '';
this._is_unique_transaction = false;
this._key = '';
this._receiver_name = '';
this._receiver_city = '';
this._amout = 0;
this._zip_code = '';
this._identificator = '';
this._description = '';
this._location = '';
}
PIX.estatico = function () {
PIX.static = function () {
return new PIX();
};
PIX.dinamico = function () {
PIX.dinamic = function () {
return new PIX();
};
PIX.prototype.setUrlPadraoPix = function (url_padrao_pix) {
this._url_padrao_pix = url_padrao_pix.replace('https://', '');
PIX.prototype.setLocation = function (location) {
this._location = location.replace('https://', '');
};
PIX.prototype.setChave = function (chave) {
this._chave = chave;
PIX.prototype.setKey = function (key) {
this._key = key;
};
PIX.prototype.setCepRecebedor = function (cep) {
this._cep_recebedor = cep;
PIX.prototype.setReceiverZipCode = function (zipCode) {
this._zip_code = zipCode;
};
PIX.prototype.setNomeRecebedor = function (nome_recebedor) {
if (nome_recebedor.length > 25)
PIX.prototype.setReceiverName = function (name) {
if (name.length > 25)
throw 'A quantidade máxima de caracteres para o nome do recebedor é 25';
this._nome_recebedor = nome_recebedor;
this._receiver_name = name;
};
PIX.prototype.setIdentificador = function (identificador_transacao) {
this._identificador_transacao = identificador_transacao;
PIX.prototype.setIdentificator = function (identificator) {
this._identificator = identificator;
};
PIX.prototype.setDescricao = function (descricao_transacao) {
this._descricao_transacao = descricao_transacao;
PIX.prototype.setDescription = function (description) {
this._description = description;
};
PIX.prototype.setCidadeRecebedor = function (cidade_recebedor) {
if (cidade_recebedor.length > 15)
PIX.prototype.setReceiverCity = function (city) {
if (city.length > 15)
throw 'A quantidade máxima de caracteres para a cidade do recebedor é 15';
this._cidade_recebedor = cidade_recebedor;
this._receiver_city = city;
};
PIX.prototype.setValor = function (valor) {
if (valor.toFixed(2).toString().length > 13)
PIX.prototype.setAmount = function (amout) {
if (amout.toFixed(2).toString().length > 13)
throw 'A quantidade máxima de caracteres para o valor é 13';
this._valor = valor;
this._amout = amout;
};
PIX.prototype.isTransacaoUnica = function (_is_transacao_unica) {
this._is_transacao_unica = _is_transacao_unica;
PIX.prototype.isUniqueTransaction = function (is_unique_transaction) {
this._is_unique_transaction = is_unique_transaction;
};

@@ -98,3 +98,3 @@ PIX.prototype._rightPad = function (value) {

};
PIX.prototype._normalizarTexto = function (value) {
PIX.prototype._normalizeText = function (value) {
var str = value.toUpperCase().replace('Ç', 'C');

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

// caso seja transação única
if (this._is_transacao_unica)
if (this._is_unique_transaction)
lines.push('0102 12');
//#region Merchant Account Information - PIX
var descricao_transacao = this._normalizarTexto(this._descricao_transacao || '');
var descricao_transacao = this._normalizeText(this._description || '');
var extra = 14 + 8;

@@ -118,13 +118,13 @@ if (descricao_transacao) {

}
if (this._chave) {
var conteudoChave = this._normalizarTexto(this._chave);
lines.push("26" + (conteudoChave.length + extra));
if (this._key) {
var contentKey = this._normalizeText(this._key);
lines.push("26" + (contentKey.length + extra));
lines.push("\t0014 br.gov.bcb.pix");
lines.push("\t01" + this._rightPad(conteudoChave.length) + " " + conteudoChave);
lines.push("\t01" + this._rightPad(contentKey.length) + " " + contentKey);
}
else if (this._url_padrao_pix) {
var padraoUrl = this._url_padrao_pix;
lines.push("26" + (padraoUrl.length + extra));
else if (this._location) {
var location_1 = this._location;
lines.push("26" + (location_1.length + extra));
lines.push("\t0014 br.gov.bcb.pix");
lines.push("\t25" + this._rightPad(padraoUrl.length) + " " + padraoUrl);
lines.push("\t25" + this._rightPad(location_1.length) + " " + location_1);
}

@@ -135,3 +135,3 @@ else {

// descricao
if (this._descricao_transacao) {
if (this._description) {
lines.push("\t02" + this._rightPad(descricao_transacao.length) + " " + descricao_transacao);

@@ -147,5 +147,5 @@ }

//#region Transaction Amount
if (this._valor) {
var valor = this._normalizarTexto(this._valor.toFixed(2).toString());
if (this._valor > 0)
if (this._amout) {
var valor = this._normalizeText(this._amout.toFixed(2).toString());
if (this._amout > 0)
lines.push("54" + this._rightPad(valor.length) + " " + valor);

@@ -159,20 +159,20 @@ }

//#region Merchant Name
var nome_recebedor = this._normalizarTexto(this._nome_recebedor);
lines.push("59" + this._rightPad(nome_recebedor.length) + " " + nome_recebedor);
var receiver_name = this._normalizeText(this._receiver_name);
lines.push("59" + this._rightPad(receiver_name.length) + " " + receiver_name);
//#endregion
//#region Merchant City
var cidade_recebedor = this._normalizarTexto(this._cidade_recebedor);
lines.push("60" + this._rightPad(cidade_recebedor.length) + " " + cidade_recebedor);
var receiver_city = this._normalizeText(this._receiver_city);
lines.push("60" + this._rightPad(receiver_city.length) + " " + receiver_city);
//#endregion
//#region Postal Code
if (this._cep_recebedor) {
var codigo_postal = this._normalizarTexto(this._cep_recebedor);
lines.push("61" + this._rightPad(codigo_postal.length) + " " + codigo_postal);
if (this._zip_code) {
var zip_code = this._normalizeText(this._zip_code);
lines.push("61" + this._rightPad(zip_code.length) + " " + zip_code);
}
//#endregion
//#region Additional Data Field
if (this._identificador_transacao) {
var identificador_transacao = this._normalizarTexto(this._identificador_transacao);
lines.push("62" + (identificador_transacao.length + 38));
lines.push("\t05" + this._rightPad(identificador_transacao.length) + " " + identificador_transacao);
if (this._identificator) {
var transaction_identificator = this._normalizeText(this._identificator);
lines.push("62" + (transaction_identificator.length + 38));
lines.push("\t05" + this._rightPad(transaction_identificator.length) + " " + transaction_identificator);
lines.push("\t5030");

@@ -184,3 +184,3 @@ lines.push("\t\t0017 br.gov.bcb.brcode");

//#region Additional Data Field
if (this._url_padrao_pix) {
if (this._location) {
lines.push("6207");

@@ -187,0 +187,0 @@ lines.push("\t0503 ***");

import { PIX } from "./lib/pix";
// Exemplo 01: BRCODE estático, com valor definido
let pix = PIX.estatico();
pix.setNomeRecebedor('Hiago Silva Souza')
pix.setCidadeRecebedor('Rio Preto')
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setIdentificador('123') // opcional
pix.setCepRecebedor('15082131') // opcional
pix.setDescricao('Doação com valor fixo - GPIX') // opcional
pix.setValor(5.0) // opcional
// Exemplo 01: BRCODE static with defined amount.
let pix = PIX.static();
pix.setReceiverName('Hiago Silva Souza')
pix.setReceiverCity('Rio Preto')
pix.setReceiverZipCode('15082131') // opcional
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setIdentificator('123') // opcional
pix.setDescription('Donation with defined amount - GPIX') // opcional
pix.setAmount(5.0) // opcional
console.log('\nDoação com valor fixo - GPIX >>>>\n', pix.getBRCode())
console.log('\nDonation with defined amount - GPIX >>>>\n', pix.getBRCode())
pix = PIX.estatico();
// Exemplo 02: BRCODE estático, sem valor definido (usuário digita valor) e o identificador definido é 123
pix.setNomeRecebedor('Hiago Silva Souza')
pix.setCidadeRecebedor('Rio Preto')
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setDescricao('Doação Livre - GPIX') // opcional
pix = PIX.static();
// Exemplo 02: Static BRCODE, with no defined amount (user types amount) and the defined identifier is 123
pix.setReceiverName('Hiago Silva Souza')
pix.setReceiverCity('Rio Preto')
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setDescription('Donation without defined amount - GPIX') // optional
console.log('Doação Livre - GPIX >>>>\n', pix.getBRCode())
console.log('Donation without defined amount - GPIX >>>>\n', pix.getBRCode())
// Exemplo 03: BRCODE dinâmico
let dpix = PIX.dinamico();
dpix.setNomeRecebedor('Logical Delivery LTDA')
dpix.setCidadeRecebedor('Rio Preto')
dpix.setUrlPadraoPix('url-location-instituicao')
console.log('\nBRCODE dinâmico - GPIX >>>>\n', dpix.getBRCode());
// Exemplo 03: BRCODE dinamic
let dpix = PIX.dinamic();
dpix.setReceiverName('Minha Empresa LTDA')
dpix.setReceiverCity('Rio Preto')
dpix.setLocation('url-location-psp')
console.log('\nBRCODE dinamic - GPIX >>>>\n', dpix.getBRCode());
// Gerando QRCodes em base64
// Gerando QRCode em base64
// Generating QRCode in base64
(async () => {
//console.log('QRCODE Estático >>> ', await pix.getQRCode())
//console.log('QRCODE Dinamico >>> ', await dpix.getQRCode())
//console.log('QRCODE Static >>> ', await pix.getQRCode())
//console.log('QRCODE Dinamic >>> ', await dpix.getQRCode())
})();
// Saving QRCode to physical file
// Salvando QRCode em arquivo físico
(async () => {
pix.setDescricao('Doacao Livre / QRCODE - GPIX') // opcional
pix.setDescription('Free Donation / QRCODE - GPIX') // opcional
if(await pix.saveQRCodeFile('./qrcode.png')) {
console.log('sucesso ao salvar qr-code estático')
console.log('success in saving static QR-code')
} else {
console.log('erro ao salvar qr-code')
console.log('error saving QR-code')
}
})();

@@ -15,4 +15,4 @@ import { crcTable } from "./table";

return ((crc ^ 0) & 0xffff).toString(16).toUpperCase();
return (((crc ^ 0) & 0xffff).toString(16).toUpperCase()).padStart(4, "0");
}
}
import { CRC } from "./crc/crc";
import { IDinamico } from "./idinamico";
import { IEstatico } from "./iestatico";
import { IDinamic } from "./idinamic";
import { IStatic } from "./istatic";
import * as qrcode from "qrcode"
import * as fs from "fs"
export class PIX implements IDinamico, IEstatico {
export class PIX implements IDinamic, IStatic {
private _is_transacao_unica: boolean = false
private _chave: string = ''
private _nome_recebedor: string = ''
private _cidade_recebedor: string = ''
private _valor: number = 0
private _cep_recebedor: string = ''
private _identificador_transacao: string = ''
private _descricao_transacao: string = ''
private _url_padrao_pix: string = ''
private _is_unique_transaction: boolean = false
private _key: string = ''
private _receiver_name: string = ''
private _receiver_city: string = ''
private _amout: number = 0
private _zip_code: string = ''
private _identificator: string = ''
private _description: string = ''
private _location: string = ''
private constructor() {}
public static estatico(): IEstatico {
public static static(): IStatic {
return new PIX();
}
public static dinamico(): IDinamico {
public static dinamic(): IDinamic {
return new PIX();
}
setUrlPadraoPix(url_padrao_pix: string) {
this._url_padrao_pix = url_padrao_pix.replace('https://', '')
setLocation(location: string) {
this._location = location.replace('https://', '')
}
setChave(chave: string) {
this._chave = chave
setKey(key: string) {
this._key = key
}
setCepRecebedor(cep: string) {
this._cep_recebedor = cep
setReceiverZipCode(zipCode: string) {
this._zip_code = zipCode
}
setNomeRecebedor(nome_recebedor: string) {
if (nome_recebedor.length > 25)
setReceiverName(name: string) {
if (name.length > 25)
throw 'A quantidade máxima de caracteres para o nome do recebedor é 25'
this._nome_recebedor = nome_recebedor
this._receiver_name = name
}
setIdentificador(identificador_transacao: string) {
this._identificador_transacao = identificador_transacao
setIdentificator(identificator: string) {
this._identificator = identificator
}
setDescricao(descricao_transacao: string) {
this._descricao_transacao = descricao_transacao
setDescription(description: string) {
this._description = description
}
setCidadeRecebedor(cidade_recebedor: string) {
if (cidade_recebedor.length > 15)
setReceiverCity(city: string) {
if (city.length > 15)
throw 'A quantidade máxima de caracteres para a cidade do recebedor é 15'
this._cidade_recebedor = cidade_recebedor
this._receiver_city = city
}
setValor(valor: number) {
setAmount(amout: number) {
if (valor.toFixed(2).toString().length > 13)
if (amout.toFixed(2).toString().length > 13)
throw 'A quantidade máxima de caracteres para o valor é 13'
this._valor = valor
this._amout = amout
}
isTransacaoUnica(_is_transacao_unica: boolean) {
this._is_transacao_unica = _is_transacao_unica
isUniqueTransaction(is_unique_transaction: boolean) {
this._is_unique_transaction = is_unique_transaction
}

@@ -80,3 +80,3 @@

private _normalizarTexto(value: string) {
private _normalizeText(value: string) {
let str = value.toUpperCase().replace('Ç','C') as any

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

// caso seja transação única
if (this._is_transacao_unica)
if (this._is_unique_transaction)
lines.push('0102 12')
//#region Merchant Account Information - PIX
let descricao_transacao = this._normalizarTexto(this._descricao_transacao || '')
let descricao_transacao = this._normalizeText(this._description || '')
let extra = 14 + 8;

@@ -105,12 +105,12 @@ if(descricao_transacao) {

if (this._chave) {
let conteudoChave = this._normalizarTexto(this._chave)
lines.push(`26${conteudoChave.length + extra}`)
if (this._key) {
let contentKey = this._normalizeText(this._key)
lines.push(`26${contentKey.length + extra}`)
lines.push(`\t0014 br.gov.bcb.pix`)
lines.push(`\t01${this._rightPad(conteudoChave.length)} ${conteudoChave}`)
} else if(this._url_padrao_pix) {
let padraoUrl = this._url_padrao_pix
lines.push(`26${padraoUrl.length + extra}`)
lines.push(`\t01${this._rightPad(contentKey.length)} ${contentKey}`)
} else if(this._location) {
let location = this._location
lines.push(`26${location.length + extra}`)
lines.push(`\t0014 br.gov.bcb.pix`)
lines.push(`\t25${this._rightPad(padraoUrl.length)} ${padraoUrl}`)
lines.push(`\t25${this._rightPad(location.length)} ${location}`)
} else {

@@ -121,3 +121,3 @@ throw 'É necessário informar uma URL ou então uma chave pix.'

// descricao
if(this._descricao_transacao) {
if(this._description) {
lines.push(`\t02${this._rightPad(descricao_transacao.length)} ${descricao_transacao}`)

@@ -137,5 +137,5 @@ }

//#region Transaction Amount
if (this._valor) {
let valor = this._normalizarTexto(this._valor.toFixed(2).toString())
if (this._valor > 0)
if (this._amout) {
let valor = this._normalizeText(this._amout.toFixed(2).toString())
if (this._amout > 0)
lines.push(`54${this._rightPad(valor.length)} ${valor}`)

@@ -151,15 +151,15 @@ }

//#region Merchant Name
let nome_recebedor = this._normalizarTexto(this._nome_recebedor)
lines.push(`59${this._rightPad(nome_recebedor.length)} ${nome_recebedor}`)
let receiver_name = this._normalizeText(this._receiver_name)
lines.push(`59${this._rightPad(receiver_name.length)} ${receiver_name}`)
//#endregion
//#region Merchant City
let cidade_recebedor = this._normalizarTexto(this._cidade_recebedor)
lines.push(`60${this._rightPad(cidade_recebedor.length)} ${cidade_recebedor}`)
let receiver_city = this._normalizeText(this._receiver_city)
lines.push(`60${this._rightPad(receiver_city.length)} ${receiver_city}`)
//#endregion
//#region Postal Code
if (this._cep_recebedor) {
let codigo_postal = this._normalizarTexto(this._cep_recebedor)
lines.push(`61${this._rightPad(codigo_postal.length)} ${codigo_postal}`)
if (this._zip_code) {
let zip_code = this._normalizeText(this._zip_code)
lines.push(`61${this._rightPad(zip_code.length)} ${zip_code}`)
}

@@ -169,6 +169,6 @@ //#endregion

//#region Additional Data Field
if (this._identificador_transacao) {
let identificador_transacao = this._normalizarTexto(this._identificador_transacao)
lines.push(`62${identificador_transacao.length + 38}`)
lines.push(`\t05${this._rightPad(identificador_transacao.length)} ${identificador_transacao}`)
if (this._identificator) {
let transaction_identificator = this._normalizeText(this._identificator)
lines.push(`62${transaction_identificator.length + 38}`)
lines.push(`\t05${this._rightPad(transaction_identificator.length)} ${transaction_identificator}`)
lines.push(`\t5030`)

@@ -181,3 +181,3 @@ lines.push(`\t\t0017 br.gov.bcb.brcode`)

//#region Additional Data Field
if (this._url_padrao_pix) {
if (this._location) {
lines.push(`6207`)

@@ -184,0 +184,0 @@ lines.push(`\t0503 ***`)

{
"name": "gpix",
"version": "1.0.9",
"version": "1.1.0",
"description": "Biblioteca escrita em nodejs para gerar br-code e qr-code do PIX.",

@@ -5,0 +5,0 @@ "main": "index.js",

# GPIX
GPIX é um biblioteca que facilita a geração de br-codes dinâmicos e estáticos para o arranjo PIX.
GPIX is a library that facilitates the generation of dynamic and static br-codes for the central bank of Brazil PIX arrangement.
# Como utilizar
# How to use
Primeiro instale a biblioteca:
First install the library:

@@ -13,3 +13,3 @@ ```sh

Depois instâncie o `PIX.estatico` ou o `PIX.dinamico` e siga os exemplos abaixo
Then start with `PIX.static()` or `PIX.dinamic()` and follow the examples below:

@@ -20,49 +20,49 @@

// Exemplo 01: BRCODE estático, com valor definido
let pix = PIX.estatico();
pix.setNomeRecebedor('Hiago Silva Souza')
pix.setCidadeRecebedor('Rio Preto')
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setIdentificador('123') // opcional
pix.setCepRecebedor('15082131') // opcional
pix.setDescricao('Doação com valor fixo - GPIX') // opcional
pix.setValor(5.0) // opcional
// Exemplo 01: BRCODE static with defined amount.
let pix = PIX.static();
pix.setReceiverName('Hiago Silva Souza')
pix.setReceiverCity('Rio Preto')
pix.setReceiverZipCode('15082131') // opcional
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setIdentificator('123') // opcional
pix.setDescription('Donation with defined amount - GPIX') // opcional
pix.setAmount(5.0) // opcional
console.log('\nDoação com valor fixo - GPIX >>>>\n', pix.getBRCode())
console.log('\nDonation with defined amount - GPIX >>>>\n', pix.getBRCode())
pix = PIX.estatico();
// Exemplo 02: BRCODE estático, sem valor definido (usuário digita valor) e o identificador definido é 123
pix.setNomeRecebedor('Hiago Silva Souza')
pix.setCidadeRecebedor('Rio Preto')
pix.setChave('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setDescricao('Doação Livre - GPIX') // opcional
pix = PIX.static();
// Exemplo 02: Static BRCODE, with no defined amount (user types amount) and the defined identifier is 123
pix.setReceiverName('Hiago Silva Souza')
pix.setReceiverCity('Rio Preto')
pix.setKey('fcba8826-cbff-46e2-8c40-1b39896402a8')
pix.setDescription('Donation without defined amount - GPIX') // optional
console.log('Doação Livre - GPIX >>>>\n', pix.getBRCode())
console.log('Donation without defined amount - GPIX >>>>\n', pix.getBRCode())
// Exemplo 03: BRCODE dinâmico
let dpix = PIX.dinamico();
dpix.setNomeRecebedor('Logical Delivery LTDA')
dpix.setCidadeRecebedor('Rio Preto')
dpix.setUrlPadraoPix('url-location-instituicao')
console.log('\nBRCODE dinâmico - GPIX >>>>\n', dpix.getBRCode());
// Exemplo 03: BRCODE dinamic
let dpix = PIX.dinamic();
dpix.setReceiverName('Minha Empresa LTDA')
dpix.setReceiverCity('Rio Preto')
dpix.setLocation('url-location-psp')
console.log('\nBRCODE dinamic - GPIX >>>>\n', dpix.getBRCode());
// Gerando QRCodes em base64
// Generating QRCode in base64
(async () => {
//console.log('QRCODE Estático >>> ', await pix.getQRCode())
//console.log('QRCODE Dinamico >>> ', await dpix.getQRCode())
//console.log('QRCODE Static >>> ', await pix.getQRCode())
//console.log('QRCODE Dinamic >>> ', await dpix.getQRCode())
})();
// Salvando QRCode em arquivo físico
// Saving QRCode to physical file
(async () => {
pix.setDescricao('Doacao Livre / QRCODE - GPIX') // opcional
pix.setDescription('Free Donation / QRCODE - GPIX') // opcional
if(await pix.saveQRCodeFile('./qrcode.png')) {
console.log('sucesso ao salvar qr-code estático')
console.log('success in saving static QR-code')
} else {
console.log('erro ao salvar qr-code')
console.log('error saving QR-code')
}

@@ -72,11 +72,10 @@ })();

# Essa lib te ajudou?
# Did this lib help you?
Se essa lib te ajudou fique a vontade para fazer uma doação =), pode ser R$ 0.50 hahahaha. Para isso basta ler o qrcode abaixo, ele foi gerado com o arquivo de exemplo da lib.
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](https://github.com/hiagodotme/gpix/blob/main/qrcode.png?raw=true)
# Author
# Autor
Hiago Silva Souza <<hiasilva@gmail.com>> | https://hiago.me/

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc