All Projects → Astrocoders → emv-parser

Astrocoders / emv-parser

Licence: MIT license
A simple and lightweight emv-parser made for human beings

Programming Languages

javascript
184084 projects - #8 most used programming language

emv-parser [WIP ⚠️!!!!]

npm install emv-parser

const {parseWithTemplate} = require('emv-parser')
const templates = require('emv-parser/templates')

const emv = `00020101021226410005Cielo0116123456789012000102082009130352040000530398654120000000001005802BR5905CIELO6014SANTO ANDRE SP801010033"https://www.cielo.com.br/qrcode"011613050329197F190A0212150518113349030410000404000105020006020163049872`

console.log(parseWithTemplate(templates.cielo, emv))
// =>
{
  payloadFormatIndicator: '01',
  pointOfInitiationMethod: '12',
  merchantAccountInformation: {
    globallyUniqueIdentifier: 'Cielo',
    merchantAccountInformation: '1234567890120001',
    logicNumber: '20091303'
  },
  merchantCategory: '0000',
  transactionCurrency: '986',
  transactionAmount: '000000000100',
  countryCode: 'BR',
  merchantName: 'CIELO',
  merchantCity: 'SANTO ANDRE SP',
  transactionInformations: {
    globallyUniqueIdentifier: '"https://www.cielo.com.br/qrcode"',
    transactionId: '13050329197F190A',
    transactionDate: '150518113349',
    mainProduct: '1000',
    subProduct: '0001',
    paymentInstallments: '00',
    transactionType: '01'
  },
  crc: '9872'
}

const pixStatic = `00020126440014BR.GOV.BCB.PIX0122FULANO2019 EXAMPLE.COM5204000053039865802BR5913FULANO DE TAL6008BRASILIA62410503***50300017BR.GOV.BCB.BRCODE01051.0.0630427E9`;

console.log(parseWithTemplate(templates.pixStatic, pixStatic))
// =>
{
  payloadFormatIndicator: '01',
  pointOfInitiationMethod: null,
  merchantAccountInformation: {
    globallyUniqueIdentifier: 'BR.GOV.BCB.PIX',
    pixKey: 'FULANO2019 EXAMPLE.COM'
  },
  merchantCategory: '0000',
  transactionCurrency: '986',
  transactionAmount: null,
  countryCode: 'BR',
  merchantName: 'FULANO DE TAL',
  merchantCity: 'BRASILIA',
  additionalData: { referenceLabel: null },
  crc: '27E9'
}

Check out index.test.js for more examples

Templates

  • Cielo
  • PIX Static (EMV-MPM)
  • PIX Dynamic (EMV-MPM)

Limitations

We only parse the tree and we are not doing any fancy validations on it yet

Specification followed

Known issues

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].