From db524958bb6b6551430781c8a0e6df96a1d4e974 Mon Sep 17 00:00:00 2001 From: Marcelo Jannotti Date: Tue, 29 Aug 2023 15:46:19 -0300 Subject: [PATCH] Fix bug Pix.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correção de descrição que não há no manual do PIX. Aplicado toString() nos valores, afim de não gerar erro no lenght quando o valor é numeral. --- Pix.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Pix.js b/Pix.js index e4ac409..2c448ef 100644 --- a/Pix.js +++ b/Pix.js @@ -1,7 +1,6 @@ module.exports = class Pix { - constructor(pixKey, description, merchantName, merchantCity, txid, amount) { + constructor(pixKey, merchantName, merchantCity, txid, amount) { this.pixKey = pixKey; - this.description = description; this.merchantName = merchantName; this.merchantCity = merchantCity; this.txid = txid; @@ -11,7 +10,6 @@ module.exports = class Pix { this.ID_MERCHANT_ACCOUNT_INFORMATION = "26"; this.ID_MERCHANT_ACCOUNT_INFORMATION_GUI = "00"; this.ID_MERCHANT_ACCOUNT_INFORMATION_KEY = "01"; - this.ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = "02"; this.ID_MERCHANT_CATEGORY_CODE = "52"; this.ID_TRANSACTION_CURRENCY = "53"; this.ID_TRANSACTION_AMOUNT = "54"; @@ -24,6 +22,7 @@ module.exports = class Pix { } _getValue(id, value) { + value = value.toString(); const size = String(value.length).padStart(2, "0"); return id + size + value; } @@ -37,14 +36,10 @@ module.exports = class Pix { this.ID_MERCHANT_ACCOUNT_INFORMATION_KEY, this.pixKey ); - const description = this._getValue( - this.ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION, - this.description - ); return this._getValue( this.ID_MERCHANT_ACCOUNT_INFORMATION, - gui + key + description + gui + key ); }