Skip to content

Instantly share code, notes, and snippets.

@Thainainan03
Last active July 15, 2024 09:02
Show Gist options
  • Save Thainainan03/e7f71f5a88c2e19221f9d79305a3818b to your computer and use it in GitHub Desktop.
Save Thainainan03/e7f71f5a88c2e19221f9d79305a3818b to your computer and use it in GitHub Desktop.
promptpay-qr
const generatePayload = require('promptpay-qr')
const qrcode = require('qrcode')
const fs = require('fs')
const mobileNumber = '000-000-0000'
const IDCardNumber = '0-0000-00000-00-0'
const amount = 0
const payload = generatePayload(mobileNumber, { amount }) //First parameter : mobileNumber || IDCardNumber
console.log(payload)
// Convert to SVG QR Code
const options = { type: 'svg', color: { dark: '#000', light: '#fff' } }
qrcode.toString(payload, options, (err, svg) => {
if (err) return console.log(err)
fs.writeFileSync('./qr.svg', svg)
console.log(svg)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment