npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emvqr-parser

v1.0.6

Published

JavaScript library for parsing EMV QR Codes

Downloads

209

Readme

About

JavaScript library for parsing EMV QR Codes for Payment Systems Merchant-Presented Mode

For development, you can test your change by creating a pull request. Go to prepublish_package of the checks section, then on the Publish Package step, you will get something like this at the bottom: @abrahamosmonde/[email protected]

You can then install @abrahamosmonde/emvqr-parser with version 1.0.3-c792fd6 to test the changes you made as a package

Don't forget to update the version everytime you plan on merging a pull-request to main

Installation

npm install emvqr-parser

How to use

Retrieving plaintext from QR text

import {decodeQrData} from 'emvqr-parser';

// Example text received from scanning a payment QR
const QR_DATA = '00020101021128620011ph.ppmi.p2m0111GXCHPHM2XXX032121702000005469871609905030005204581453036085802PH5917S and R MBTC 91826006Taguig6104163062650012ph.ppmi.qrph0308SRSU002005212170500000669901340940708GEN0035163049EE7';

console.log(decodeQrData(QR_DATA));

// Results in the following
/**

{
  28: {
    id: '28',
    name: 'Merchant Account Information',
    len: 62,
    data: {
      '00': {
        id: '00',
        name: 'Globally Unique Identifier',
        len: 11,
        data: 'ph.ppmi.p2m',
        
      },
      '01': {
        id: '01',
        name: 'Context Specific Data',
        len: 11,
        data: 'GXCHPHM2XXX',
        
      },
      '03': {
        id: '03',
        name: 'Context Specific Data',
        len: 21,
        data: '217020000054698716099',
        
      },
      '05': {
        id: '05',
        name: 'Context Specific Data',
        len: 3,
        data: '000',
        
      },
      
    },
    
  },
  52: {
    id: '52',
    name: 'Merchant Category Code',
    len: 4,
    data: '5814',
    
  },
  53: {
    id: '53',
    name: 'Transaction Currency',
    len: 3,
    data: '608',
    
  },
  58: {
    id: '58',
    name: 'Country Code',
    len: 2,
    data: 'PH',
    
  },
  59: {
    id: '59',
    name: 'Merchant Name',
    len: 17,
    data: 'S and R MBTC 9182',
    
  },
  60: {
    id: '60',
    name: 'Merchant City',
    len: 6,
    data: 'Taguig',
    
  },
  61: {
    id: '61',
    name: 'Postal Code',
    len: 4,
    data: '1630',
    
  },
  62: {
    id: '62',
    name: 'Additional Data Field Template',
    len: 65,
    data: {
      '00': {
        id: '00',
        name: 'Globally Unique Identifier',
        len: 12,
        data: 'ph.ppmi.qrph',
        
      },
      '03': {
        id: '03',
        name: 'Additional Data Field',
        len: 8,
        data: 'SRSU0020',
        
      },
      '05': {
        id: '05',
        name: 'Additional Data Field',
        len: 21,
        data: '217050000066990134094',
        
      },
      '07': {
        id: '07',
        name: 'Additional Data Field',
        len: 8,
        data: 'GEN00351',
        
      },
      
    },
    
  },
  63: {
    id: '63',
    name: 'CRC',
    len: 4,
    data: '9EE7',
    
  },
  '00': {
    id: '00',
    name: 'Payload Format Indicator',
    len: 2,
    data: '01',
    
  },
  '01': {
    id: '01',
    name: 'Point of Initiation Method',
    len: 2,
    data: '11',
    
  },
  
};
**/

Encoding data to QR text

import { generateEmvcoQrText } from '../qr-generator';

// Example data
const qrPayload = {
  merchantAccountInfo: {
    globalIdentifier: 'ph.ppmi.p2m',
    paymentNetworkInformation: {
      bankCode: 'GXCHPHM2XXX',
      bankNumber: '217020000054698716099',
      bankBranchCode: '000',
    },
  },
  merchantCategoryCode: '5814',
  transactionCurrency: '608',
  countryCode: 'PH',
  merchantName: 'S-and-R-MBTC-9182',
  merchantCity: 'Taguig',
  postalCode: '1630',
  additionalDataField: {
    '00': 'ph.ppmi.qrph',
    '03': 'SRSU0020',
    '05': '217050000066990134094',
    '07': 'GEN00351',
  },
};

console.log(generateEmvcoQrText(qrPayload))

// Results in the following
/**
00020101021128620011ph.ppmi.p2m0111GXCHPHM2XXX032121702000005469871609905030005204581453036085802PH5917S-and-R-MBTC-91826006Taguig6104163062650012ph.ppmi.qrph0308SRSU002005212170500000669901340940708GEN003516304BF2B
**/