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

promptparse

v1.3.0

Published

All-in-one JS library for PromptPay & EMVCo QR Codes

Downloads

3,726

Readme

PromptParse

PromptParse npm version

"All-in-one JS library for PromptPay & EMVCo QR Codes"

No dependency & Cross-platform. You can use it anywhere (Node.js, Deno, Bun), even in the browser!

Features

  • Parse — PromptPay & EMVCo QR Code data strings into object
  • Generate — QR Code data from pre-made templates (for example: PromptPay AnyID, PromptPay Bill Payment, TrueMoney, etc.)
  • Manipulate — any values from parsed QR Code data (for example: transfer amount, account number) and encodes back into QR Code data
  • Validate — checksum and data structure for known QR Code formats (for example: Slip Verify API Mini QR)

Usage

Parsing data and get value from tag

import { parse } from 'promptparse'

// Example data
const ppqr = parse('000201010211...')

// Get Value of Tag ID '00'
ppqr.getTagValue('00') // Returns '01'

Build QR data and append CRC tag

import { encode, tag, withCrcTag } from 'promptparse'

// Example data
const data = [
  tag('00', '01'),
  tag('01', '11'),
  // ...
]

// Set CRC Tag ID '63'
withCrcTag(encode(data), '63') // Returns '000201010211...'

Generate PromptPay Bill Payment QR

import { billPayment } from 'promptparse/generate'

const payload = billPayment({
  billerId: '1xxxxxxxxxxxx',
  amount: 300.0,
  ref1: 'INV12345',
})

// TODO: Create QR Code from payload

Validate & extract data from Slip Verify QR

import { slipVerify } from 'promptparse/validate'

const data = slipVerify('00550006000001...')

if (!data) {
  console.error('Invalid Payload')
}

const { sendingBank, transRef } = data

// TODO: Inquiry transaction from Bank Open API

Convert BOT Barcode to PromptPay QR Tag 30 (Bill Payment)

import { parseBarcode } from 'promptparse'

const botBarcode = parseBarcode('|310109999999901\r...')

if (!botBarcode) {
  console.error('Invalid Payload')
}

const payload = botBarcode.toQrTag30()

// TODO: Create QR Code from payload

Use on browser via CDN

<script src="https://cdn.jsdelivr.net/npm/promptparse"></script>

<script>
  ;(function () {
    // Generate QR code payload (use function from "promptparse" global)
    const payload = promptparse.generate.trueMoney({
      mobileNo: '08xxxxxxxx',
      amount: 10.0,
      message: 'Hello World!',
    })

    // Quick & dirty way to show QR Code image
    document.write(
      `<img src="https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${payload}">`,
    )
  })()
</script>

References

See also

License

This project is MIT licensed (see LICENSE.md)