apiref
promptpay-qr@0.5.0

generatePayload()  Function

Generates a PromptPay QR payload.

Signature

export function generatePayload(
  target: string,
  options: generatePayload.Options
): string;

Remarks

This package is a CommonJS module. Import this function from CommonJS code like this:

const generatePayload = require('promptpay-qr')

If you use ES modules, you can use the default import syntax:

import generatePayload from 'promptpay-qr'

If you use TypeScript, make sure to set "esModuleInterop": true in the tsconfig.json file.

Example 1

Generate a PromptPay QR payload for a phone number

generatePayload('0812345678', {})

Example 2

Generate a PromptPay QR payload for a phone number with a fixed amount

generatePayload('0812345678', { amount: 4.22 })

Parameters

ParameterTypeDescription
targetstring

The target PromptPay ID. This can be a phone number (10 digits), a citizen ID (13 digits), a tax ID (13 digits), or an e-Wallet account ID (15 digits).

optionsgeneratePayload.Options

Options for generating a PromptPay QR payload

(Returns)string

A PromptPay QR payload. Use this payload to generate a QR code that can be scanned by mobile banking apps in Thailand.