
PromptParse 
"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'
const ppqr = parse('000201010211...')
ppqr.getTagValue('00')
Build QR data and append CRC tag
import { encode, tag, withCrcTag } from 'promptparse'
const data = [
tag('00', '01'),
tag('01', '11'),
]
withCrcTag(encode(data), '63')
Generate PromptPay Bill Payment QR
import { billPayment } from 'promptparse/generate'
const payload = billPayment({
billerId: '1xxxxxxxxxxxx',
amount: 300.0,
ref1: 'INV12345',
})
import { slipVerify } from 'promptparse/validate'
const data = slipVerify('00550006000001...')
if (!data) {
console.error('Invalid Payload')
}
const { sendingBank, transRef } = data
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()
Use on browser via CDN
<script src="https://cdn.jsdelivr.net/npm/promptparse"></script>
<script>
;(function () {
const payload = promptparse.generate.trueMoney({
mobileNo: '08xxxxxxxx',
amount: 10.0,
message: 'Hello World!',
})
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)