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

sgqr-code

v0.1.0

Published

Generate SGQR Code for PayNow transactions in Node.js

Downloads

215

Readme

Singapore Quick Response Code (SGQR)

Effortlessly generate your Singapore Quick Response Code (SGQR) Code for PayNow transactions. Quickly set predefined amounts and reference numbers for seamless peer-to-peer transfers across major banks and non-financial institutions in Singapore.

A Node.js package to generate Singapore Quick Response Code (SGQR) for PayNow transactions.

Installation

npm install sgqr-code --save

Usage

const { getPaynowQRCode } = require('sgqr-code');

// Example Usage
try {
    const qrCode = getPaynowQRCode({
        phone: '+6512345678'
    });

    console.log(qrCode);
} catch (error) {
    console.log(error);
    console.error('Error generating QR code:', error.message);
}

// Example Usage: 1
const qrCode = getPaynowQRCode({
  merchantName: 'MyMerchant',
  amount: 25.99,
  uen: '123456789A',
});

// Example Usage: 2
const qrCode = getPaynowQRCode({
  amount: 25.99,
  phone: '+6512345678',
});

// Example Usage: 3
const qrCode = getPaynowQRCode({
  uen: '123456789A',
});

// Example Usage: 4
const qrCode = getPaynowQRCode({
  initiationMethod: '12',
  referenceNumber: '123456',
  merchantName: 'MyMerchant',
  amount: 25.99,
  amountEditable: '0',
  uen: '123456789A',
  transactionCurrency: '702',
  countryCode: 'SG',
  merchantCity: 'Singapore',
  uniqueIdentifier: 'SG.PAYNOW',
  expiryDate: '20230101120000', // Optional, format: YYYYMMDD or YYYYMMDDHHMMSS
});

console.log(qrCode);

getPaynowQRCode Object Param Values

| Parameter | Description | Default Value | Maximum Length | Mandatory | | ------------------- | ----------------------------------------------- | ------------------| ---------------| ----------| | initiationMethod | Initiation method for the transaction. '11' Static or '12' Dynamic | '12' (Dynamic) | N/A | Yes | | referenceNumber | Reference number for the transaction. | Auto-generated | 99 | Yes | | merchantName | Name of the merchant. | 'NA' | 25 | Yes | | amount | Transaction amount. | null | N/A | No | | amountEditable | Whether the amount is editable or not. | '0' | N/A | Yes | | uen | UEN (Unique Entity Number) of the merchant. | null | 16 | No | | phone | SG Phone number including +65 | null | 16 | No | | transactionCurrency| Currency code for the transaction. | '702' | 3 | Yes | | countryCode | Country code of the merchant. | 'SG' | 2 | Yes | | merchantCity | City of the merchant. | 'Singapore' | 15 | Yes | | uniqueIdentifier | Unique identifier for PayNow transactions. | 'SG.PAYNOW' | 9 | Yes | | expiryDate | Expiry date for the QR code. | null (Optional) | 14 | No |

Note:

  • initiationMethod should be either '11' for Static or '12' for Dynamic QR code.
  • If amount is null, amountEditable will be set to '0' (non-editable).
  • Either uen or phone can be provided. If both are provided, uen will be considered by default.
  • phone should be a Singapore phone number starting with +65 and followed by 8 digits.
  • expiryDate (if provided) should be in the format YYYYMMDD or YYYYMMDDHHMMSS and must be greater than the current date and time.