ThaiQRPaymentBuilder
Defined in: builder.ts:127
Thai QR Payment payload builder.
Three terminal methods:
.build()returns the wire-format string ready for QR encoding..buildWithChecksum()returns both the body and the checksum separately — useful for debugging the CRC step..toBytes()returns aUint8Arrayof the ASCII-encoded payload for callers that want to hash or sign it.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ThaiQRPaymentBuilder():
ThaiQRPaymentBuilder
Defined in: builder.ts:136
Returns
Section titled “Returns”ThaiQRPaymentBuilder
Methods
Section titled “Methods”additionalData()
Section titled “additionalData()”additionalData(
fields):this
Defined in: builder.ts:304
Set sub-fields of the additional-data template (tag 62).
Parameters
Section titled “Parameters”fields
Section titled “fields”Returns
Section titled “Returns”this
amount()
Section titled “amount()”amount(
value,options?):this
Defined in: builder.ts:276
Set the transaction amount in baht. Pass {fromSatang: true} to
supply integer satang instead. Omit / pass undefined to keep the
QR static (the consumer’s banking app will prompt for an amount).
Parameters
Section titled “Parameters”number | bigint | undefined
options?
Section titled “options?”Returns
Section titled “Returns”this
bankAccount()
Section titled “bankAccount()”bankAccount(
bankCode,accountNo):this
Defined in: builder.ts:167
Configure a PromptPay credit transfer to a bank account (sub-tag 04).
bankCode is the 3-digit BoT bank identifier; accountNo is the
variable-length numeric account.
Parameters
Section titled “Parameters”bankCode
Section titled “bankCode”string
accountNo
Section titled “accountNo”string
Returns
Section titled “Returns”this
Example
Section titled “Example”new ThaiQRPaymentBuilder().bankAccount('014', '1234567890').amount(100).build()billPayment()
Section titled “billPayment()”billPayment(
input):this
Defined in: builder.ts:251
Configure a BillPayment recipient (Cross-Bank BillPayment / R-Bill).
Pass crossBorder: true to emit the ASEAN-region remittance AID
(A000000677012006) instead of the domestic one (A000000677010112).
The template layout is otherwise identical — same sub-tags, same
value rules. Pair with the purposeOfTransaction additional-data
field (tag 62 sub-tag 08), which carries an 18-char triple in this
mode: currencyCode (3 digits) + localAmount (13 digits) +
countryCode (2 digits). The builder treats that field as opaque;
compose / parse the triple at the call site.
Parameters
Section titled “Parameters”billerId
Section titled “billerId”string
crossBorder?
Section titled “crossBorder?”boolean
reference1?
Section titled “reference1?”string
reference2?
Section titled “reference2?”string
Returns
Section titled “Returns”this
build()
Section titled “build()”build():
string
Defined in: builder.ts:394
Render the full wire-format payload with checksum appended.
Returns
Section titled “Returns”string
buildWithChecksum()
Section titled “buildWithChecksum()”buildWithChecksum():
object
Defined in: builder.ts:442
Render and split the body/CRC for inspection.
Returns
Section titled “Returns”object
body:
string
checksum
Section titled “checksum”checksum:
string
payload
Section titled “payload”payload:
string
merchant()
Section titled “merchant()”merchant(
info):this
Defined in: builder.ts:295
Set merchant display info (tags 52, 59, 60, 61).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
ota(
otaCode):this
Defined in: builder.ts:182
Attach a One-Time Authorization code (sub-tag 05, fixed 10 chars). Flips the merchant template’s AID from the standard PromptPay GUID to the OTA GUID so scanners route the payload to the single-use flow.
Parameters
Section titled “Parameters”otaCode
Section titled “otaCode”string
Returns
Section titled “Returns”this
Example
Section titled “Example”new ThaiQRPaymentBuilder().promptpay('0812345678').ota('1234567890').amount(50).build()pointOfInitiation()
Section titled “pointOfInitiation()”pointOfInitiation(
method):this
Defined in: builder.ts:339
Force the point-of-initiation flag regardless of amount presence.
Parameters
Section titled “Parameters”method
Section titled “method”"static" | "dynamic"
Returns
Section titled “Returns”this
promptpay()
Section titled “promptpay()”promptpay(
recipient,type?):this
Defined in: builder.ts:149
Configure a PromptPay recipient (mobile, national ID, or e-wallet).
Overrides any previously-set BillPayment / KShop template. Use
.bankAccount() for credit-transfer payloads — its wire value needs
the (bankCode, accountNo) split this single-string form cannot carry.
Parameters
Section titled “Parameters”recipient
Section titled “recipient”string
Returns
Section titled “Returns”this
tipPolicy()
Section titled “tipPolicy()”tipPolicy(
mode):this
Defined in: builder.ts:289
Set the tip / convenience-fee policy (tags 55-57).
Parameters
Section titled “Parameters”TipMode | undefined
Returns
Section titled “Returns”this
toBytes()
Section titled “toBytes()”toBytes():
Uint8Array
Defined in: builder.ts:452
UTF-8 byte view of the payload — useful for hashing or transport.
Returns
Section titled “Returns”Uint8Array
trueMoney()
Section titled “trueMoney()”trueMoney(
mobileNo,options?):this
Defined in: builder.ts:213
Configure a TrueMoney Wallet recipient. Same merchant template tag
(29) as PromptPay but with the literal 14 prefix on sub-tag 03 so
the TrueMoney app can disambiguate its own payloads from a plain
e-wallet QR. The mobile is zero-padded on the left to 13 digits
before the prefix is added (final value length is always 15).
The optional message is carried in tag 81 (UTF-16BE hex) and is
surfaced inside the TrueMoney app only; other scanners ignore it.
Parameters
Section titled “Parameters”mobileNo
Section titled “mobileNo”string
options?
Section titled “options?”amount?
Section titled “amount?”number
message?
Section titled “message?”string
Returns
Section titled “Returns”this
vatTqrc()
Section titled “vatTqrc()”vatTqrc(
input):this
Defined in: builder.ts:318
Attach the Bank of Thailand VAT TQRC extension (tag 80). Promotes the
payment QR to an e-tax-receipt source. Pass undefined to clear.
Field-length rules come from the BOT extension spec:
sellerTaxBranchIdis exactly 4 charactersvatRateis 1–5 characters when present (e.g. “7” or “7.00”)vatAmountis 1–13 characters and required
Parameters
Section titled “Parameters”VATTQRCInput | undefined
Returns
Section titled “Returns”this