@rprata/pixcode

Pixcode module is used to handler PIX qrcode based on BCB specification

Usage no npm install needed!

<script type="module">
  import rprataPixcode from 'https://cdn.skypack.dev/@rprata/pixcode';
</script>

README

Pixcode

Support Node of LTS npm version npm version dependencies typescript License mit

Description

Pixcode module is used to handler PIX qrcode based on BCB specification. It's completely written in typescript for node js.

How to use

Importing in your project:

npm install pixcode

Using in your code:

import { parse } from 'pixcode'
...
const qrcode = '00020101021226720014br.gov.bcb.pix2550bx.com.br/pix/8b3da2f3-9a41-40d1-a91a-bd93113bd4415204000053039865406123.455802BR5913Fulano de Tal6008BRASILIA62190515RP12345678-2019630445C8'
const result = parse(qrcode)
console.log(result)

Result

Result is a PIXCode structure.

{
   "payloadFormatIndicator":{
      "id":"00",
      "name":"Payload Format Indicator",
      "length":2,
      "value":"01",
      "mandatory":true,
      "description":"versão do payloadQRCPS-MPM, fixo em \"01\""
   },
   "pointOfInitiationMethod":{
      "id":"01",
      "name":"Point of Initiation Method",
      "length":2,
      "value":"12",
      "mandatory":false,
      "description":"\"11\" (QR reutilizável) ou \"12\" (QR utilizável apenas uma vez)"
   },
   "merchantAccountInformation":{
      "id":"26",
      "name":"Merchant Account Information",
      "length":72,
      "value":"0014br.gov.bcb.pix2550bx.com.br/pix/8b3da2f3-9a41-40d1-a91a-bd93113bd441",
      "mandatory":true,
      "description":"indica arranjo específico / \"00\" (GUI) obrigatório / \"01..99\" conform BCB"
   },
   "merchantCategoryCode":{
      "id":"52",
      "name":"Merchant Category Code",
      "length":4,
      "value":"0000",
      "mandatory":true,
      "description":"\"0000\" ou MCC ISO18245"
   },
   "transactionCurrency":{
      "id":"53",
      "name":"Transaction Currency",
      "length":3,
      "value":"986",
      "mandatory":true,
      "description":"ISO4217"
   },
   "transactionAmount":{
      "id":"54",
      "name":"Transaction Amount",
      "length":6,
      "value":"123.45",
      "mandatory":false,
      "description":"valor da transação. Ex.: \"0\", \"1.00\", \"123.99\""
   },
   "countryCode":{
      "id":"58",
      "name":"Country Code",
      "length":2,
      "value":"BR",
      "mandatory":true,
      "description":"código de país ISO3166-1 alpha 2"
   },
   "merchantName":{
      "id":"59",
      "name":"Merchant Name",
      "length":13,
      "value":"Fulano de Tal",
      "mandatory":true,
      "description":"nome do beneficiário/recebedor"
   },
   "merchantCity":{
      "id":"60",
      "name":"Merchant City",
      "length":8,
      "value":"BRASILIA",
      "mandatory":true,
      "description":"cidade onde é efetuada a transação"
   },
   "postalCode":{
      "id":"61",
      "name":"Postal Code",
      "length":0,
      "value":"",
      "mandatory":false,
      "description":"CEP da localidade onde é efetuada a transação"
   },
   "additionalDataField":{
      "id":"62",
      "name":"Additional Data Field",
      "length":19,
      "value":"0515RP12345678-2019",
      "mandatory":false,
      "description":"Campos adicionais"
   },
   "unreservedTemplates":{
      "id":"",
      "name":"Unreserved Templates",
      "length":0,
      "value":"",
      "mandatory":false,
      "description":"Campos não reservados"
   },
   "crc":{
      "id":"63",
      "name":"CRC",
      "length":4,
      "value":"45C8",
      "mandatory":true,
      "description":"CRC"
   }
}

Types and Interfaces:


interface TLV {
    id: string;
    name: string;
    length: number;
    value: string;
    mandatory: boolean;
    description: string;
}

interface PIXCode {
    payloadFormatIndicator: TLV;
    pointOfInitiationMethod: TLV;
    merchantAccountInformation: TLV;
    merchantCategoryCode: TLV;
    transactionCurrency: TLV;
    transactionAmount: TLV;
    countryCode: TLV;
    merchantName: TLV;
    merchantCity: TLV;
    postalCode: TLV;
    additionalDataField: TLV;
    unreservedTemplates: TLV;
    crc: TLV;
}