All-in-one JS library for PromptPay & EMVCo QR Codes
npm install promptparse-kshop"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!
- 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)
``ts
import { parse } from 'promptparse'
// Example data
const ppqr = parse('000201010211...')
// Get Value of Tag ID '00'
ppqr.getTagValue('00') // Returns '01'
`
`ts
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...'
`
`ts
import { billPayment } from 'promptparse/generate'
const payload = billPayment({
billerId: '1xxxxxxxxxxxx',
amount: 300.0,
ref1: 'INV12345',
})
// TODO: Create QR Code from payload
`
`ts
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
`
`ts
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
`
`html
``
- EMV QR Code
- Thai QR Payment Standard
- Slip Verify API Mini QR Data
- BOT Barcode Standard
- phoomin2012/promptparse-php PromptParse port for PHP
This project is MIT licensed (see LICENSE.md)