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

@paycashless/qpi.js

v0.0.4

Published

manipulate qpi data objects

Downloads

10

Readme

QR Payment Intent

This library allows you to encode and decode QPI data objects. Note: it won't generate a QR image, it only creates what can be used as the content of the QR code, you'll have use a seperate library for generating QR codes.

Get started

npm install @paycashless/qpi.js

encode

This function encodes your payment intent data objects into a string that can be easily embeded in a QR code.

  import { QrPaymentIntent } from '@paycashless/qpi.js';

  const dataObjects = {
    version: '01',
    intentType: IntentType.static,
    merchantAccount: {
      accountNumber: '2200010702',
      nipCode: '090267'
    },
    merchantCategoryCode: '4111', // transportation
    countryCode: 'NG',
    merchantName: 'GRUBWAYS',
    merchantCity: 'ABUJA',
    postalCode: '900231',
    amount: '5000',
    currency: '566', // NGN
    additionalDataObjects: {
      storeLabel: '055',
      customerLabel: 'cust_2bt7pwl20mb25sa',
      terminalLabel: '05',
      reference: '567223',
      narration: 'FOOD DELIVERY',
      merchantChannel: '521' // online
    },
    paymentIntentDataObjects: {
      token: "tok_neojvjkwPrrpr9e03hplcag2ig5gpua8"
    },
  }

  const qpi = new QrPaymentIntent();
  const payload = qpi.encode(dataObjects);
  console.log(payload);

decode

This function allows you to decode a QR payment intent payload back to readable data objects

import { QrPaymentIntent } from '@paycashless/qpi.js';

const payload = '00020101021236470210220001070204060902670019org.paycashless.qpi520441115802NG5908GRUBWAYS6005ABUJA6106900231540450005303566627703030550620customer@example.com0702050512PAY_567228030813FOOD DELIVERY110352180630136tok_neojvjkwPrrpr9e03hplcag2ig5gpua80019org.paycashless.qpi630423C0';
const qpi = new QrPaymentIntent();
const dataObjects = qpi.decode(payload);
console.log(dataObjects);

Data Objects

You can find all the possible data objects listed below;

interface DataObjects {
  version: string;
  intentType: IntentType;
  checksum: string;
  merchantAccount: {
    schemeIdentifier: string;
    accountNumber: string;
    nipCode: string;
    piftCode?: string;
    merchantId?: string;
  };
  merchantCategoryCode: string;
  countryCode: string;
  merchantName: string;
  merchantCity: string;
  postalCode: string;
  merchantInfoAltLanguage?: {
    localLanguage: string;
    merchantName: string;
    merchantCity: string;
  };
  amount: string;
  currency: string;
  serviceFee?: string;
  percentageServiceFee?: string;
  additionalDataObjects: {
    storeLabel: string;
    customerLabel: string;
    terminalLabel: string;
    loyaltyNumber?: string;
    reference: string;
    narration: string;
    merchantChannel: string;
  };
  paymentIntentDataObjects: {
    schemeIdentifier: string;
    token: string;
  },
}

merchantCategoryCode data object shall contain MCC as defined by [ISO 18245]

countryCode data object shall contain the country code of the merchant as defined by [ISO 3166-1 alpha-2]

additionalDataObjects.merchantChannel has three chracters, each chracter in each position identifies the characteristic of the channel used for the transaction. The possible value of each character and its definition are listed below

currency data object is to conform with [ISO 4217] containing 3 digit numeric representation of the transaction currency

Merchant Channel: First chracter (Media)

| Value | Meaning | | ----------- | ----------- | | "0" | Print - Merchant Sticker | | "1" | Print - Bill/Invoice | | "2" | Print - Magazine/Poster | | "3" | Print - Other | | "4" | Screen/Electronic - Merchant POS/POI | | "5" | Screen/Electronic - Website | | "6" | Screen/Electronic - App | | "7" | Screen/Electronic - Other |

Merchant Channel: Second chracter (Transaction Location)

| Value | Meaning | | ----------- | ----------- | | "0" | At Merchant premises/registered address | | "1" | Not at merchant premises/registered address | | "2" | Remote commerce | | "3" | Other |

Merchant Channel: Third chracter (Merchant Presence)

| Value | Meaning | | ----------- | ----------- | | "0" | Attended POI | | "1" | Unattended | | "2" | Semi attended (Self-checkout) | | "3" | Other |