This is the full developer documentation for thai-qr-payment # thai-qr-payment > Spec-faithful Thai QR Payment for JS — payload, QR, SVG card, React, CLI. Zero deps. import { Card, CardGrid, Code } from '@astrojs/starlight/components'; ## Why this exists Every other Thai QR library on npm wraps the [`qrcode`](https://www.npmjs.com/package/qrcode) package, ties you to Node-only APIs, or ships a 30 KB blob. This one is in-house TypeScript end-to-end: No `qrcode`, no `canvas`, no `crc16`. `npm install thai-qr-payment` pulls **one** tarball. Browsers, Node ≥ 18, Bun, Deno, Cloudflare Workers, Vercel Edge — same bundle. Full bundle 13.6 KB brotli. Payload-only sub-path 3 KB. EMVCo MPM 1.1 + Bank of Thailand supplement, ISO/IEC 18004 QR Model 2, 337 vitest tests in the payload package alone. `` and `` SSR-safe, peer-dep React. `npx thai-qr-payment 0812345678 --amount 50 -o qr.svg` Bank-account PromptPay, OTA credit transfer, [TrueMoney Wallet QR](/guide/payload/), [VAT TQRC](/reference/spec/#vat-tqrc-template-under-tag-80), cross-border bill payment, [Slip Verify Mini-QR](/guide/slip-verify/), [BOT 1D barcode](/guide/barcode/). ## Quickstart ![Sample QR card output](../../../public/img/samples/qr-card-merchant.svg) [→ Try it without installing](/demo/) # colorLogo > **colorLogo**(`name`): `string` Defined in: [index.ts:39](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/index.ts#L39) Get a color logo by name (returns the SVG string). ## Parameters ### name `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` ## Returns `string` # silhouetteLogo > **silhouetteLogo**(`name`): `string` Defined in: [index.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/index.ts#L44) Get a silhouette logo by name. ## Parameters ### name `"PromptPay1"` \| `"Thai_QR_Payment_Logo-01"` ## Returns `string` # @thai-qr-payment/assets ## Type Aliases - [ColorLogoName](/api/assets/typealiascolorlogoname/) - [SilhouetteLogoName](/api/assets/typealiassilhouettelogoname/) ## Variables - [COLOR\_LOGOS](/api/assets/variablecolor_logos/) - [DEFAULT\_LOGOS](/api/assets/variabledefault_logos/) - [SILHOUETTE\_LOGOS](/api/assets/variablesilhouette_logos/) ## Functions - [colorLogo](/api/assets/functioncolorlogo/) - [silhouetteLogo](/api/assets/functionsilhouettelogo/) # ColorLogoName > **ColorLogoName** = keyof *typeof* [`COLOR_LOGOS`](/api/assets/variablecolor_logos/) Defined in: [generated.ts:21](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/generated.ts#L21) `@thai-qr-payment/assets` — SVG brand marks for Thai QR Payment. Each mark ships in two flavors: - `COLOR_LOGOS[name]` — full-colour SVG path traced via vtracer. True vector (no embedded raster), small enough to inline anywhere. - `SILHOUETTE_LOGOS[name]` — monochrome path traced via potrace. Even smaller, suitable for masks / icons / dark mode. Only the canonical marks ship by default — `Thai_QR_Payment_Logo-01` (the BOT/TBA primary Thai QR Payment logo) and `PromptPay1` (the National ITMX PromptPay mark). If you need an alternative layout, trace your own asset via the supplied `scripts/build-assets.sh` and drop the result into `packages/assets/src/svg/`. All exports are plain SVG strings — drop them into innerHTML, write them to disk, or serve them with `Content-Type: image/svg+xml`. Marks belong to their respective rights-holders: - Thai QR Payment logo — Bank of Thailand / Thai Bankers' Association - PromptPay logo — Bank of Thailand / National ITMX Use of these marks is governed by Thai QR Payment Brand Guidelines. This package merely redistributes the bitmap → SVG conversion; downstream apps must comply with the official brand book. # SilhouetteLogoName > **SilhouetteLogoName** = keyof *typeof* [`SILHOUETTE_LOGOS`](/api/assets/variablesilhouette_logos/) Defined in: [generated.ts:22](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/generated.ts#L22) `@thai-qr-payment/assets` — SVG brand marks for Thai QR Payment. Each mark ships in two flavors: - `COLOR_LOGOS[name]` — full-colour SVG path traced via vtracer. True vector (no embedded raster), small enough to inline anywhere. - `SILHOUETTE_LOGOS[name]` — monochrome path traced via potrace. Even smaller, suitable for masks / icons / dark mode. Only the canonical marks ship by default — `Thai_QR_Payment_Logo-01` (the BOT/TBA primary Thai QR Payment logo) and `PromptPay1` (the National ITMX PromptPay mark). If you need an alternative layout, trace your own asset via the supplied `scripts/build-assets.sh` and drop the result into `packages/assets/src/svg/`. All exports are plain SVG strings — drop them into innerHTML, write them to disk, or serve them with `Content-Type: image/svg+xml`. Marks belong to their respective rights-holders: - Thai QR Payment logo — Bank of Thailand / Thai Bankers' Association - PromptPay logo — Bank of Thailand / National ITMX Use of these marks is governed by Thai QR Payment Brand Guidelines. This package merely redistributes the bitmap → SVG conversion; downstream apps must comply with the official brand book. # COLOR_LOGOS > `const` **COLOR\_LOGOS**: `object` Defined in: [generated.ts:10](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/generated.ts#L10) `@thai-qr-payment/assets` — SVG brand marks for Thai QR Payment. Each mark ships in two flavors: - `COLOR_LOGOS[name]` — full-colour SVG path traced via vtracer. True vector (no embedded raster), small enough to inline anywhere. - `SILHOUETTE_LOGOS[name]` — monochrome path traced via potrace. Even smaller, suitable for masks / icons / dark mode. Only the canonical marks ship by default — `Thai_QR_Payment_Logo-01` (the BOT/TBA primary Thai QR Payment logo) and `PromptPay1` (the National ITMX PromptPay mark). If you need an alternative layout, trace your own asset via the supplied `scripts/build-assets.sh` and drop the result into `packages/assets/src/svg/`. All exports are plain SVG strings — drop them into innerHTML, write them to disk, or serve them with `Content-Type: image/svg+xml`. Marks belong to their respective rights-holders: - Thai QR Payment logo — Bank of Thailand / Thai Bankers' Association - PromptPay logo — Bank of Thailand / National ITMX Use of these marks is governed by Thai QR Payment Brand Guidelines. This package merely redistributes the bitmap → SVG conversion; downstream apps must comply with the official brand book. ## Type Declaration ### PromptPay1 > `readonly` **PromptPay1**: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" ### PromptPay2 > `readonly` **PromptPay2**: "\\\" ### Thai\_QR\_Payment\_Logo-01 > `readonly` **Thai\_QR\_Payment\_Logo-01**: "\\\\\\\\\\\\\\\\\\\\\\\\\\" = `Thai_QR_Payment_Logo_01` # DEFAULT_LOGOS > `const` **DEFAULT\_LOGOS**: `object` Defined in: [index.ts:49](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/index.ts#L49) Default mark recommendations for downstream use. ## Type Declaration ### promptpay > `readonly` **promptpay**: `"PromptPay1"` = `'PromptPay1'` ### promptpaySilhouette > `readonly` **promptpaySilhouette**: `"PromptPay1"` = `'PromptPay1'` ### thaiQrPayment > `readonly` **thaiQrPayment**: `"Thai_QR_Payment_Logo-01"` = `'Thai_QR_Payment_Logo-01'` ### thaiQrPaymentSilhouette > `readonly` **thaiQrPaymentSilhouette**: `"Thai_QR_Payment_Logo-01"` = `'Thai_QR_Payment_Logo-01'` # SILHOUETTE_LOGOS > `const` **SILHOUETTE\_LOGOS**: `object` Defined in: [generated.ts:16](https://github.com/uunw/thai-qr-payment/blob/main/packages/assets/src/generated.ts#L16) `@thai-qr-payment/assets` — SVG brand marks for Thai QR Payment. Each mark ships in two flavors: - `COLOR_LOGOS[name]` — full-colour SVG path traced via vtracer. True vector (no embedded raster), small enough to inline anywhere. - `SILHOUETTE_LOGOS[name]` — monochrome path traced via potrace. Even smaller, suitable for masks / icons / dark mode. Only the canonical marks ship by default — `Thai_QR_Payment_Logo-01` (the BOT/TBA primary Thai QR Payment logo) and `PromptPay1` (the National ITMX PromptPay mark). If you need an alternative layout, trace your own asset via the supplied `scripts/build-assets.sh` and drop the result into `packages/assets/src/svg/`. All exports are plain SVG strings — drop them into innerHTML, write them to disk, or serve them with `Content-Type: image/svg+xml`. Marks belong to their respective rights-holders: - Thai QR Payment logo — Bank of Thailand / Thai Bankers' Association - PromptPay logo — Bank of Thailand / National ITMX Use of these marks is governed by Thai QR Payment Brand Guidelines. This package merely redistributes the bitmap → SVG conversion; downstream apps must comply with the official brand book. ## Type Declaration ### PromptPay1 > `readonly` **PromptPay1**: "\\\\\\\\" = `PromptPay1_silhouette` ### Thai\_QR\_Payment\_Logo-01 > `readonly` **Thai\_QR\_Payment\_Logo-01**: "\\\\\\" = `Thai_QR_Payment_Logo_01_silhouette` # ThaiQRPaymentBuilder Defined in: [builder.ts:127](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L127) 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 a `Uint8Array` of the ASCII-encoded payload for callers that want to hash or sign it. ## Constructors ### Constructor > **new ThaiQRPaymentBuilder**(): `ThaiQRPaymentBuilder` Defined in: [builder.ts:136](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L136) #### Returns `ThaiQRPaymentBuilder` ## Methods ### additionalData() > **additionalData**(`fields`): `this` Defined in: [builder.ts:304](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L304) Set sub-fields of the additional-data template (tag 62). #### Parameters ##### fields [`AdditionalDataFields`](/api/payload/interfaceadditionaldatafields/) #### Returns `this` *** ### amount() > **amount**(`value`, `options?`): `this` Defined in: [builder.ts:276](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L276) 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 ##### value `number` \| `bigint` \| `undefined` ##### options? [`FormatAmountOptions`](/api/payload/interfaceformatamountoptions/) #### Returns `this` *** ### bankAccount() > **bankAccount**(`bankCode`, `accountNo`): `this` Defined in: [builder.ts:167](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L167) 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 ##### bankCode `string` ##### accountNo `string` #### Returns `this` #### Example ```ts new ThaiQRPaymentBuilder().bankAccount('014', '1234567890').amount(100).build() ``` *** ### billPayment() > **billPayment**(`input`): `this` Defined in: [builder.ts:251](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L251) 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 ##### input ###### billerId `string` ###### crossBorder? `boolean` ###### reference1? `string` ###### reference2? `string` #### Returns `this` *** ### build() > **build**(): `string` Defined in: [builder.ts:394](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L394) Render the full wire-format payload with checksum appended. #### Returns `string` *** ### buildWithChecksum() > **buildWithChecksum**(): `object` Defined in: [builder.ts:442](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L442) Render and split the body/CRC for inspection. #### Returns `object` ##### body > **body**: `string` ##### checksum > **checksum**: `string` ##### payload > **payload**: `string` *** ### merchant() > **merchant**(`info`): `this` Defined in: [builder.ts:295](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L295) Set merchant display info (tags 52, 59, 60, 61). #### Parameters ##### info [`MerchantInfo`](/api/payload/interfacemerchantinfo/) #### Returns `this` *** ### ota() > **ota**(`otaCode`): `this` Defined in: [builder.ts:182](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L182) 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 ##### otaCode `string` #### Returns `this` #### Example ```ts new ThaiQRPaymentBuilder().promptpay('0812345678').ota('1234567890').amount(50).build() ``` *** ### pointOfInitiation() > **pointOfInitiation**(`method`): `this` Defined in: [builder.ts:339](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L339) Force the point-of-initiation flag regardless of amount presence. #### Parameters ##### method `"static"` \| `"dynamic"` #### Returns `this` *** ### promptpay() > **promptpay**(`recipient`, `type?`): `this` Defined in: [builder.ts:149](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L149) 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 ##### recipient `string` ##### type? [`PromptPayRecipientType`](/api/payload/typealiaspromptpayrecipienttype/) #### Returns `this` *** ### tipPolicy() > **tipPolicy**(`mode`): `this` Defined in: [builder.ts:289](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L289) Set the tip / convenience-fee policy (tags 55-57). #### Parameters ##### mode [`TipMode`](/api/payload/typealiastipmode/) \| `undefined` #### Returns `this` *** ### toBytes() > **toBytes**(): `Uint8Array` Defined in: [builder.ts:452](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L452) UTF-8 byte view of the payload — useful for hashing or transport. #### Returns `Uint8Array` *** ### trueMoney() > **trueMoney**(`mobileNo`, `options?`): `this` Defined in: [builder.ts:213](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L213) 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 ##### mobileNo `string` ##### options? ###### amount? `number` ###### message? `string` #### Returns `this` *** ### vatTqrc() > **vatTqrc**(`input`): `this` Defined in: [builder.ts:318](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L318) 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: - `sellerTaxBranchId` is exactly 4 characters - `vatRate` is 1–5 characters when present (e.g. "7" or "7.00") - `vatAmount` is 1–13 characters and required #### Parameters ##### input [`VATTQRCInput`](/api/payload/interfacevattqrcinput/) \| `undefined` #### Returns `this` # buildBOTBarcode > **buildBOTBarcode**(`input`): `string` Defined in: [barcode.ts:69](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L69) Build a BOT 1D bill-payment barcode payload. Throws `TypeError` / `RangeError` for malformed input — the caller never silently produces an unscannable barcode. ## Parameters ### input [`BOTBarcodeInput`](/api/payload/interfacebotbarcodeinput/) ## Returns `string` ## Examples ```ts buildBOTBarcode({ billerId: '099999999999990', ref1: '111222333444' }) // → '|099999999999990\r111222333444\r\r0' ``` ```ts buildBOTBarcode({ billerId: '099400016550100', ref1: '123456789012', ref2: '670429', amount: 3649.22, }) // → '|099400016550100\r123456789012\r670429\r364922' ``` # buildSlipVerify > **buildSlipVerify**(`input`): `string` Defined in: [slip-verify.ts:83](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L83) Build a Slip Verify Mini-QR payload. The output is a TLV string ending in a tag-91 CRC (uppercase hex), suitable for embedding in a printed slip and looking the transaction up via bank Open APIs. ## Parameters ### input [`SlipVerifyInput`](/api/payload/interfaceslipverifyinput/) ## Returns `string` ## Example ```ts buildSlipVerify({ sendingBank: '002', transRef: '0002123123121200011' }) // → '004000060000010103002021900021231231212000115102TH91049C30' ``` # buildTrueMoneySlipVerify > **buildTrueMoneySlipVerify**(`input`): `string` Defined in: [slip-verify.ts:142](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L142) Build a TrueMoney Slip Verify Mini-QR payload. Uses the same TLV envelope as the standard variant but with a different sub-tag layout and a **lowercase** hex CRC at tag 91. ## Parameters ### input [`TrueMoneySlipVerifyInput`](/api/payload/interfacetruemoneyslipverifyinput/) ## Returns `string` ## Example ```ts buildTrueMoneySlipVerify({ eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024' }) // → '00480002010102010203P2P0313TXN00012345670408250120249104b425' ``` # checksum > **checksum**(`input`): `string` Defined in: [crc.ts:28](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/crc.ts#L28) Compute the CRC-16/CCITT-FALSE checksum of an ASCII-encoded payload and return it as a 4-character uppercase hex string. The EMVCo spec requires the trailing zero-padding to keep the QR payload length stable. ## Parameters ### input `string` ## Returns `string` # decodePersonalMessage > **decodePersonalMessage**(`hex`): `string` Defined in: [message.ts:23](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/message.ts#L23) Decode a UTF-16BE hex string back to its source message. ## Parameters ### hex `string` ## Returns `string` # encodeField > **encodeField**(`tag`, `value`): `string` Defined in: [tlv.ts:17](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L17) Encode one TLV. The caller guarantees that `tag` is a valid 2-digit id. ## Parameters ### tag `string` ### value `string` ## Returns `string` # encodeFields > **encodeFields**(`pairs`): `string` Defined in: [tlv.ts:32](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L32) Encode an array of `[tag, value]` pairs in registration order. Empty or `null`/`undefined` values are filtered out so callers can compose optional fields without an `if` chain. ## Parameters ### pairs readonly readonly \[`string`, `string` \| `null` \| `undefined`\][] ## Returns `string` # encodePersonalMessage > **encodePersonalMessage**(`message`): `string` Defined in: [message.ts:13](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/message.ts#L13) Encode a personal message string to UTF-16BE hex (uppercase). ## Parameters ### message `string` ## Returns `string` # formatAmount > **formatAmount**(`value`, `options?`): `string` \| `null` Defined in: [amount.ts:21](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/amount.ts#L21) Format an amount for the wire. Returns `null` for static QR (caller intends a "scan and enter any amount" code). ## Parameters ### value `number` \| `bigint` \| `null` \| `undefined` ### options? [`FormatAmountOptions`](/api/payload/interfaceformatamountoptions/) = `{}` ## Returns `string` \| `null` # iterateFields > **iterateFields**(`input`): `IterableIterator`\<[`TLVField`](/api/payload/interfacetlvfield/)\> Defined in: [tlv.ts:50](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L50) Walk a TLV-encoded string and return one field at a time. Stops cleanly at end-of-input; throws on malformed length headers or truncated values. Designed for parsing both the root payload and nested template values — the same algorithm applies at any depth. ## Parameters ### input `string` ## Returns `IterableIterator`\<[`TLVField`](/api/payload/interfacetlvfield/)\> # normaliseBankAccount > **normaliseBankAccount**(`bankCode`, `accountNo`): [`NormalisedRecipient`](/api/payload/interfacenormalisedrecipient/) Defined in: [recipient.ts:96](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L96) Format a bank-account recipient for sub-tag 04 under the PromptPay merchant template. The wire value is the 3-digit bank code followed by the (variable-length, numeric) account number; total length must fit EMVCo's 1–43-character cap on the sub-tag. ## Parameters ### bankCode `string` ### accountNo `string` ## Returns [`NormalisedRecipient`](/api/payload/interfacenormalisedrecipient/) ## Example ```ts normaliseBankAccount('014', '1234567890') // → { subTag: '04', value: '0141234567890', type: 'bankAccount' } ``` # normaliseRecipient > **normaliseRecipient**(`raw`, `explicit?`): [`NormalisedRecipient`](/api/payload/interfacenormalisedrecipient/) Defined in: [recipient.ts:58](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L58) Decide the recipient type from the digit count, then format the wire value. Explicit `type` arg overrides the inference — useful if a national ID happens to look like a long e-wallet id or vice versa. Pass `'bankAccount'` to `normaliseBankAccount` instead; it needs two pieces (bank code + account number) the single-string form can't carry. ## Parameters ### raw `string` ### explicit? `"mobile"` \| `"nationalId"` \| `"eWallet"` ## Returns [`NormalisedRecipient`](/api/payload/interfacenormalisedrecipient/) # parseBOTBarcode > **parseBOTBarcode**(`barcode`): [`ParsedBOTBarcode`](/api/payload/interfaceparsedbotbarcode/) \| `null` Defined in: [barcode.ts:108](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L108) Parse a BOT 1D bill-payment barcode back into its component fields. Returns `null` for any structural issue (missing prefix, wrong field count, biller-id too short) so callers can branch without `try/catch`. The trailing amount is decoded back to baht (e.g. `'364922'` → `3649.22`), and the literal "0" sentinel surfaces as `undefined`. ## Parameters ### barcode `string` ## Returns [`ParsedBOTBarcode`](/api/payload/interfaceparsedbotbarcode/) \| `null` ## Examples ```ts parseBOTBarcode('|099999999999990\r111222333444\r\r0') // → { billerId: '099999999999990', ref1: '111222333444' } ``` ```ts parseBOTBarcode('|099400016550100\r123456789012\r670429\r364922') // → { // billerId: '099400016550100', // ref1: '123456789012', // ref2: '670429', // amount: 3649.22, // } ``` # parseFields > **parseFields**(`input`): `Map`\<`string`, `string`\> Defined in: [tlv.ts:75](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L75) Convenience over `iterateFields` — collect into a Map by tag id. ## Parameters ### input `string` ## Returns `Map`\<`string`, `string`\> # parsePayload > **parsePayload**(`payload`, `options?`): [`ParsedPayload`](/api/payload/interfaceparsedpayload/) Defined in: [parser.ts:372](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L372) Parse a wire-format payload. By default throws on structural errors or a hard checksum mismatch (with truncated-CRC auto-fix applied when possible). In `strict: true` mode also throws when the CRC tag is missing or its value fails to match. ## Parameters ### payload `string` ### options? [`ParsePayloadOptions`](/api/payload/interfaceparsepayloadoptions/) = `{}` ## Returns [`ParsedPayload`](/api/payload/interfaceparsedpayload/) # parseSlipVerify > **parseSlipVerify**(`payload`): [`ParsedSlipVerify`](/api/payload/interfaceparsedslipverify/) \| `null` Defined in: [slip-verify.ts:104](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L104) Parse a Slip Verify Mini-QR payload. Returns `null` for any string that isn't a valid slip-verify envelope — wrong root tag, wrong CRC tag, or checksum mismatch. CRCs of 1-3 hex chars are auto-padded with leading zeros (some bank apps drop characters when re-encoding). ## Parameters ### payload `string` ## Returns [`ParsedSlipVerify`](/api/payload/interfaceparsedslipverify/) \| `null` ## Example ```ts parseSlipVerify('004000060000010103002021900021231231212000115102TH91049C30') // → { sendingBank: '002', transRef: '0002123123121200011' } ``` # parseTrueMoneySlipVerify > **parseTrueMoneySlipVerify**(`payload`): [`ParsedTrueMoneySlipVerify`](/api/payload/interfaceparsedtruemoneyslipverify/) \| `null` Defined in: [slip-verify.ts:170](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L170) Parse a TrueMoney Slip Verify Mini-QR payload. Returns `null` for any string that doesn't carry the TrueMoney marker pair (sub-tags 00 + 01 both `'01'`) or whose CRC fails to verify. Comparison is case-insensitive; truncated CRCs (1-3 chars) are auto-padded. ## Parameters ### payload `string` ## Returns [`ParsedTrueMoneySlipVerify`](/api/payload/interfaceparsedtruemoneyslipverify/) \| `null` ## Example ```ts parseTrueMoneySlipVerify('00480002010102010203P2P0313TXN00012345670408250120249104b425') // → { eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024' } ``` # payloadFor > **payloadFor**(`input`): `string` Defined in: [index.ts:67](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/index.ts#L67) Shorthand for the common "make me a PromptPay QR for this recipient with this amount" use case. Returns the wire payload string. ## Parameters ### input #### amount? `number` #### fromSatang? `boolean` #### recipient `string` #### type? [`PromptPayRecipientType`](/api/payload/typealiaspromptpayrecipienttype/) ## Returns `string` ## Example ```ts payloadFor({ recipient: '0812345678', amount: 100 }) // → '00020101021229370016A00000067701011101130066812345678530376454...' ``` # AdditionalDataFields Defined in: [builder.ts:80](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L80) ## Properties ### billNumber? > `optional` **billNumber?**: `string` Defined in: [builder.ts:81](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L81) *** ### consumerDataRequest? > `optional` **consumerDataRequest?**: `string` Defined in: [builder.ts:89](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L89) *** ### customerLabel? > `optional` **customerLabel?**: `string` Defined in: [builder.ts:86](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L86) *** ### loyaltyNumber? > `optional` **loyaltyNumber?**: `string` Defined in: [builder.ts:84](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L84) *** ### mobileNumber? > `optional` **mobileNumber?**: `string` Defined in: [builder.ts:82](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L82) *** ### purposeOfTransaction? > `optional` **purposeOfTransaction?**: `string` Defined in: [builder.ts:88](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L88) *** ### referenceLabel? > `optional` **referenceLabel?**: `string` Defined in: [builder.ts:85](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L85) *** ### storeLabel? > `optional` **storeLabel?**: `string` Defined in: [builder.ts:83](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L83) *** ### terminalLabel? > `optional` **terminalLabel?**: `string` Defined in: [builder.ts:87](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L87) # BOTBarcodeInput Defined in: [barcode.ts:29](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L29) ## Properties ### amount? > `optional` **amount?**: `number` Defined in: [barcode.ts:40](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L40) Baht amount. Omit (or pass `undefined`) for a counter-keyed total — the literal "0" is then written and the cashier types the amount. *** ### billerId > **billerId**: `string` Defined in: [barcode.ts:31](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L31) Cross-bank biller id (Tax ID + suffix). ≤ 15 chars, zero-padded on emit. *** ### ref1 > **ref1**: `string` Defined in: [barcode.ts:33](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L33) Customer / invoice reference. Must be non-empty. *** ### ref2? > `optional` **ref2?**: `string` Defined in: [barcode.ts:35](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L35) Optional secondary reference. Empty string on the wire if omitted. # FormatAmountOptions Defined in: [amount.ts:12](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/amount.ts#L12) ## Properties ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: [amount.ts:14](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/amount.ts#L14) When true, treat the input as integer satang (1 baht = 100 satang). # MerchantInfo Defined in: [builder.ts:97](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L97) ## Properties ### categoryCode? > `optional` **categoryCode?**: `string` Defined in: [builder.ts:105](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L105) 4-digit Merchant Category Code from ISO 18245. *** ### city? > `optional` **city?**: `string` Defined in: [builder.ts:101](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L101) Up to 15 alphanumeric characters. *** ### name? > `optional` **name?**: `string` Defined in: [builder.ts:99](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L99) Up to 25 alphanumeric characters; truncated by the builder. *** ### postalCode? > `optional` **postalCode?**: `string` Defined in: [builder.ts:103](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L103) Up to 10 chars. # NormalisedRecipient Defined in: [recipient.ts:20](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L20) ## Properties ### subTag > `readonly` **subTag**: `"01"` \| `"02"` \| `"03"` \| `"04"` Defined in: [recipient.ts:21](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L21) *** ### type > `readonly` **type**: [`PromptPayRecipientType`](/api/payload/typealiaspromptpayrecipienttype/) Defined in: [recipient.ts:27](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L27) *** ### value > `readonly` **value**: `string` Defined in: [recipient.ts:26](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L26) # ParsedAdditionalData Defined in: [parser.ts:111](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L111) ## Properties ### billNumber? > `optional` **billNumber?**: `string` Defined in: [parser.ts:112](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L112) *** ### consumerDataRequest? > `optional` **consumerDataRequest?**: `string` Defined in: [parser.ts:120](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L120) *** ### customerLabel? > `optional` **customerLabel?**: `string` Defined in: [parser.ts:117](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L117) *** ### loyaltyNumber? > `optional` **loyaltyNumber?**: `string` Defined in: [parser.ts:115](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L115) *** ### mobileNumber? > `optional` **mobileNumber?**: `string` Defined in: [parser.ts:113](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L113) *** ### purposeOfTransaction? > `optional` **purposeOfTransaction?**: `string` Defined in: [parser.ts:119](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L119) *** ### referenceLabel? > `optional` **referenceLabel?**: `string` Defined in: [parser.ts:116](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L116) *** ### storeLabel? > `optional` **storeLabel?**: `string` Defined in: [parser.ts:114](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L114) *** ### terminalLabel? > `optional` **terminalLabel?**: `string` Defined in: [parser.ts:118](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L118) # ParsedBillPayment Defined in: [parser.ts:90](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L90) ## Properties ### billerId > `readonly` **billerId**: `string` Defined in: [parser.ts:92](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L92) *** ### crossBorder > `readonly` **crossBorder**: `boolean` Defined in: [parser.ts:102](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L102) `true` when the merchant template uses the ASEAN cross-border AID (`A000000677012006`). In that mode the `purposeOfTransaction` field (tag 62 sub-tag 08) carries an 18-char triple of currency + local amount + country; the parser surfaces it verbatim under `additionalData.purposeOfTransaction`. *** ### kind > `readonly` **kind**: `"billPayment"` Defined in: [parser.ts:91](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L91) *** ### reference1? > `readonly` `optional` **reference1?**: `string` Defined in: [parser.ts:93](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L93) *** ### reference2? > `readonly` `optional` **reference2?**: `string` Defined in: [parser.ts:94](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L94) # ParsedBOTBarcode Defined in: [barcode.ts:43](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L43) ## Properties ### amount? > `optional` **amount?**: `number` Defined in: [barcode.ts:47](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L47) *** ### billerId > **billerId**: `string` Defined in: [barcode.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L44) *** ### ref1 > **ref1**: `string` Defined in: [barcode.ts:45](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L45) *** ### ref2? > `optional` **ref2?**: `string` Defined in: [barcode.ts:46](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/barcode.ts#L46) # ParsedCRC Defined in: [parser.ts:131](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L131) Bookkeeping for the trailing checksum — useful when reporting auto-fix. ## Properties ### truncated > `readonly` **truncated**: `boolean` Defined in: [parser.ts:137](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L137) True when zero-padding was needed to recover a valid CRC. *** ### valid > `readonly` **valid**: `boolean` Defined in: [parser.ts:135](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L135) True when the wire CRC matches the recomputed value (possibly after padding). *** ### value > `readonly` **value**: `string` Defined in: [parser.ts:133](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L133) The CRC text as it appeared on the wire (may be 1–4 chars). # ParsedPayload Defined in: [parser.ts:140](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L140) ## Properties ### additionalData? > `readonly` `optional` **additionalData?**: [`ParsedAdditionalData`](/api/payload/interfaceparsedadditionaldata/) Defined in: [parser.ts:151](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L151) *** ### amount > `readonly` **amount**: `number` \| `null` Defined in: [parser.ts:144](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L144) *** ### country > `readonly` **country**: `string` Defined in: [parser.ts:146](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L146) *** ### crc > `readonly` **crc**: [`ParsedCRC`](/api/payload/interfaceparsedcrc/) Defined in: [parser.ts:153](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L153) *** ### currency > `readonly` **currency**: `string` Defined in: [parser.ts:145](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L145) *** ### merchant > `readonly` **merchant**: [`ParsedPromptPay`](/api/payload/interfaceparsedpromptpay/) \| [`ParsedBillPayment`](/api/payload/interfaceparsedbillpayment/) \| [`ParsedTrueMoney`](/api/payload/interfaceparsedtruemoney/) \| `null` Defined in: [parser.ts:143](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L143) *** ### merchantCategoryCode? > `readonly` `optional` **merchantCategoryCode?**: `string` Defined in: [parser.ts:149](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L149) *** ### merchantCity? > `readonly` `optional` **merchantCity?**: `string` Defined in: [parser.ts:148](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L148) *** ### merchantName? > `readonly` `optional` **merchantName?**: `string` Defined in: [parser.ts:147](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L147) *** ### payloadFormat > `readonly` **payloadFormat**: `string` Defined in: [parser.ts:141](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L141) *** ### pointOfInitiation > `readonly` **pointOfInitiation**: `"static"` \| `"dynamic"` Defined in: [parser.ts:142](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L142) *** ### postalCode? > `readonly` `optional` **postalCode?**: `string` Defined in: [parser.ts:150](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L150) *** ### rawTags > `readonly` **rawTags**: readonly [`TLVField`](/api/payload/interfacetlvfield/)[] Defined in: [parser.ts:155](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L155) All top-level TLV fields, in wire order. Use for unknown / future tags. *** ### vatTqrc? > `readonly` `optional` **vatTqrc?**: [`ParsedVATTQRC`](/api/payload/interfaceparsedvattqrc/) Defined in: [parser.ts:152](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L152) ## Methods ### getTag() > **getTag**(`id`): [`TLVField`](/api/payload/interfacetlvfield/) \| `undefined` Defined in: [parser.ts:157](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L157) Lookup a top-level TLV field by id. Returns `undefined` if absent. #### Parameters ##### id `string` #### Returns [`TLVField`](/api/payload/interfacetlvfield/) \| `undefined` *** ### getTagValue() > **getTagValue**(`id`, `subId?`): `string` \| `undefined` Defined in: [parser.ts:163](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L163) Lookup a value by id. Pass `subId` to descend one level into a nested template (tags 29–31, 62, 64 are templated). Returns `undefined` if either the parent or the sub-field is missing. #### Parameters ##### id `string` ##### subId? `string` #### Returns `string` \| `undefined` # ParsedPromptPay Defined in: [parser.ts:73](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L73) ## Properties ### accountNo? > `readonly` `optional` **accountNo?**: `string` Defined in: [parser.ts:85](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L85) Account number. Present only when `recipientType === 'bankAccount'`. *** ### bankCode? > `readonly` `optional` **bankCode?**: `string` Defined in: [parser.ts:83](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L83) Bank code (3 digits). Present only when `recipientType === 'bankAccount'`. *** ### kind > `readonly` **kind**: `"promptpay"` Defined in: [parser.ts:74](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L74) *** ### ota? > `readonly` `optional` **ota?**: `string` Defined in: [parser.ts:87](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L87) One-Time Authorization code from sub-tag 05. Present only on OTA payloads. *** ### recipient > `readonly` **recipient**: `string` Defined in: [parser.ts:81](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L81) Wire value for the recipient sub-tag. For `bankAccount` this is the full `bankCode + accountNo` concatenation — split fields are exposed separately below. *** ### recipientType > `readonly` **recipientType**: [`PromptPayRecipientType`](/api/payload/typealiaspromptpayrecipienttype/) Defined in: [parser.ts:75](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L75) # ParsedSlipVerify Defined in: [slip-verify.ts:52](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L52) Decoded payload from `parseSlipVerify`. ## Properties ### sendingBank > `readonly` **sendingBank**: `string` Defined in: [slip-verify.ts:53](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L53) *** ### transRef > `readonly` **transRef**: `string` Defined in: [slip-verify.ts:54](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L54) # ParsedTrueMoney Defined in: [parser.ts:105](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L105) ## Properties ### kind > `readonly` **kind**: `"trueMoney"` Defined in: [parser.ts:106](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L106) *** ### message? > `readonly` `optional` **message?**: `string` Defined in: [parser.ts:108](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L108) *** ### mobileNo > `readonly` **mobileNo**: `string` Defined in: [parser.ts:107](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L107) # ParsedTrueMoneySlipVerify Defined in: [slip-verify.ts:68](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L68) Decoded payload from `parseTrueMoneySlipVerify`. ## Properties ### date > `readonly` **date**: `string` Defined in: [slip-verify.ts:71](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L71) *** ### eventType > `readonly` **eventType**: `string` Defined in: [slip-verify.ts:69](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L69) *** ### transactionId > `readonly` **transactionId**: `string` Defined in: [slip-verify.ts:70](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L70) # ParsedVATTQRC Defined in: [parser.ts:124](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L124) Decoded VAT TQRC template (tag 80). ## Properties ### sellerTaxBranchId > `readonly` **sellerTaxBranchId**: `string` Defined in: [parser.ts:125](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L125) *** ### vatAmount > `readonly` **vatAmount**: `string` Defined in: [parser.ts:127](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L127) *** ### vatRate? > `readonly` `optional` **vatRate?**: `string` Defined in: [parser.ts:126](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L126) # ParsePayloadOptions Defined in: [parser.ts:166](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L166) ## Properties ### strict? > `readonly` `optional` **strict?**: `boolean` Defined in: [parser.ts:173](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/parser.ts#L173) When true, throw if the CRC tag is missing or its on-wire value doesn't match the recomputed checksum. Defaults to false for backwards compatibility with callers that need to consume the truncated-CRC auto-fix path. # SlipVerifyInput Defined in: [slip-verify.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L44) Input for `buildSlipVerify`. ## Properties ### sendingBank > `readonly` **sendingBank**: `string` Defined in: [slip-verify.ts:46](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L46) Bank code that issued the slip (e.g. `'002'` for Bangkok Bank). *** ### transRef > `readonly` **transRef**: `string` Defined in: [slip-verify.ts:48](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L48) Transaction reference printed on the slip. # TLVField Defined in: [tlv.ts:11](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L11) A parsed TLV field with its (possibly-nested) value text. ## Properties ### tag > `readonly` **tag**: `string` Defined in: [tlv.ts:12](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L12) *** ### value > `readonly` **value**: `string` Defined in: [tlv.ts:13](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tlv.ts#L13) # TrueMoneySlipVerifyInput Defined in: [slip-verify.ts:58](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L58) Input for `buildTrueMoneySlipVerify`. ## Properties ### date > `readonly` **date**: `string` Defined in: [slip-verify.ts:64](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L64) Transfer date as a `DDMMYYYY` 8-character string. *** ### eventType > `readonly` **eventType**: `string` Defined in: [slip-verify.ts:60](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L60) Event classification (e.g. `'P2P'`). *** ### transactionId > `readonly` **transactionId**: `string` Defined in: [slip-verify.ts:62](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/slip-verify.ts#L62) Wallet transaction identifier. # VATTQRCInput Defined in: [builder.ts:108](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L108) ## Properties ### sellerTaxBranchId > **sellerTaxBranchId**: `string` Defined in: [builder.ts:110](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L110) Seller's tax branch identifier — exactly 4 characters. *** ### vatAmount > **vatAmount**: `string` Defined in: [builder.ts:114](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L114) VAT amount as displayed on the receipt; 1–13 chars, required. *** ### vatRate? > `optional` **vatRate?**: `string` Defined in: [builder.ts:112](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L112) VAT rate as displayed on the receipt (e.g. "7" or "7.00"); 1–5 chars. # Tags ## Variables - [COUNTRY\_TH](/api/payload/tagsvariablecountry_th/) - [CURRENCY\_THB](/api/payload/tagsvariablecurrency_thb/) - [GUID\_BILL\_PAYMENT](/api/payload/tagsvariableguid_bill_payment/) - [GUID\_BILL\_PAYMENT\_CROSS\_BORDER](/api/payload/tagsvariableguid_bill_payment_cross_border/) - [GUID\_PROMPTPAY](/api/payload/tagsvariableguid_promptpay/) - [GUID\_PROMPTPAY\_OTA](/api/payload/tagsvariableguid_promptpay_ota/) - [PAYLOAD\_FORMAT\_VERSION](/api/payload/tagsvariablepayload_format_version/) - [POI\_DYNAMIC](/api/payload/tagsvariablepoi_dynamic/) - [POI\_STATIC](/api/payload/tagsvariablepoi_static/) - [SUB\_ADD\_BILL\_NUMBER](/api/payload/tagsvariablesub_add_bill_number/) - [SUB\_ADD\_CONSUMER\_DATA\_REQUEST](/api/payload/tagsvariablesub_add_consumer_data_request/) - [SUB\_ADD\_CUSTOMER\_LABEL](/api/payload/tagsvariablesub_add_customer_label/) - [SUB\_ADD\_LOYALTY\_NUMBER](/api/payload/tagsvariablesub_add_loyalty_number/) - [SUB\_ADD\_MOBILE\_NUMBER](/api/payload/tagsvariablesub_add_mobile_number/) - [SUB\_ADD\_PURPOSE\_OF\_TRANSACTION](/api/payload/tagsvariablesub_add_purpose_of_transaction/) - [SUB\_ADD\_REFERENCE\_LABEL](/api/payload/tagsvariablesub_add_reference_label/) - [SUB\_ADD\_STORE\_LABEL](/api/payload/tagsvariablesub_add_store_label/) - [SUB\_ADD\_TERMINAL\_LABEL](/api/payload/tagsvariablesub_add_terminal_label/) - [SUB\_BILL\_BILLER\_ID](/api/payload/tagsvariablesub_bill_biller_id/) - [SUB\_BILL\_REFERENCE\_1](/api/payload/tagsvariablesub_bill_reference_1/) - [SUB\_BILL\_REFERENCE\_2](/api/payload/tagsvariablesub_bill_reference_2/) - [SUB\_GUID](/api/payload/tagsvariablesub_guid/) - [SUB\_PROMPTPAY\_BANK\_ACCOUNT](/api/payload/tagsvariablesub_promptpay_bank_account/) - [SUB\_PROMPTPAY\_EWALLET](/api/payload/tagsvariablesub_promptpay_ewallet/) - [SUB\_PROMPTPAY\_MOBILE](/api/payload/tagsvariablesub_promptpay_mobile/) - [SUB\_PROMPTPAY\_NATIONAL\_ID](/api/payload/tagsvariablesub_promptpay_national_id/) - [SUB\_PROMPTPAY\_OTA](/api/payload/tagsvariablesub_promptpay_ota/) - [SUB\_TRUE\_MONEY](/api/payload/tagsvariablesub_true_money/) - [SUB\_VAT\_AMOUNT](/api/payload/tagsvariablesub_vat_amount/) - [SUB\_VAT\_RATE](/api/payload/tagsvariablesub_vat_rate/) - [SUB\_VAT\_SELLER\_TAX\_BRANCH\_ID](/api/payload/tagsvariablesub_vat_seller_tax_branch_id/) - [TAG\_ADDITIONAL\_DATA](/api/payload/tagsvariabletag_additional_data/) - [TAG\_CHECKSUM](/api/payload/tagsvariabletag_checksum/) - [TAG\_COUNTRY\_CODE](/api/payload/tagsvariabletag_country_code/) - [TAG\_LANGUAGE\_TEMPLATE](/api/payload/tagsvariabletag_language_template/) - [TAG\_MERCHANT\_ACCOUNT\_BILL\_PAYMENT](/api/payload/tagsvariabletag_merchant_account_bill_payment/) - [TAG\_MERCHANT\_ACCOUNT\_KSHOP](/api/payload/tagsvariabletag_merchant_account_kshop/) - [TAG\_MERCHANT\_ACCOUNT\_PROMPTPAY](/api/payload/tagsvariabletag_merchant_account_promptpay/) - [TAG\_MERCHANT\_CATEGORY\_CODE](/api/payload/tagsvariabletag_merchant_category_code/) - [TAG\_MERCHANT\_CITY](/api/payload/tagsvariabletag_merchant_city/) - [TAG\_MERCHANT\_NAME](/api/payload/tagsvariabletag_merchant_name/) - [TAG\_PAYLOAD\_FORMAT](/api/payload/tagsvariabletag_payload_format/) - [TAG\_PERSONAL\_MESSAGE](/api/payload/tagsvariabletag_personal_message/) - [TAG\_POINT\_OF\_INITIATION](/api/payload/tagsvariabletag_point_of_initiation/) - [TAG\_POSTAL\_CODE](/api/payload/tagsvariabletag_postal_code/) - [TAG\_TIP\_FIXED](/api/payload/tagsvariabletag_tip_fixed/) - [TAG\_TIP\_OR\_CONVENIENCE\_INDICATOR](/api/payload/tagsvariabletag_tip_or_convenience_indicator/) - [TAG\_TIP\_PERCENTAGE](/api/payload/tagsvariabletag_tip_percentage/) - [TAG\_TRANSACTION\_AMOUNT](/api/payload/tagsvariabletag_transaction_amount/) - [TAG\_TRANSACTION\_CURRENCY](/api/payload/tagsvariabletag_transaction_currency/) - [TAG\_VAT\_TQRC](/api/payload/tagsvariabletag_vat_tqrc/) - [TIP\_FIXED](/api/payload/tagsvariabletip_fixed/) - [TIP\_PERCENTAGE](/api/payload/tagsvariabletip_percentage/) - [TIP\_PROMPT](/api/payload/tagsvariabletip_prompt/) - [TRUE\_MONEY\_PREFIX](/api/payload/tagsvariabletrue_money_prefix/) # @thai-qr-payment/payload ## Namespaces - [Tags](/api/payload/namespacetags/) ## Classes - [ThaiQRPaymentBuilder](/api/payload/classthaiqrpaymentbuilder/) ## Interfaces - [AdditionalDataFields](/api/payload/interfaceadditionaldatafields/) - [BOTBarcodeInput](/api/payload/interfacebotbarcodeinput/) - [FormatAmountOptions](/api/payload/interfaceformatamountoptions/) - [MerchantInfo](/api/payload/interfacemerchantinfo/) - [NormalisedRecipient](/api/payload/interfacenormalisedrecipient/) - [ParsedAdditionalData](/api/payload/interfaceparsedadditionaldata/) - [ParsedBillPayment](/api/payload/interfaceparsedbillpayment/) - [ParsedBOTBarcode](/api/payload/interfaceparsedbotbarcode/) - [ParsedCRC](/api/payload/interfaceparsedcrc/) - [ParsedPayload](/api/payload/interfaceparsedpayload/) - [ParsedPromptPay](/api/payload/interfaceparsedpromptpay/) - [ParsedSlipVerify](/api/payload/interfaceparsedslipverify/) - [ParsedTrueMoney](/api/payload/interfaceparsedtruemoney/) - [ParsedTrueMoneySlipVerify](/api/payload/interfaceparsedtruemoneyslipverify/) - [ParsedVATTQRC](/api/payload/interfaceparsedvattqrc/) - [ParsePayloadOptions](/api/payload/interfaceparsepayloadoptions/) - [SlipVerifyInput](/api/payload/interfaceslipverifyinput/) - [TLVField](/api/payload/interfacetlvfield/) - [TrueMoneySlipVerifyInput](/api/payload/interfacetruemoneyslipverifyinput/) - [VATTQRCInput](/api/payload/interfacevattqrcinput/) ## Type Aliases - [PromptPayRecipientType](/api/payload/typealiaspromptpayrecipienttype/) - [TipMode](/api/payload/typealiastipmode/) ## Functions - [buildBOTBarcode](/api/payload/functionbuildbotbarcode/) - [buildSlipVerify](/api/payload/functionbuildslipverify/) - [buildTrueMoneySlipVerify](/api/payload/functionbuildtruemoneyslipverify/) - [checksum](/api/payload/functionchecksum/) - [decodePersonalMessage](/api/payload/functiondecodepersonalmessage/) - [encodeField](/api/payload/functionencodefield/) - [encodeFields](/api/payload/functionencodefields/) - [encodePersonalMessage](/api/payload/functionencodepersonalmessage/) - [formatAmount](/api/payload/functionformatamount/) - [iterateFields](/api/payload/functioniteratefields/) - [normaliseBankAccount](/api/payload/functionnormalisebankaccount/) - [normaliseRecipient](/api/payload/functionnormaliserecipient/) - [parseBOTBarcode](/api/payload/functionparsebotbarcode/) - [parseFields](/api/payload/functionparsefields/) - [parsePayload](/api/payload/functionparsepayload/) - [parseSlipVerify](/api/payload/functionparseslipverify/) - [parseTrueMoneySlipVerify](/api/payload/functionparsetruemoneyslipverify/) - [payloadFor](/api/payload/functionpayloadfor/) # COUNTRY_TH > `const` **COUNTRY\_TH**: `"TH"` = `'TH'` Defined in: [tags.ts:68](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L68) # CURRENCY_THB > `const` **CURRENCY\_THB**: `"764"` = `'764'` Defined in: [tags.ts:67](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L67) # GUID_BILL_PAYMENT > `const` **GUID\_BILL\_PAYMENT**: `"A000000677010112"` = `'A000000677010112'` Defined in: [tags.ts:70](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L70) # GUID_BILL_PAYMENT_CROSS_BORDER > `const` **GUID\_BILL\_PAYMENT\_CROSS\_BORDER**: `"A000000677012006"` = `'A000000677012006'` Defined in: [tags.ts:79](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L79) # GUID_PROMPTPAY > `const` **GUID\_PROMPTPAY**: `"A000000677010111"` = `'A000000677010111'` Defined in: [tags.ts:69](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L69) # GUID_PROMPTPAY_OTA > `const` **GUID\_PROMPTPAY\_OTA**: `"A000000677010114"` = `'A000000677010114'` Defined in: [tags.ts:74](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L74) # PAYLOAD_FORMAT_VERSION > `const` **PAYLOAD\_FORMAT\_VERSION**: `"01"` = `'01'` Defined in: [tags.ts:64](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L64) # POI_DYNAMIC > `const` **POI\_DYNAMIC**: `"12"` = `'12'` Defined in: [tags.ts:66](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L66) # POI_STATIC > `const` **POI\_STATIC**: `"11"` = `'11'` Defined in: [tags.ts:65](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L65) # SUB_ADD_BILL_NUMBER > `const` **SUB\_ADD\_BILL\_NUMBER**: `"01"` = `'01'` Defined in: [tags.ts:53](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L53) # SUB_ADD_CONSUMER_DATA_REQUEST > `const` **SUB\_ADD\_CONSUMER\_DATA\_REQUEST**: `"09"` = `'09'` Defined in: [tags.ts:61](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L61) # SUB_ADD_CUSTOMER_LABEL > `const` **SUB\_ADD\_CUSTOMER\_LABEL**: `"06"` = `'06'` Defined in: [tags.ts:58](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L58) # SUB_ADD_LOYALTY_NUMBER > `const` **SUB\_ADD\_LOYALTY\_NUMBER**: `"04"` = `'04'` Defined in: [tags.ts:56](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L56) # SUB_ADD_MOBILE_NUMBER > `const` **SUB\_ADD\_MOBILE\_NUMBER**: `"02"` = `'02'` Defined in: [tags.ts:54](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L54) # SUB_ADD_PURPOSE_OF_TRANSACTION > `const` **SUB\_ADD\_PURPOSE\_OF\_TRANSACTION**: `"08"` = `'08'` Defined in: [tags.ts:60](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L60) # SUB_ADD_REFERENCE_LABEL > `const` **SUB\_ADD\_REFERENCE\_LABEL**: `"05"` = `'05'` Defined in: [tags.ts:57](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L57) # SUB_ADD_STORE_LABEL > `const` **SUB\_ADD\_STORE\_LABEL**: `"03"` = `'03'` Defined in: [tags.ts:55](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L55) # SUB_ADD_TERMINAL_LABEL > `const` **SUB\_ADD\_TERMINAL\_LABEL**: `"07"` = `'07'` Defined in: [tags.ts:59](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L59) # SUB_BILL_BILLER_ID > `const` **SUB\_BILL\_BILLER\_ID**: `"01"` = `'01'` Defined in: [tags.ts:48](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L48) # SUB_BILL_REFERENCE_1 > `const` **SUB\_BILL\_REFERENCE\_1**: `"02"` = `'02'` Defined in: [tags.ts:49](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L49) # SUB_BILL_REFERENCE_2 > `const` **SUB\_BILL\_REFERENCE\_2**: `"03"` = `'03'` Defined in: [tags.ts:50](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L50) # SUB_GUID > `const` **SUB\_GUID**: `"00"` = `'00'` Defined in: [tags.ts:33](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L33) # SUB_PROMPTPAY_BANK_ACCOUNT > `const` **SUB\_PROMPTPAY\_BANK\_ACCOUNT**: `"04"` = `'04'` Defined in: [tags.ts:37](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L37) # SUB_PROMPTPAY_EWALLET > `const` **SUB\_PROMPTPAY\_EWALLET**: `"03"` = `'03'` Defined in: [tags.ts:36](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L36) # SUB_PROMPTPAY_MOBILE > `const` **SUB\_PROMPTPAY\_MOBILE**: `"01"` = `'01'` Defined in: [tags.ts:34](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L34) # SUB_PROMPTPAY_NATIONAL_ID > `const` **SUB\_PROMPTPAY\_NATIONAL\_ID**: `"02"` = `'02'` Defined in: [tags.ts:35](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L35) # SUB_PROMPTPAY_OTA > `const` **SUB\_PROMPTPAY\_OTA**: `"05"` = `'05'` Defined in: [tags.ts:38](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L38) # SUB_TRUE_MONEY > `const` **SUB\_TRUE\_MONEY**: `"03"` = `'03'` Defined in: [tags.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L44) # SUB_VAT_AMOUNT > `const` **SUB\_VAT\_AMOUNT**: `"02"` = `'02'` Defined in: [tags.ts:93](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L93) # SUB_VAT_RATE > `const` **SUB\_VAT\_RATE**: `"01"` = `'01'` Defined in: [tags.ts:92](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L92) # SUB_VAT_SELLER_TAX_BRANCH_ID > `const` **SUB\_VAT\_SELLER\_TAX\_BRANCH\_ID**: `"00"` = `'00'` Defined in: [tags.ts:91](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L91) # TAG_ADDITIONAL_DATA > `const` **TAG\_ADDITIONAL\_DATA**: `"62"` = `'62'` Defined in: [tags.ts:27](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L27) # TAG_CHECKSUM > `const` **TAG\_CHECKSUM**: `"63"` = `'63'` Defined in: [tags.ts:28](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L28) # TAG_COUNTRY_CODE > `const` **TAG\_COUNTRY\_CODE**: `"58"` = `'58'` Defined in: [tags.ts:23](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L23) # TAG_LANGUAGE_TEMPLATE > `const` **TAG\_LANGUAGE\_TEMPLATE**: `"64"` = `'64'` Defined in: [tags.ts:29](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L29) # TAG_MERCHANT_ACCOUNT_BILL_PAYMENT > `const` **TAG\_MERCHANT\_ACCOUNT\_BILL\_PAYMENT**: `"30"` = `'30'` Defined in: [tags.ts:15](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L15) # TAG_MERCHANT_ACCOUNT_KSHOP > `const` **TAG\_MERCHANT\_ACCOUNT\_KSHOP**: `"31"` = `'31'` Defined in: [tags.ts:16](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L16) # TAG_MERCHANT_ACCOUNT_PROMPTPAY > `const` **TAG\_MERCHANT\_ACCOUNT\_PROMPTPAY**: `"29"` = `'29'` Defined in: [tags.ts:14](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L14) # TAG_MERCHANT_CATEGORY_CODE > `const` **TAG\_MERCHANT\_CATEGORY\_CODE**: `"52"` = `'52'` Defined in: [tags.ts:17](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L17) # TAG_MERCHANT_CITY > `const` **TAG\_MERCHANT\_CITY**: `"60"` = `'60'` Defined in: [tags.ts:25](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L25) # TAG_MERCHANT_NAME > `const` **TAG\_MERCHANT\_NAME**: `"59"` = `'59'` Defined in: [tags.ts:24](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L24) # TAG_PAYLOAD_FORMAT > `const` **TAG\_PAYLOAD\_FORMAT**: `"00"` = `'00'` Defined in: [tags.ts:12](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L12) EMVCo Merchant-Presented-Mode QR Code Specification — tag registry. Source: EMVCo MPM v1.1 §3 — public spec; Bank of Thailand and KASIKORN adopt the same numbering with Thai-specific GUIDs under templates 29-31. Tags are stringly-typed (two-character zero-padded decimal) on the wire but exposed here as named constants so call sites stay readable. # TAG_PERSONAL_MESSAGE > `const` **TAG\_PERSONAL\_MESSAGE**: `"81"` = `'81'` Defined in: [tags.ts:30](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L30) # TAG_POINT_OF_INITIATION > `const` **TAG\_POINT\_OF\_INITIATION**: `"01"` = `'01'` Defined in: [tags.ts:13](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L13) # TAG_POSTAL_CODE > `const` **TAG\_POSTAL\_CODE**: `"61"` = `'61'` Defined in: [tags.ts:26](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L26) # TAG_TIP_FIXED > `const` **TAG\_TIP\_FIXED**: `"56"` = `'56'` Defined in: [tags.ts:21](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L21) # TAG_TIP_OR_CONVENIENCE_INDICATOR > `const` **TAG\_TIP\_OR\_CONVENIENCE\_INDICATOR**: `"55"` = `'55'` Defined in: [tags.ts:20](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L20) # TAG_TIP_PERCENTAGE > `const` **TAG\_TIP\_PERCENTAGE**: `"57"` = `'57'` Defined in: [tags.ts:22](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L22) # TAG_TRANSACTION_AMOUNT > `const` **TAG\_TRANSACTION\_AMOUNT**: `"54"` = `'54'` Defined in: [tags.ts:19](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L19) # TAG_TRANSACTION_CURRENCY > `const` **TAG\_TRANSACTION\_CURRENCY**: `"53"` = `'53'` Defined in: [tags.ts:18](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L18) # TAG_VAT_TQRC > `const` **TAG\_VAT\_TQRC**: `"80"` = `'80'` Defined in: [tags.ts:90](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L90) # TIP_FIXED > `const` **TIP\_FIXED**: `"02"` = `'02'` Defined in: [tags.ts:83](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L83) # TIP_PERCENTAGE > `const` **TIP\_PERCENTAGE**: `"03"` = `'03'` Defined in: [tags.ts:84](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L84) # TIP_PROMPT > `const` **TIP\_PROMPT**: `"01"` = `'01'` Defined in: [tags.ts:82](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L82) # TRUE_MONEY_PREFIX > `const` **TRUE\_MONEY\_PREFIX**: `"14"` = `'14'` Defined in: [tags.ts:45](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/tags.ts#L45) # PromptPayRecipientType > **PromptPayRecipientType** = `"mobile"` \| `"nationalId"` \| `"eWallet"` \| `"bankAccount"` Defined in: [recipient.ts:18](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/recipient.ts#L18) # TipMode > **TipMode** = \{ `mode`: `"prompt"`; \} \| \{ `fromSatang?`: `boolean`; `mode`: `"fixed"`; `value`: `number`; \} \| \{ `mode`: `"percentage"`; `value`: `number`; \} Defined in: [builder.ts:92](https://github.com/uunw/thai-qr-payment/blob/main/packages/payload/src/builder.ts#L92) # detectMode > **detectMode**(`text`): [`EncodingMode`](/api/qr/typealiasencodingmode/) Defined in: [mode.ts:49](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/mode.ts#L49) Detect the narrowest mode that can encode the entire input. ## Parameters ### text `string` ## Returns [`EncodingMode`](/api/qr/typealiasencodingmode/) # encodeQR > **encodeQR**(`text`, `options?`): [`QRMatrix`](/api/qr/interfaceqrmatrix/) Defined in: [encoder.ts:122](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L122) Encode `text` as a QR Code matrix. The returned matrix is a square 2-D boolean array (`true` = dark module). Render with any output (SVG, canvas, PNG, terminal). ## Parameters ### text `string` ### options? [`EncodeOptions`](/api/qr/interfaceencodeoptions/) = `{}` ## Returns [`QRMatrix`](/api/qr/interfaceqrmatrix/) # EncodeOptions Defined in: [encoder.ts:27](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L27) ## Properties ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: [`ErrorCorrectionLevel`](/api/qr/typealiaserrorcorrectionlevel/) Defined in: [encoder.ts:28](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L28) *** ### forceMask? > `optional` **forceMask?**: `number` Defined in: [encoder.ts:31](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L31) *** ### maxVersion? > `optional` **maxVersion?**: `number` Defined in: [encoder.ts:30](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L30) *** ### minVersion? > `optional` **minVersion?**: `number` Defined in: [encoder.ts:29](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L29) # QRMatrix Defined in: [encoder.ts:34](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L34) ## Properties ### errorCorrectionLevel > `readonly` **errorCorrectionLevel**: [`ErrorCorrectionLevel`](/api/qr/typealiaserrorcorrectionlevel/) Defined in: [encoder.ts:38](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L38) *** ### mask > `readonly` **mask**: `number` Defined in: [encoder.ts:39](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L39) *** ### modules > `readonly` **modules**: `boolean`[][] Defined in: [encoder.ts:36](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L36) *** ### size > `readonly` **size**: `number` Defined in: [encoder.ts:35](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L35) *** ### version > `readonly` **version**: `number` Defined in: [encoder.ts:37](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/encoder.ts#L37) # @thai-qr-payment/qr ## Interfaces - [EncodeOptions](/api/qr/interfaceencodeoptions/) - [QRMatrix](/api/qr/interfaceqrmatrix/) ## Type Aliases - [EncodingMode](/api/qr/typealiasencodingmode/) - [ErrorCorrectionLevel](/api/qr/typealiaserrorcorrectionlevel/) ## Functions - [detectMode](/api/qr/functiondetectmode/) - [encodeQR](/api/qr/functionencodeqr/) # EncodingMode > **EncodingMode** = `"numeric"` \| `"alphanumeric"` \| `"byte"` Defined in: [mode.ts:15](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/mode.ts#L15) # ErrorCorrectionLevel > **ErrorCorrectionLevel** = `"L"` \| `"M"` \| `"Q"` \| `"H"` Defined in: [version.ts:13](https://github.com/uunw/thai-qr-payment/blob/main/packages/qr/src/version.ts#L13) Capacity tables + version metadata from ISO/IEC 18004 §6.5 and Annex D. Each version 1-40 has 4 ECC levels (L, M, Q, H). For each (version, ECC) the spec defines: - Total data codewords (`dataCodewords`) - Number of error-correction blocks (groups) - Block sizes within each group The matrix dimension is `(version - 1) * 4 + 21`. # ThaiQRPayment > **ThaiQRPayment**(`__namedParameters`): `ReactElement` Defined in: [react/src/index.tsx:49](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L49) Full Thai QR Payment card (header logo + QR + amount). ## Parameters ### \_\_namedParameters [`ThaiQRPaymentProps`](/api/react/interfacethaiqrpaymentprops/) ## Returns `ReactElement` # ThaiQRPaymentMatrix > **ThaiQRPaymentMatrix**(`__namedParameters`): `ReactElement` Defined in: [react/src/index.tsx:86](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L86) Just the QR matrix (no card chrome). ## Parameters ### \_\_namedParameters [`ThaiQRPaymentMatrixProps`](/api/react/interfacethaiqrpaymentmatrixprops/) ## Returns `ReactElement` # ThaiQRPaymentMatrixProps Defined in: [react/src/index.tsx:37](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L37) ## Extends - `QRSvgOptions` ## Properties ### amount? > `optional` **amount?**: `number` Defined in: [react/src/index.tsx:39](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L39) *** ### ariaLabel? > `optional` **ariaLabel?**: `string` Defined in: [react/src/index.tsx:45](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L45) *** ### background? > `optional` **background?**: `string` Defined in: render/dist/matrix-svg.d.ts:19 Background colour (set to `transparent` to omit). Defaults to `#fff`. #### Inherited from `QRSvgOptions.background` *** ### className? > `optional` **className?**: `string` Defined in: [react/src/index.tsx:43](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L43) *** ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: `ErrorCorrectionLevel` Defined in: [react/src/index.tsx:42](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L42) *** ### foreground? > `optional` **foreground?**: `string` Defined in: render/dist/matrix-svg.d.ts:17 Dark module colour. Defaults to `#000`. #### Inherited from `QRSvgOptions.foreground` *** ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: [react/src/index.tsx:41](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L41) *** ### quietZone? > `optional` **quietZone?**: `number` Defined in: render/dist/matrix-svg.d.ts:15 Quiet-zone width in modules. EMVCo recommends 4. #### Inherited from `QRSvgOptions.quietZone` *** ### recipient > **recipient**: `string` Defined in: [react/src/index.tsx:38](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L38) *** ### recipientType? > `optional` **recipientType?**: `PromptPayRecipientType` Defined in: [react/src/index.tsx:40](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L40) *** ### rootAttributes? > `optional` **rootAttributes?**: `Record`\<`string`, `string`\> Defined in: render/dist/matrix-svg.d.ts:21 Additional attributes added verbatim to the root `` element. #### Inherited from `QRSvgOptions.rootAttributes` *** ### size? > `optional` **size?**: `number` Defined in: render/dist/matrix-svg.d.ts:13 Output width in user units (px by default). Defaults to module count. #### Inherited from `QRSvgOptions.size` *** ### style? > `optional` **style?**: `CSSProperties` Defined in: [react/src/index.tsx:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L44) # ThaiQRPaymentProps Defined in: [react/src/index.tsx:25](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L25) ## Extends - `CardOptions` ## Properties ### accent? > `optional` **accent?**: `string` Defined in: render/dist/card.d.ts:48 Foreground / accent colour for text + silhouette artwork. #### Inherited from `CardOptions.accent` *** ### amount? > `optional` **amount?**: `number` Defined in: [react/src/index.tsx:27](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L27) *** ### amountLabel? > `optional` **amountLabel?**: `string` Defined in: render/dist/card.d.ts:42 Optional amount label rendered below the QR. #### Inherited from `CardOptions.amountLabel` *** ### ariaLabel? > `optional` **ariaLabel?**: `string` Defined in: [react/src/index.tsx:34](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L34) Optional aria-label override; defaults to "Thai QR Payment for ". *** ### background? > `optional` **background?**: `string` Defined in: render/dist/card.d.ts:46 Background colour of the entire card. #### Inherited from `CardOptions.background` *** ### centerOverlay? > `optional` **centerOverlay?**: `boolean` Defined in: render/dist/card.d.ts:61 Overlay the Thai QR Payment icon at the centre of the QR matrix. Defaults to `true` for `theme: 'color'`, `false` for `'silhouette'`. Always pair with `encodeQR({ errorCorrectionLevel: 'Q' | 'H' })` so the obscured modules are recoverable. #### Inherited from `CardOptions.centerOverlay` *** ### className? > `optional` **className?**: `string` Defined in: [react/src/index.tsx:31](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L31) *** ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: `ErrorCorrectionLevel` Defined in: [react/src/index.tsx:30](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L30) *** ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: [react/src/index.tsx:29](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L29) *** ### headerLogo? > `optional` **headerLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: render/dist/card.d.ts:52 Override the Thai QR Payment header logo by registry name. #### Inherited from `CardOptions.headerLogo` *** ### merchantName? > `optional` **merchantName?**: `string` Defined in: render/dist/card.d.ts:44 Optional merchant name rendered below the QR (above the amount). #### Inherited from `CardOptions.merchantName` *** ### promptpayLogo? > `optional` **promptpayLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: render/dist/card.d.ts:54 Override the PromptPay sub-mark by registry name. #### Inherited from `CardOptions.promptpayLogo` *** ### qrColor? > `optional` **qrColor?**: `string` Defined in: render/dist/card.d.ts:50 QR module fill colour. Defaults to `#000000` for max scanner contrast. #### Inherited from `CardOptions.qrColor` *** ### recipient > **recipient**: `string` Defined in: [react/src/index.tsx:26](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L26) *** ### recipientType? > `optional` **recipientType?**: `PromptPayRecipientType` Defined in: [react/src/index.tsx:28](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L28) *** ### style? > `optional` **style?**: `CSSProperties` Defined in: [react/src/index.tsx:32](https://github.com/uunw/thai-qr-payment/blob/main/packages/react/src/index.tsx#L32) *** ### theme? > `optional` **theme?**: `CardTheme` Defined in: render/dist/card.d.ts:40 Brand artwork flavor. `color` keeps full fidelity, `silhouette` is monochrome. #### Inherited from `CardOptions.theme` # @thai-qr-payment/react ## Interfaces - [ThaiQRPaymentMatrixProps](/api/react/interfacethaiqrpaymentmatrixprops/) - [ThaiQRPaymentProps](/api/react/interfacethaiqrpaymentprops/) ## Functions - [ThaiQRPayment](/api/react/functionthaiqrpayment/) - [ThaiQRPaymentMatrix](/api/react/functionthaiqrpaymentmatrix/) # matrixToPath > **matrixToPath**(`matrix`): `string` Defined in: [matrix-svg.ts:12](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L12) Build a path-data string covering every dark module in the matrix. ## Parameters ### matrix `QRMatrix` ## Returns `string` # renderCard > **renderCard**(`matrix`, `options?`): `string` Defined in: [card.ts:173](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L173) Compose the full Thai QR Payment card SVG. ## Parameters ### matrix `QRMatrix` ### options? [`CardOptions`](/api/render/interfacecardoptions/) = `{}` ## Returns `string` # renderQRSvg > **renderQRSvg**(`matrix`, `options?`): `string` Defined in: [matrix-svg.ts:48](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L48) Render a QR matrix to a self-contained `` string. ## Parameters ### matrix `QRMatrix` ### options? [`QRSvgOptions`](/api/render/interfaceqrsvgoptions/) = `{}` ## Returns `string` # renderThaiQRPayment > **renderThaiQRPayment**(`input`): `string` Defined in: [index.ts:32](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L32) One-shot helper: build payload → encode QR → render Thai QR Payment card. Returns the SVG string ready to ship. ## Parameters ### input [`RenderInput`](/api/render/interfacerenderinput/) & `Omit`\<[`CardOptions`](/api/render/interfacecardoptions/), `never`\> ## Returns `string` # renderThaiQRPaymentMatrix > **renderThaiQRPaymentMatrix**(`input`): `string` Defined in: [index.ts:52](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L52) One-shot helper for callers that want only the QR (no header card). Useful when wrapping the QR in your own design system. ## Parameters ### input [`RenderInput`](/api/render/interfacerenderinput/) & [`QRSvgOptions`](/api/render/interfaceqrsvgoptions/) ## Returns `string` # CardOptions Defined in: [card.ts:42](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L42) ## Properties ### accent? > `optional` **accent?**: `string` Defined in: [card.ts:52](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L52) Foreground / accent colour for text + silhouette artwork. *** ### amountLabel? > `optional` **amountLabel?**: `string` Defined in: [card.ts:46](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L46) Optional amount label rendered below the QR. *** ### background? > `optional` **background?**: `string` Defined in: [card.ts:50](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L50) Background colour of the entire card. *** ### centerOverlay? > `optional` **centerOverlay?**: `boolean` Defined in: [card.ts:65](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L65) Overlay the Thai QR Payment icon at the centre of the QR matrix. Defaults to `true` for `theme: 'color'`, `false` for `'silhouette'`. Always pair with `encodeQR({ errorCorrectionLevel: 'Q' | 'H' })` so the obscured modules are recoverable. *** ### headerLogo? > `optional` **headerLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: [card.ts:56](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L56) Override the Thai QR Payment header logo by registry name. *** ### merchantName? > `optional` **merchantName?**: `string` Defined in: [card.ts:48](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L48) Optional merchant name rendered below the QR (above the amount). *** ### promptpayLogo? > `optional` **promptpayLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: [card.ts:58](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L58) Override the PromptPay sub-mark by registry name. *** ### qrColor? > `optional` **qrColor?**: `string` Defined in: [card.ts:54](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L54) QR module fill colour. Defaults to `#000000` for max scanner contrast. *** ### theme? > `optional` **theme?**: [`CardTheme`](/api/render/typealiascardtheme/) Defined in: [card.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L44) Brand artwork flavor. `color` keeps full fidelity, `silhouette` is monochrome. # QRSvgOptions Defined in: [matrix-svg.ts:34](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L34) ## Properties ### background? > `optional` **background?**: `string` Defined in: [matrix-svg.ts:42](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L42) Background colour (set to `transparent` to omit). Defaults to `#fff`. *** ### foreground? > `optional` **foreground?**: `string` Defined in: [matrix-svg.ts:40](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L40) Dark module colour. Defaults to `#000`. *** ### quietZone? > `optional` **quietZone?**: `number` Defined in: [matrix-svg.ts:38](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L38) Quiet-zone width in modules. EMVCo recommends 4. *** ### rootAttributes? > `optional` **rootAttributes?**: `Record`\<`string`, `string`\> Defined in: [matrix-svg.ts:44](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L44) Additional attributes added verbatim to the root `` element. *** ### size? > `optional` **size?**: `number` Defined in: [matrix-svg.ts:36](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/matrix-svg.ts#L36) Output width in user units (px by default). Defaults to module count. # RenderInput Defined in: [index.ts:19](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L19) ## Properties ### amount? > `optional` **amount?**: `number` Defined in: [index.ts:21](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L21) *** ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: `ErrorCorrectionLevel` Defined in: [index.ts:25](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L25) QR error-correction level. `H` gives the best margin for logo overlays. *** ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: [index.ts:23](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L23) *** ### recipient > **recipient**: `string` Defined in: [index.ts:20](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L20) *** ### recipientType? > `optional` **recipientType?**: `PromptPayRecipientType` Defined in: [index.ts:22](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/index.ts#L22) # @thai-qr-payment/render ## Interfaces - [CardOptions](/api/render/interfacecardoptions/) - [QRSvgOptions](/api/render/interfaceqrsvgoptions/) - [RenderInput](/api/render/interfacerenderinput/) ## Type Aliases - [CardTheme](/api/render/typealiascardtheme/) ## Functions - [matrixToPath](/api/render/functionmatrixtopath/) - [renderCard](/api/render/functionrendercard/) - [renderQRSvg](/api/render/functionrenderqrsvg/) - [renderThaiQRPayment](/api/render/functionrenderthaiqrpayment/) - [renderThaiQRPaymentMatrix](/api/render/functionrenderthaiqrpaymentmatrix/) # CardTheme > **CardTheme** = `"color"` \| `"silhouette"` Defined in: [card.ts:40](https://github.com/uunw/thai-qr-payment/blob/main/packages/render/src/card.ts#L40) # ThaiQRPaymentBuilder Defined in: payload/dist/builder.d.ts:66 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 a `Uint8Array` of the ASCII-encoded payload for callers that want to hash or sign it. ## Constructors ### Constructor > **new ThaiQRPaymentBuilder**(): `ThaiQRPaymentBuilder` Defined in: payload/dist/builder.d.ts:74 #### Returns `ThaiQRPaymentBuilder` ## Methods ### additionalData() > **additionalData**(`fields`): `this` Defined in: payload/dist/builder.d.ts:145 Set sub-fields of the additional-data template (tag 62). #### Parameters ##### fields [`AdditionalDataFields`](/api/thai-qr-payment/interfaceadditionaldatafields/) #### Returns `this` *** ### amount() > **amount**(`value`, `options?`): `this` Defined in: payload/dist/builder.d.ts:139 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 ##### value `number` \| `bigint` \| `undefined` ##### options? [`FormatAmountOptions`](/api/thai-qr-payment/interfaceformatamountoptions/) #### Returns `this` *** ### bankAccount() > **bankAccount**(`bankCode`, `accountNo`): `this` Defined in: payload/dist/builder.d.ts:90 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 ##### bankCode `string` ##### accountNo `string` #### Returns `this` #### Example ```ts new ThaiQRPaymentBuilder().bankAccount('014', '1234567890').amount(100).build() ``` *** ### billPayment() > **billPayment**(`input`): `this` Defined in: payload/dist/builder.d.ts:128 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 ##### input ###### billerId `string` ###### crossBorder? `boolean` ###### reference1? `string` ###### reference2? `string` #### Returns `this` *** ### build() > **build**(): `string` Defined in: payload/dist/builder.d.ts:163 Render the full wire-format payload with checksum appended. #### Returns `string` *** ### buildWithChecksum() > **buildWithChecksum**(): `object` Defined in: payload/dist/builder.d.ts:165 Render and split the body/CRC for inspection. #### Returns `object` ##### body > **body**: `string` ##### checksum > **checksum**: `string` ##### payload > **payload**: `string` *** ### merchant() > **merchant**(`info`): `this` Defined in: payload/dist/builder.d.ts:143 Set merchant display info (tags 52, 59, 60, 61). #### Parameters ##### info [`MerchantInfo`](/api/thai-qr-payment/interfacemerchantinfo/) #### Returns `this` *** ### ota() > **ota**(`otaCode`): `this` Defined in: payload/dist/builder.d.ts:99 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 ##### otaCode `string` #### Returns `this` #### Example ```ts new ThaiQRPaymentBuilder().promptpay('0812345678').ota('1234567890').amount(50).build() ``` *** ### pointOfInitiation() > **pointOfInitiation**(`method`): `this` Defined in: payload/dist/builder.d.ts:157 Force the point-of-initiation flag regardless of amount presence. #### Parameters ##### method `"static"` \| `"dynamic"` #### Returns `this` *** ### promptpay() > **promptpay**(`recipient`, `type?`): `this` Defined in: payload/dist/builder.d.ts:81 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 ##### recipient `string` ##### type? [`PromptPayRecipientType`](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) #### Returns `this` *** ### tipPolicy() > **tipPolicy**(`mode`): `this` Defined in: payload/dist/builder.d.ts:141 Set the tip / convenience-fee policy (tags 55-57). #### Parameters ##### mode [`TipMode`](/api/thai-qr-payment/typealiastipmode/) \| `undefined` #### Returns `this` *** ### toBytes() > **toBytes**(): `Uint8Array` Defined in: payload/dist/builder.d.ts:171 UTF-8 byte view of the payload — useful for hashing or transport. #### Returns `Uint8Array` *** ### trueMoney() > **trueMoney**(`mobileNo`, `options?`): `this` Defined in: payload/dist/builder.d.ts:112 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 ##### mobileNo `string` ##### options? ###### amount? `number` ###### message? `string` #### Returns `this` *** ### vatTqrc() > **vatTqrc**(`input`): `this` Defined in: payload/dist/builder.d.ts:155 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: - `sellerTaxBranchId` is exactly 4 characters - `vatRate` is 1–5 characters when present (e.g. "7" or "7.00") - `vatAmount` is 1–13 characters and required #### Parameters ##### input [`VATTQRCInput`](/api/thai-qr-payment/interfacevattqrcinput/) \| `undefined` #### Returns `this` # buildBOTBarcode > **buildBOTBarcode**(`input`): `string` Defined in: payload/dist/barcode.d.ts:59 Build a BOT 1D bill-payment barcode payload. Throws `TypeError` / `RangeError` for malformed input — the caller never silently produces an unscannable barcode. ## Parameters ### input [`BOTBarcodeInput`](/api/thai-qr-payment/interfacebotbarcodeinput/) ## Returns `string` ## Examples ```ts buildBOTBarcode({ billerId: '099999999999990', ref1: '111222333444' }) // → '|099999999999990\r111222333444\r\r0' ``` ```ts buildBOTBarcode({ billerId: '099400016550100', ref1: '123456789012', ref2: '670429', amount: 3649.22, }) // → '|099400016550100\r123456789012\r670429\r364922' ``` # buildSlipVerify > **buildSlipVerify**(`input`): `string` Defined in: payload/dist/slip-verify.d.ts:52 Build a Slip Verify Mini-QR payload. The output is a TLV string ending in a tag-91 CRC (uppercase hex), suitable for embedding in a printed slip and looking the transaction up via bank Open APIs. ## Parameters ### input [`SlipVerifyInput`](/api/thai-qr-payment/interfaceslipverifyinput/) ## Returns `string` ## Example ```ts buildSlipVerify({ sendingBank: '002', transRef: '0002123123121200011' }) // → '004000060000010103002021900021231231212000115102TH91049C30' ``` # buildTrueMoneySlipVerify > **buildTrueMoneySlipVerify**(`input`): `string` Defined in: payload/dist/slip-verify.d.ts:73 Build a TrueMoney Slip Verify Mini-QR payload. Uses the same TLV envelope as the standard variant but with a different sub-tag layout and a **lowercase** hex CRC at tag 91. ## Parameters ### input [`TrueMoneySlipVerifyInput`](/api/thai-qr-payment/interfacetruemoneyslipverifyinput/) ## Returns `string` ## Example ```ts buildTrueMoneySlipVerify({ eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024' }) // → '00480002010102010203P2P0313TXN00012345670408250120249104b425' ``` # checksum > **checksum**(`input`): `string` Defined in: payload/dist/crc.d.ts:15 Compute the CRC-16/CCITT-FALSE checksum of an ASCII-encoded payload and return it as a 4-character uppercase hex string. The EMVCo spec requires the trailing zero-padding to keep the QR payload length stable. ## Parameters ### input `string` ## Returns `string` # decodePersonalMessage > **decodePersonalMessage**(`hex`): `string` Defined in: payload/dist/message.d.ts:14 Decode a UTF-16BE hex string back to its source message. ## Parameters ### hex `string` ## Returns `string` # detectMode > **detectMode**(`text`): [`EncodingMode`](/api/thai-qr-payment/typealiasencodingmode/) Defined in: qr/dist/mode.d.ts:18 Detect the narrowest mode that can encode the entire input. ## Parameters ### text `string` ## Returns [`EncodingMode`](/api/thai-qr-payment/typealiasencodingmode/) # encodeField > **encodeField**(`tag`, `value`): `string` Defined in: payload/dist/tlv.d.ts:15 Encode one TLV. The caller guarantees that `tag` is a valid 2-digit id. ## Parameters ### tag `string` ### value `string` ## Returns `string` # encodeFields > **encodeFields**(`pairs`): `string` Defined in: payload/dist/tlv.d.ts:21 Encode an array of `[tag, value]` pairs in registration order. Empty or `null`/`undefined` values are filtered out so callers can compose optional fields without an `if` chain. ## Parameters ### pairs readonly readonly \[`string`, `string` \| `null` \| `undefined`\][] ## Returns `string` # encodePersonalMessage > **encodePersonalMessage**(`message`): `string` Defined in: payload/dist/message.d.ts:12 Encode a personal message string to UTF-16BE hex (uppercase). ## Parameters ### message `string` ## Returns `string` # encodeQR > **encodeQR**(`text`, `options?`): [`QRMatrix`](/api/thai-qr-payment/interfaceqrmatrix/) Defined in: qr/dist/encoder.d.ts:33 Encode `text` as a QR Code matrix. The returned matrix is a square 2-D boolean array (`true` = dark module). Render with any output (SVG, canvas, PNG, terminal). ## Parameters ### text `string` ### options? [`EncodeOptions`](/api/thai-qr-payment/interfaceencodeoptions/) ## Returns [`QRMatrix`](/api/thai-qr-payment/interfaceqrmatrix/) # formatAmount > **formatAmount**(`value`, `options?`): `string` \| `null` Defined in: payload/dist/amount.d.ts:17 Format an amount for the wire. Returns `null` for static QR (caller intends a "scan and enter any amount" code). ## Parameters ### value `number` \| `bigint` \| `null` \| `undefined` ### options? [`FormatAmountOptions`](/api/thai-qr-payment/interfaceformatamountoptions/) ## Returns `string` \| `null` # iterateFields > **iterateFields**(`input`): `IterableIterator`\<[`TLVField`](/api/thai-qr-payment/interfacetlvfield/)\> Defined in: payload/dist/tlv.d.ts:29 Walk a TLV-encoded string and return one field at a time. Stops cleanly at end-of-input; throws on malformed length headers or truncated values. Designed for parsing both the root payload and nested template values — the same algorithm applies at any depth. ## Parameters ### input `string` ## Returns `IterableIterator`\<[`TLVField`](/api/thai-qr-payment/interfacetlvfield/)\> # matrixToPath > **matrixToPath**(`matrix`): `string` Defined in: render/dist/matrix-svg.d.ts:10 Build a path-data string covering every dark module in the matrix. ## Parameters ### matrix [`QRMatrix`](/api/thai-qr-payment/interfaceqrmatrix/) ## Returns `string` # normaliseBankAccount > **normaliseBankAccount**(`bankCode`, `accountNo`): [`NormalisedRecipient`](/api/thai-qr-payment/interfacenormalisedrecipient/) Defined in: payload/dist/recipient.d.ts:35 Format a bank-account recipient for sub-tag 04 under the PromptPay merchant template. The wire value is the 3-digit bank code followed by the (variable-length, numeric) account number; total length must fit EMVCo's 1–43-character cap on the sub-tag. ## Parameters ### bankCode `string` ### accountNo `string` ## Returns [`NormalisedRecipient`](/api/thai-qr-payment/interfacenormalisedrecipient/) ## Example ```ts normaliseBankAccount('014', '1234567890') // → { subTag: '04', value: '0141234567890', type: 'bankAccount' } ``` # normaliseRecipient > **normaliseRecipient**(`raw`, `explicit?`): [`NormalisedRecipient`](/api/thai-qr-payment/interfacenormalisedrecipient/) Defined in: payload/dist/recipient.d.ts:24 Decide the recipient type from the digit count, then format the wire value. Explicit `type` arg overrides the inference — useful if a national ID happens to look like a long e-wallet id or vice versa. Pass `'bankAccount'` to `normaliseBankAccount` instead; it needs two pieces (bank code + account number) the single-string form can't carry. ## Parameters ### raw `string` ### explicit? `"mobile"` \| `"nationalId"` \| `"eWallet"` ## Returns [`NormalisedRecipient`](/api/thai-qr-payment/interfacenormalisedrecipient/) # parseBOTBarcode > **parseBOTBarcode**(`barcode`): [`ParsedBOTBarcode`](/api/thai-qr-payment/interfaceparsedbotbarcode/) \| `null` Defined in: payload/dist/barcode.d.ts:81 Parse a BOT 1D bill-payment barcode back into its component fields. Returns `null` for any structural issue (missing prefix, wrong field count, biller-id too short) so callers can branch without `try/catch`. The trailing amount is decoded back to baht (e.g. `'364922'` → `3649.22`), and the literal "0" sentinel surfaces as `undefined`. ## Parameters ### barcode `string` ## Returns [`ParsedBOTBarcode`](/api/thai-qr-payment/interfaceparsedbotbarcode/) \| `null` ## Examples ```ts parseBOTBarcode('|099999999999990\r111222333444\r\r0') // → { billerId: '099999999999990', ref1: '111222333444' } ``` ```ts parseBOTBarcode('|099400016550100\r123456789012\r670429\r364922') // → { // billerId: '099400016550100', // ref1: '123456789012', // ref2: '670429', // amount: 3649.22, // } ``` # parseFields > **parseFields**(`input`): `Map`\<`string`, `string`\> Defined in: payload/dist/tlv.d.ts:31 Convenience over `iterateFields` — collect into a Map by tag id. ## Parameters ### input `string` ## Returns `Map`\<`string`, `string`\> # parsePayload > **parsePayload**(`payload`, `options?`): [`ParsedPayload`](/api/thai-qr-payment/interfaceparsedpayload/) Defined in: payload/dist/parser.d.ts:121 Parse a wire-format payload. By default throws on structural errors or a hard checksum mismatch (with truncated-CRC auto-fix applied when possible). In `strict: true` mode also throws when the CRC tag is missing or its value fails to match. ## Parameters ### payload `string` ### options? [`ParsePayloadOptions`](/api/thai-qr-payment/interfaceparsepayloadoptions/) ## Returns [`ParsedPayload`](/api/thai-qr-payment/interfaceparsedpayload/) # parseSlipVerify > **parseSlipVerify**(`payload`): [`ParsedSlipVerify`](/api/thai-qr-payment/interfaceparsedslipverify/) \| `null` Defined in: payload/dist/slip-verify.d.ts:63 Parse a Slip Verify Mini-QR payload. Returns `null` for any string that isn't a valid slip-verify envelope — wrong root tag, wrong CRC tag, or checksum mismatch. CRCs of 1-3 hex chars are auto-padded with leading zeros (some bank apps drop characters when re-encoding). ## Parameters ### payload `string` ## Returns [`ParsedSlipVerify`](/api/thai-qr-payment/interfaceparsedslipverify/) \| `null` ## Example ```ts parseSlipVerify('004000060000010103002021900021231231212000115102TH91049C30') // → { sendingBank: '002', transRef: '0002123123121200011' } ``` # parseTrueMoneySlipVerify > **parseTrueMoneySlipVerify**(`payload`): [`ParsedTrueMoneySlipVerify`](/api/thai-qr-payment/interfaceparsedtruemoneyslipverify/) \| `null` Defined in: payload/dist/slip-verify.d.ts:84 Parse a TrueMoney Slip Verify Mini-QR payload. Returns `null` for any string that doesn't carry the TrueMoney marker pair (sub-tags 00 + 01 both `'01'`) or whose CRC fails to verify. Comparison is case-insensitive; truncated CRCs (1-3 chars) are auto-padded. ## Parameters ### payload `string` ## Returns [`ParsedTrueMoneySlipVerify`](/api/thai-qr-payment/interfaceparsedtruemoneyslipverify/) \| `null` ## Example ```ts parseTrueMoneySlipVerify('00480002010102010203P2P0313TXN00012345670408250120249104b425') // → { eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024' } ``` # payloadFor > **payloadFor**(`input`): `string` Defined in: payload/dist/index.d.ts:34 Shorthand for the common "make me a PromptPay QR for this recipient with this amount" use case. Returns the wire payload string. ## Parameters ### input #### amount? `number` #### fromSatang? `boolean` #### recipient `string` #### type? [`PromptPayRecipientType`](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) ## Returns `string` ## Example ```ts payloadFor({ recipient: '0812345678', amount: 100 }) // → '00020101021229370016A00000067701011101130066812345678530376454...' ``` # renderCard > **renderCard**(`matrix`, `options?`): `string` Defined in: render/dist/card.d.ts:64 Compose the full Thai QR Payment card SVG. ## Parameters ### matrix [`QRMatrix`](/api/thai-qr-payment/interfaceqrmatrix/) ### options? [`CardOptions`](/api/thai-qr-payment/interfacecardoptions/) ## Returns `string` # renderQRSvg > **renderQRSvg**(`matrix`, `options?`): `string` Defined in: render/dist/matrix-svg.d.ts:24 Render a QR matrix to a self-contained `` string. ## Parameters ### matrix [`QRMatrix`](/api/thai-qr-payment/interfaceqrmatrix/) ### options? [`QRSvgOptions`](/api/thai-qr-payment/interfaceqrsvgoptions/) ## Returns `string` # renderThaiQRPayment > **renderThaiQRPayment**(`input`): `string` Defined in: render/dist/index.d.ts:28 One-shot helper: build payload → encode QR → render Thai QR Payment card. Returns the SVG string ready to ship. ## Parameters ### input [`RenderInput`](/api/thai-qr-payment/interfacerenderinput/) & `Omit`\<[`CardOptions`](/api/thai-qr-payment/interfacecardoptions/), `never`\> ## Returns `string` # renderThaiQRPaymentMatrix > **renderThaiQRPaymentMatrix**(`input`): `string` Defined in: render/dist/index.d.ts:33 One-shot helper for callers that want only the QR (no header card). Useful when wrapping the QR in your own design system. ## Parameters ### input [`RenderInput`](/api/thai-qr-payment/interfacerenderinput/) & [`QRSvgOptions`](/api/thai-qr-payment/interfaceqrsvgoptions/) ## Returns `string` # AdditionalDataFields Defined in: payload/dist/builder.d.ts:17 ## Properties ### billNumber? > `optional` **billNumber?**: `string` Defined in: payload/dist/builder.d.ts:18 *** ### consumerDataRequest? > `optional` **consumerDataRequest?**: `string` Defined in: payload/dist/builder.d.ts:26 *** ### customerLabel? > `optional` **customerLabel?**: `string` Defined in: payload/dist/builder.d.ts:23 *** ### loyaltyNumber? > `optional` **loyaltyNumber?**: `string` Defined in: payload/dist/builder.d.ts:21 *** ### mobileNumber? > `optional` **mobileNumber?**: `string` Defined in: payload/dist/builder.d.ts:19 *** ### purposeOfTransaction? > `optional` **purposeOfTransaction?**: `string` Defined in: payload/dist/builder.d.ts:25 *** ### referenceLabel? > `optional` **referenceLabel?**: `string` Defined in: payload/dist/builder.d.ts:22 *** ### storeLabel? > `optional` **storeLabel?**: `string` Defined in: payload/dist/builder.d.ts:20 *** ### terminalLabel? > `optional` **terminalLabel?**: `string` Defined in: payload/dist/builder.d.ts:24 # BOTBarcodeInput Defined in: payload/dist/barcode.d.ts:21 Bank of Thailand 1D barcode (bill-payment, counter-scanned). This is intentionally not part of the EMVCo TLV machinery in the rest of the package. The BOT barcode is a `|`-led, `\r`-delimited ASCII string scanned at bank counters and 7-Eleven cashier stations for over-the-counter bill payments — not a QR, not TLV, no CRC. It shares the cross-bank biller-id concept with EMVCo tag 30 but the wire format is otherwise unrelated, so it lives in its own module to keep the TLV builder + parser tree-shake cleanly when callers only need one or the other. Wire shape: `|\r\r\r` - leading pipe is a fixed sentinel - billerId is 15 chars (Tax ID + suffix), zero-padded if shorter - ref1 is mandatory (customer/invoice number) - ref2 may be the empty string if unused - amount is integer satang (baht × 100), or the literal "0" when the cashier is expected to key the amount in by hand ## Properties ### amount? > `optional` **amount?**: `number` Defined in: payload/dist/barcode.d.ts:32 Baht amount. Omit (or pass `undefined`) for a counter-keyed total — the literal "0" is then written and the cashier types the amount. *** ### billerId > **billerId**: `string` Defined in: payload/dist/barcode.d.ts:23 Cross-bank biller id (Tax ID + suffix). ≤ 15 chars, zero-padded on emit. *** ### ref1 > **ref1**: `string` Defined in: payload/dist/barcode.d.ts:25 Customer / invoice reference. Must be non-empty. *** ### ref2? > `optional` **ref2?**: `string` Defined in: payload/dist/barcode.d.ts:27 Optional secondary reference. Empty string on the wire if omitted. # CardOptions Defined in: render/dist/card.d.ts:38 ## Properties ### accent? > `optional` **accent?**: `string` Defined in: render/dist/card.d.ts:48 Foreground / accent colour for text + silhouette artwork. *** ### amountLabel? > `optional` **amountLabel?**: `string` Defined in: render/dist/card.d.ts:42 Optional amount label rendered below the QR. *** ### background? > `optional` **background?**: `string` Defined in: render/dist/card.d.ts:46 Background colour of the entire card. *** ### centerOverlay? > `optional` **centerOverlay?**: `boolean` Defined in: render/dist/card.d.ts:61 Overlay the Thai QR Payment icon at the centre of the QR matrix. Defaults to `true` for `theme: 'color'`, `false` for `'silhouette'`. Always pair with `encodeQR({ errorCorrectionLevel: 'Q' | 'H' })` so the obscured modules are recoverable. *** ### headerLogo? > `optional` **headerLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: render/dist/card.d.ts:52 Override the Thai QR Payment header logo by registry name. *** ### merchantName? > `optional` **merchantName?**: `string` Defined in: render/dist/card.d.ts:44 Optional merchant name rendered below the QR (above the amount). *** ### promptpayLogo? > `optional` **promptpayLogo?**: `"PromptPay1"` \| `"PromptPay2"` \| `"Thai_QR_Payment_Logo-01"` Defined in: render/dist/card.d.ts:54 Override the PromptPay sub-mark by registry name. *** ### qrColor? > `optional` **qrColor?**: `string` Defined in: render/dist/card.d.ts:50 QR module fill colour. Defaults to `#000000` for max scanner contrast. *** ### theme? > `optional` **theme?**: [`CardTheme`](/api/thai-qr-payment/typealiascardtheme/) Defined in: render/dist/card.d.ts:40 Brand artwork flavor. `color` keeps full fidelity, `silhouette` is monochrome. # EncodeOptions Defined in: qr/dist/encoder.d.ts:14 ## Properties ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: [`ErrorCorrectionLevel`](/api/thai-qr-payment/typealiaserrorcorrectionlevel/) Defined in: qr/dist/encoder.d.ts:15 *** ### forceMask? > `optional` **forceMask?**: `number` Defined in: qr/dist/encoder.d.ts:18 *** ### maxVersion? > `optional` **maxVersion?**: `number` Defined in: qr/dist/encoder.d.ts:17 *** ### minVersion? > `optional` **minVersion?**: `number` Defined in: qr/dist/encoder.d.ts:16 # FormatAmountOptions Defined in: payload/dist/amount.d.ts:9 Amount formatting for tag 54 (Transaction Amount). EMVCo allows up to 13 chars including the decimal point — Thai banks cap the integer part at 10 digits + 2 decimals. We accept either a number (in baht) or a satang-int + flag, and always emit 2 decimals because that's what every Thai banking app re-displays consistently. ## Properties ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: payload/dist/amount.d.ts:11 When true, treat the input as integer satang (1 baht = 100 satang). # MerchantInfo Defined in: payload/dist/builder.d.ts:38 ## Properties ### categoryCode? > `optional` **categoryCode?**: `string` Defined in: payload/dist/builder.d.ts:46 4-digit Merchant Category Code from ISO 18245. *** ### city? > `optional` **city?**: `string` Defined in: payload/dist/builder.d.ts:42 Up to 15 alphanumeric characters. *** ### name? > `optional` **name?**: `string` Defined in: payload/dist/builder.d.ts:40 Up to 25 alphanumeric characters; truncated by the builder. *** ### postalCode? > `optional` **postalCode?**: `string` Defined in: payload/dist/builder.d.ts:44 Up to 10 chars. # NormalisedRecipient Defined in: payload/dist/recipient.d.ts:12 ## Properties ### subTag > `readonly` **subTag**: `"01"` \| `"02"` \| `"03"` \| `"04"` Defined in: payload/dist/recipient.d.ts:13 *** ### type > `readonly` **type**: [`PromptPayRecipientType`](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) Defined in: payload/dist/recipient.d.ts:15 *** ### value > `readonly` **value**: `string` Defined in: payload/dist/recipient.d.ts:14 # ParsedAdditionalData Defined in: payload/dist/parser.d.ts:55 ## Properties ### billNumber? > `optional` **billNumber?**: `string` Defined in: payload/dist/parser.d.ts:56 *** ### consumerDataRequest? > `optional` **consumerDataRequest?**: `string` Defined in: payload/dist/parser.d.ts:64 *** ### customerLabel? > `optional` **customerLabel?**: `string` Defined in: payload/dist/parser.d.ts:61 *** ### loyaltyNumber? > `optional` **loyaltyNumber?**: `string` Defined in: payload/dist/parser.d.ts:59 *** ### mobileNumber? > `optional` **mobileNumber?**: `string` Defined in: payload/dist/parser.d.ts:57 *** ### purposeOfTransaction? > `optional` **purposeOfTransaction?**: `string` Defined in: payload/dist/parser.d.ts:63 *** ### referenceLabel? > `optional` **referenceLabel?**: `string` Defined in: payload/dist/parser.d.ts:60 *** ### storeLabel? > `optional` **storeLabel?**: `string` Defined in: payload/dist/parser.d.ts:58 *** ### terminalLabel? > `optional` **terminalLabel?**: `string` Defined in: payload/dist/parser.d.ts:62 # ParsedBillPayment Defined in: payload/dist/parser.d.ts:36 ## Properties ### billerId > `readonly` **billerId**: `string` Defined in: payload/dist/parser.d.ts:38 *** ### crossBorder > `readonly` **crossBorder**: `boolean` Defined in: payload/dist/parser.d.ts:48 `true` when the merchant template uses the ASEAN cross-border AID (`A000000677012006`). In that mode the `purposeOfTransaction` field (tag 62 sub-tag 08) carries an 18-char triple of currency + local amount + country; the parser surfaces it verbatim under `additionalData.purposeOfTransaction`. *** ### kind > `readonly` **kind**: `"billPayment"` Defined in: payload/dist/parser.d.ts:37 *** ### reference1? > `readonly` `optional` **reference1?**: `string` Defined in: payload/dist/parser.d.ts:39 *** ### reference2? > `readonly` `optional` **reference2?**: `string` Defined in: payload/dist/parser.d.ts:40 # ParsedBOTBarcode Defined in: payload/dist/barcode.d.ts:34 ## Properties ### amount? > `optional` **amount?**: `number` Defined in: payload/dist/barcode.d.ts:38 *** ### billerId > **billerId**: `string` Defined in: payload/dist/barcode.d.ts:35 *** ### ref1 > **ref1**: `string` Defined in: payload/dist/barcode.d.ts:36 *** ### ref2? > `optional` **ref2?**: `string` Defined in: payload/dist/barcode.d.ts:37 # ParsedCRC Defined in: payload/dist/parser.d.ts:73 Bookkeeping for the trailing checksum — useful when reporting auto-fix. ## Properties ### truncated > `readonly` **truncated**: `boolean` Defined in: payload/dist/parser.d.ts:79 True when zero-padding was needed to recover a valid CRC. *** ### valid > `readonly` **valid**: `boolean` Defined in: payload/dist/parser.d.ts:77 True when the wire CRC matches the recomputed value (possibly after padding). *** ### value > `readonly` **value**: `string` Defined in: payload/dist/parser.d.ts:75 The CRC text as it appeared on the wire (may be 1–4 chars). # ParsedPayload Defined in: payload/dist/parser.d.ts:81 ## Properties ### additionalData? > `readonly` `optional` **additionalData?**: [`ParsedAdditionalData`](/api/thai-qr-payment/interfaceparsedadditionaldata/) Defined in: payload/dist/parser.d.ts:92 *** ### amount > `readonly` **amount**: `number` \| `null` Defined in: payload/dist/parser.d.ts:85 *** ### country > `readonly` **country**: `string` Defined in: payload/dist/parser.d.ts:87 *** ### crc > `readonly` **crc**: [`ParsedCRC`](/api/thai-qr-payment/interfaceparsedcrc/) Defined in: payload/dist/parser.d.ts:94 *** ### currency > `readonly` **currency**: `string` Defined in: payload/dist/parser.d.ts:86 *** ### merchant > `readonly` **merchant**: [`ParsedBillPayment`](/api/thai-qr-payment/interfaceparsedbillpayment/) \| [`ParsedPromptPay`](/api/thai-qr-payment/interfaceparsedpromptpay/) \| [`ParsedTrueMoney`](/api/thai-qr-payment/interfaceparsedtruemoney/) \| `null` Defined in: payload/dist/parser.d.ts:84 *** ### merchantCategoryCode? > `readonly` `optional` **merchantCategoryCode?**: `string` Defined in: payload/dist/parser.d.ts:90 *** ### merchantCity? > `readonly` `optional` **merchantCity?**: `string` Defined in: payload/dist/parser.d.ts:89 *** ### merchantName? > `readonly` `optional` **merchantName?**: `string` Defined in: payload/dist/parser.d.ts:88 *** ### payloadFormat > `readonly` **payloadFormat**: `string` Defined in: payload/dist/parser.d.ts:82 *** ### pointOfInitiation > `readonly` **pointOfInitiation**: `"static"` \| `"dynamic"` Defined in: payload/dist/parser.d.ts:83 *** ### postalCode? > `readonly` `optional` **postalCode?**: `string` Defined in: payload/dist/parser.d.ts:91 *** ### rawTags > `readonly` **rawTags**: readonly [`TLVField`](/api/thai-qr-payment/interfacetlvfield/)[] Defined in: payload/dist/parser.d.ts:96 All top-level TLV fields, in wire order. Use for unknown / future tags. *** ### vatTqrc? > `readonly` `optional` **vatTqrc?**: [`ParsedVATTQRC`](/api/thai-qr-payment/interfaceparsedvattqrc/) Defined in: payload/dist/parser.d.ts:93 ## Methods ### getTag() > **getTag**(`id`): [`TLVField`](/api/thai-qr-payment/interfacetlvfield/) \| `undefined` Defined in: payload/dist/parser.d.ts:98 Lookup a top-level TLV field by id. Returns `undefined` if absent. #### Parameters ##### id `string` #### Returns [`TLVField`](/api/thai-qr-payment/interfacetlvfield/) \| `undefined` *** ### getTagValue() > **getTagValue**(`id`, `subId?`): `string` \| `undefined` Defined in: payload/dist/parser.d.ts:104 Lookup a value by id. Pass `subId` to descend one level into a nested template (tags 29–31, 62, 64 are templated). Returns `undefined` if either the parent or the sub-field is missing. #### Parameters ##### id `string` ##### subId? `string` #### Returns `string` \| `undefined` # ParsedPromptPay Defined in: payload/dist/parser.d.ts:20 ## Properties ### accountNo? > `readonly` `optional` **accountNo?**: `string` Defined in: payload/dist/parser.d.ts:32 Account number. Present only when `recipientType === 'bankAccount'`. *** ### bankCode? > `readonly` `optional` **bankCode?**: `string` Defined in: payload/dist/parser.d.ts:30 Bank code (3 digits). Present only when `recipientType === 'bankAccount'`. *** ### kind > `readonly` **kind**: `"promptpay"` Defined in: payload/dist/parser.d.ts:21 *** ### ota? > `readonly` `optional` **ota?**: `string` Defined in: payload/dist/parser.d.ts:34 One-Time Authorization code from sub-tag 05. Present only on OTA payloads. *** ### recipient > `readonly` **recipient**: `string` Defined in: payload/dist/parser.d.ts:28 Wire value for the recipient sub-tag. For `bankAccount` this is the full `bankCode + accountNo` concatenation — split fields are exposed separately below. *** ### recipientType > `readonly` **recipientType**: [`PromptPayRecipientType`](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) Defined in: payload/dist/parser.d.ts:22 # ParsedSlipVerify Defined in: payload/dist/slip-verify.d.ts:24 Decoded payload from `parseSlipVerify`. ## Properties ### sendingBank > `readonly` **sendingBank**: `string` Defined in: payload/dist/slip-verify.d.ts:25 *** ### transRef > `readonly` **transRef**: `string` Defined in: payload/dist/slip-verify.d.ts:26 # ParsedTrueMoney Defined in: payload/dist/parser.d.ts:50 ## Properties ### kind > `readonly` **kind**: `"trueMoney"` Defined in: payload/dist/parser.d.ts:51 *** ### message? > `readonly` `optional` **message?**: `string` Defined in: payload/dist/parser.d.ts:53 *** ### mobileNo > `readonly` **mobileNo**: `string` Defined in: payload/dist/parser.d.ts:52 # ParsedTrueMoneySlipVerify Defined in: payload/dist/slip-verify.d.ts:38 Decoded payload from `parseTrueMoneySlipVerify`. ## Properties ### date > `readonly` **date**: `string` Defined in: payload/dist/slip-verify.d.ts:41 *** ### eventType > `readonly` **eventType**: `string` Defined in: payload/dist/slip-verify.d.ts:39 *** ### transactionId > `readonly` **transactionId**: `string` Defined in: payload/dist/slip-verify.d.ts:40 # ParsedVATTQRC Defined in: payload/dist/parser.d.ts:67 Decoded VAT TQRC template (tag 80). ## Properties ### sellerTaxBranchId > `readonly` **sellerTaxBranchId**: `string` Defined in: payload/dist/parser.d.ts:68 *** ### vatAmount > `readonly` **vatAmount**: `string` Defined in: payload/dist/parser.d.ts:70 *** ### vatRate? > `readonly` `optional` **vatRate?**: `string` Defined in: payload/dist/parser.d.ts:69 # ParsePayloadOptions Defined in: payload/dist/parser.d.ts:106 ## Properties ### strict? > `readonly` `optional` **strict?**: `boolean` Defined in: payload/dist/parser.d.ts:113 When true, throw if the CRC tag is missing or its on-wire value doesn't match the recomputed checksum. Defaults to false for backwards compatibility with callers that need to consume the truncated-CRC auto-fix path. # QRMatrix Defined in: qr/dist/encoder.d.ts:20 ## Properties ### errorCorrectionLevel > `readonly` **errorCorrectionLevel**: [`ErrorCorrectionLevel`](/api/thai-qr-payment/typealiaserrorcorrectionlevel/) Defined in: qr/dist/encoder.d.ts:24 *** ### mask > `readonly` **mask**: `number` Defined in: qr/dist/encoder.d.ts:25 *** ### modules > `readonly` **modules**: `boolean`[][] Defined in: qr/dist/encoder.d.ts:22 *** ### size > `readonly` **size**: `number` Defined in: qr/dist/encoder.d.ts:21 *** ### version > `readonly` **version**: `number` Defined in: qr/dist/encoder.d.ts:23 # QRSvgOptions Defined in: render/dist/matrix-svg.d.ts:11 ## Properties ### background? > `optional` **background?**: `string` Defined in: render/dist/matrix-svg.d.ts:19 Background colour (set to `transparent` to omit). Defaults to `#fff`. *** ### foreground? > `optional` **foreground?**: `string` Defined in: render/dist/matrix-svg.d.ts:17 Dark module colour. Defaults to `#000`. *** ### quietZone? > `optional` **quietZone?**: `number` Defined in: render/dist/matrix-svg.d.ts:15 Quiet-zone width in modules. EMVCo recommends 4. *** ### rootAttributes? > `optional` **rootAttributes?**: `Record`\<`string`, `string`\> Defined in: render/dist/matrix-svg.d.ts:21 Additional attributes added verbatim to the root `` element. *** ### size? > `optional` **size?**: `number` Defined in: render/dist/matrix-svg.d.ts:13 Output width in user units (px by default). Defaults to module count. # RenderInput Defined in: render/dist/index.d.ts:16 ## Properties ### amount? > `optional` **amount?**: `number` Defined in: render/dist/index.d.ts:18 *** ### errorCorrectionLevel? > `optional` **errorCorrectionLevel?**: [`ErrorCorrectionLevel`](/api/thai-qr-payment/typealiaserrorcorrectionlevel/) Defined in: render/dist/index.d.ts:22 QR error-correction level. `H` gives the best margin for logo overlays. *** ### fromSatang? > `optional` **fromSatang?**: `boolean` Defined in: render/dist/index.d.ts:20 *** ### recipient > **recipient**: `string` Defined in: render/dist/index.d.ts:17 *** ### recipientType? > `optional` **recipientType?**: [`PromptPayRecipientType`](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) Defined in: render/dist/index.d.ts:19 # SlipVerifyInput Defined in: payload/dist/slip-verify.d.ts:17 Input for `buildSlipVerify`. ## Properties ### sendingBank > `readonly` **sendingBank**: `string` Defined in: payload/dist/slip-verify.d.ts:19 Bank code that issued the slip (e.g. `'002'` for Bangkok Bank). *** ### transRef > `readonly` **transRef**: `string` Defined in: payload/dist/slip-verify.d.ts:21 Transaction reference printed on the slip. # TLVField Defined in: payload/dist/tlv.d.ts:10 A parsed TLV field with its (possibly-nested) value text. ## Properties ### tag > `readonly` **tag**: `string` Defined in: payload/dist/tlv.d.ts:11 *** ### value > `readonly` **value**: `string` Defined in: payload/dist/tlv.d.ts:12 # TrueMoneySlipVerifyInput Defined in: payload/dist/slip-verify.d.ts:29 Input for `buildTrueMoneySlipVerify`. ## Properties ### date > `readonly` **date**: `string` Defined in: payload/dist/slip-verify.d.ts:35 Transfer date as a `DDMMYYYY` 8-character string. *** ### eventType > `readonly` **eventType**: `string` Defined in: payload/dist/slip-verify.d.ts:31 Event classification (e.g. `'P2P'`). *** ### transactionId > `readonly` **transactionId**: `string` Defined in: payload/dist/slip-verify.d.ts:33 Wallet transaction identifier. # VATTQRCInput Defined in: payload/dist/builder.d.ts:48 ## Properties ### sellerTaxBranchId > **sellerTaxBranchId**: `string` Defined in: payload/dist/builder.d.ts:50 Seller's tax branch identifier — exactly 4 characters. *** ### vatAmount > **vatAmount**: `string` Defined in: payload/dist/builder.d.ts:54 VAT amount as displayed on the receipt; 1–13 chars, required. *** ### vatRate? > `optional` **vatRate?**: `string` Defined in: payload/dist/builder.d.ts:52 VAT rate as displayed on the receipt (e.g. "7" or "7.00"); 1–5 chars. # Tags ## Variables - [COUNTRY\_TH](/api/thai-qr-payment/tagsvariablecountry_th/) - [CURRENCY\_THB](/api/thai-qr-payment/tagsvariablecurrency_thb/) - [GUID\_BILL\_PAYMENT](/api/thai-qr-payment/tagsvariableguid_bill_payment/) - [GUID\_BILL\_PAYMENT\_CROSS\_BORDER](/api/thai-qr-payment/tagsvariableguid_bill_payment_cross_border/) - [GUID\_PROMPTPAY](/api/thai-qr-payment/tagsvariableguid_promptpay/) - [GUID\_PROMPTPAY\_OTA](/api/thai-qr-payment/tagsvariableguid_promptpay_ota/) - [PAYLOAD\_FORMAT\_VERSION](/api/thai-qr-payment/tagsvariablepayload_format_version/) - [POI\_DYNAMIC](/api/thai-qr-payment/tagsvariablepoi_dynamic/) - [POI\_STATIC](/api/thai-qr-payment/tagsvariablepoi_static/) - [SUB\_ADD\_BILL\_NUMBER](/api/thai-qr-payment/tagsvariablesub_add_bill_number/) - [SUB\_ADD\_CONSUMER\_DATA\_REQUEST](/api/thai-qr-payment/tagsvariablesub_add_consumer_data_request/) - [SUB\_ADD\_CUSTOMER\_LABEL](/api/thai-qr-payment/tagsvariablesub_add_customer_label/) - [SUB\_ADD\_LOYALTY\_NUMBER](/api/thai-qr-payment/tagsvariablesub_add_loyalty_number/) - [SUB\_ADD\_MOBILE\_NUMBER](/api/thai-qr-payment/tagsvariablesub_add_mobile_number/) - [SUB\_ADD\_PURPOSE\_OF\_TRANSACTION](/api/thai-qr-payment/tagsvariablesub_add_purpose_of_transaction/) - [SUB\_ADD\_REFERENCE\_LABEL](/api/thai-qr-payment/tagsvariablesub_add_reference_label/) - [SUB\_ADD\_STORE\_LABEL](/api/thai-qr-payment/tagsvariablesub_add_store_label/) - [SUB\_ADD\_TERMINAL\_LABEL](/api/thai-qr-payment/tagsvariablesub_add_terminal_label/) - [SUB\_BILL\_BILLER\_ID](/api/thai-qr-payment/tagsvariablesub_bill_biller_id/) - [SUB\_BILL\_REFERENCE\_1](/api/thai-qr-payment/tagsvariablesub_bill_reference_1/) - [SUB\_BILL\_REFERENCE\_2](/api/thai-qr-payment/tagsvariablesub_bill_reference_2/) - [SUB\_GUID](/api/thai-qr-payment/tagsvariablesub_guid/) - [SUB\_PROMPTPAY\_BANK\_ACCOUNT](/api/thai-qr-payment/tagsvariablesub_promptpay_bank_account/) - [SUB\_PROMPTPAY\_EWALLET](/api/thai-qr-payment/tagsvariablesub_promptpay_ewallet/) - [SUB\_PROMPTPAY\_MOBILE](/api/thai-qr-payment/tagsvariablesub_promptpay_mobile/) - [SUB\_PROMPTPAY\_NATIONAL\_ID](/api/thai-qr-payment/tagsvariablesub_promptpay_national_id/) - [SUB\_PROMPTPAY\_OTA](/api/thai-qr-payment/tagsvariablesub_promptpay_ota/) - [SUB\_TRUE\_MONEY](/api/thai-qr-payment/tagsvariablesub_true_money/) - [SUB\_VAT\_AMOUNT](/api/thai-qr-payment/tagsvariablesub_vat_amount/) - [SUB\_VAT\_RATE](/api/thai-qr-payment/tagsvariablesub_vat_rate/) - [SUB\_VAT\_SELLER\_TAX\_BRANCH\_ID](/api/thai-qr-payment/tagsvariablesub_vat_seller_tax_branch_id/) - [TAG\_ADDITIONAL\_DATA](/api/thai-qr-payment/tagsvariabletag_additional_data/) - [TAG\_CHECKSUM](/api/thai-qr-payment/tagsvariabletag_checksum/) - [TAG\_COUNTRY\_CODE](/api/thai-qr-payment/tagsvariabletag_country_code/) - [TAG\_LANGUAGE\_TEMPLATE](/api/thai-qr-payment/tagsvariabletag_language_template/) - [TAG\_MERCHANT\_ACCOUNT\_BILL\_PAYMENT](/api/thai-qr-payment/tagsvariabletag_merchant_account_bill_payment/) - [TAG\_MERCHANT\_ACCOUNT\_KSHOP](/api/thai-qr-payment/tagsvariabletag_merchant_account_kshop/) - [TAG\_MERCHANT\_ACCOUNT\_PROMPTPAY](/api/thai-qr-payment/tagsvariabletag_merchant_account_promptpay/) - [TAG\_MERCHANT\_CATEGORY\_CODE](/api/thai-qr-payment/tagsvariabletag_merchant_category_code/) - [TAG\_MERCHANT\_CITY](/api/thai-qr-payment/tagsvariabletag_merchant_city/) - [TAG\_MERCHANT\_NAME](/api/thai-qr-payment/tagsvariabletag_merchant_name/) - [TAG\_PAYLOAD\_FORMAT](/api/thai-qr-payment/tagsvariabletag_payload_format/) - [TAG\_PERSONAL\_MESSAGE](/api/thai-qr-payment/tagsvariabletag_personal_message/) - [TAG\_POINT\_OF\_INITIATION](/api/thai-qr-payment/tagsvariabletag_point_of_initiation/) - [TAG\_POSTAL\_CODE](/api/thai-qr-payment/tagsvariabletag_postal_code/) - [TAG\_TIP\_FIXED](/api/thai-qr-payment/tagsvariabletag_tip_fixed/) - [TAG\_TIP\_OR\_CONVENIENCE\_INDICATOR](/api/thai-qr-payment/tagsvariabletag_tip_or_convenience_indicator/) - [TAG\_TIP\_PERCENTAGE](/api/thai-qr-payment/tagsvariabletag_tip_percentage/) - [TAG\_TRANSACTION\_AMOUNT](/api/thai-qr-payment/tagsvariabletag_transaction_amount/) - [TAG\_TRANSACTION\_CURRENCY](/api/thai-qr-payment/tagsvariabletag_transaction_currency/) - [TAG\_VAT\_TQRC](/api/thai-qr-payment/tagsvariabletag_vat_tqrc/) - [TIP\_FIXED](/api/thai-qr-payment/tagsvariabletip_fixed/) - [TIP\_PERCENTAGE](/api/thai-qr-payment/tagsvariabletip_percentage/) - [TIP\_PROMPT](/api/thai-qr-payment/tagsvariabletip_prompt/) - [TRUE\_MONEY\_PREFIX](/api/thai-qr-payment/tagsvariabletrue_money_prefix/) # thai-qr-payment ## Namespaces - [Tags](/api/thai-qr-payment/namespacetags/) ## Classes - [ThaiQRPaymentBuilder](/api/thai-qr-payment/classthaiqrpaymentbuilder/) ## Interfaces - [AdditionalDataFields](/api/thai-qr-payment/interfaceadditionaldatafields/) - [BOTBarcodeInput](/api/thai-qr-payment/interfacebotbarcodeinput/) - [CardOptions](/api/thai-qr-payment/interfacecardoptions/) - [EncodeOptions](/api/thai-qr-payment/interfaceencodeoptions/) - [FormatAmountOptions](/api/thai-qr-payment/interfaceformatamountoptions/) - [MerchantInfo](/api/thai-qr-payment/interfacemerchantinfo/) - [NormalisedRecipient](/api/thai-qr-payment/interfacenormalisedrecipient/) - [ParsedAdditionalData](/api/thai-qr-payment/interfaceparsedadditionaldata/) - [ParsedBillPayment](/api/thai-qr-payment/interfaceparsedbillpayment/) - [ParsedBOTBarcode](/api/thai-qr-payment/interfaceparsedbotbarcode/) - [ParsedCRC](/api/thai-qr-payment/interfaceparsedcrc/) - [ParsedPayload](/api/thai-qr-payment/interfaceparsedpayload/) - [ParsedPromptPay](/api/thai-qr-payment/interfaceparsedpromptpay/) - [ParsedSlipVerify](/api/thai-qr-payment/interfaceparsedslipverify/) - [ParsedTrueMoney](/api/thai-qr-payment/interfaceparsedtruemoney/) - [ParsedTrueMoneySlipVerify](/api/thai-qr-payment/interfaceparsedtruemoneyslipverify/) - [ParsedVATTQRC](/api/thai-qr-payment/interfaceparsedvattqrc/) - [ParsePayloadOptions](/api/thai-qr-payment/interfaceparsepayloadoptions/) - [QRMatrix](/api/thai-qr-payment/interfaceqrmatrix/) - [QRSvgOptions](/api/thai-qr-payment/interfaceqrsvgoptions/) - [RenderInput](/api/thai-qr-payment/interfacerenderinput/) - [SlipVerifyInput](/api/thai-qr-payment/interfaceslipverifyinput/) - [TLVField](/api/thai-qr-payment/interfacetlvfield/) - [TrueMoneySlipVerifyInput](/api/thai-qr-payment/interfacetruemoneyslipverifyinput/) - [VATTQRCInput](/api/thai-qr-payment/interfacevattqrcinput/) ## Type Aliases - [CardTheme](/api/thai-qr-payment/typealiascardtheme/) - [EncodingMode](/api/thai-qr-payment/typealiasencodingmode/) - [ErrorCorrectionLevel](/api/thai-qr-payment/typealiaserrorcorrectionlevel/) - [PromptPayRecipientType](/api/thai-qr-payment/typealiaspromptpayrecipienttype/) - [TipMode](/api/thai-qr-payment/typealiastipmode/) ## Functions - [buildBOTBarcode](/api/thai-qr-payment/functionbuildbotbarcode/) - [buildSlipVerify](/api/thai-qr-payment/functionbuildslipverify/) - [buildTrueMoneySlipVerify](/api/thai-qr-payment/functionbuildtruemoneyslipverify/) - [checksum](/api/thai-qr-payment/functionchecksum/) - [decodePersonalMessage](/api/thai-qr-payment/functiondecodepersonalmessage/) - [detectMode](/api/thai-qr-payment/functiondetectmode/) - [encodeField](/api/thai-qr-payment/functionencodefield/) - [encodeFields](/api/thai-qr-payment/functionencodefields/) - [encodePersonalMessage](/api/thai-qr-payment/functionencodepersonalmessage/) - [encodeQR](/api/thai-qr-payment/functionencodeqr/) - [formatAmount](/api/thai-qr-payment/functionformatamount/) - [iterateFields](/api/thai-qr-payment/functioniteratefields/) - [matrixToPath](/api/thai-qr-payment/functionmatrixtopath/) - [normaliseBankAccount](/api/thai-qr-payment/functionnormalisebankaccount/) - [normaliseRecipient](/api/thai-qr-payment/functionnormaliserecipient/) - [parseBOTBarcode](/api/thai-qr-payment/functionparsebotbarcode/) - [parseFields](/api/thai-qr-payment/functionparsefields/) - [parsePayload](/api/thai-qr-payment/functionparsepayload/) - [parseSlipVerify](/api/thai-qr-payment/functionparseslipverify/) - [parseTrueMoneySlipVerify](/api/thai-qr-payment/functionparsetruemoneyslipverify/) - [payloadFor](/api/thai-qr-payment/functionpayloadfor/) - [renderCard](/api/thai-qr-payment/functionrendercard/) - [renderQRSvg](/api/thai-qr-payment/functionrenderqrsvg/) - [renderThaiQRPayment](/api/thai-qr-payment/functionrenderthaiqrpayment/) - [renderThaiQRPaymentMatrix](/api/thai-qr-payment/functionrenderthaiqrpaymentmatrix/) # COUNTRY_TH > `const` **COUNTRY\_TH**: `"TH"` = `"TH"` Defined in: payload/dist/tags.d.ts:53 # CURRENCY_THB > `const` **CURRENCY\_THB**: `"764"` = `"764"` Defined in: payload/dist/tags.d.ts:52 # GUID_BILL_PAYMENT > `const` **GUID\_BILL\_PAYMENT**: `"A000000677010112"` = `"A000000677010112"` Defined in: payload/dist/tags.d.ts:55 # GUID_BILL_PAYMENT_CROSS_BORDER > `const` **GUID\_BILL\_PAYMENT\_CROSS\_BORDER**: `"A000000677012006"` = `"A000000677012006"` Defined in: payload/dist/tags.d.ts:57 # GUID_PROMPTPAY > `const` **GUID\_PROMPTPAY**: `"A000000677010111"` = `"A000000677010111"` Defined in: payload/dist/tags.d.ts:54 # GUID_PROMPTPAY_OTA > `const` **GUID\_PROMPTPAY\_OTA**: `"A000000677010114"` = `"A000000677010114"` Defined in: payload/dist/tags.d.ts:56 # PAYLOAD_FORMAT_VERSION > `const` **PAYLOAD\_FORMAT\_VERSION**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:49 # POI_DYNAMIC > `const` **POI\_DYNAMIC**: `"12"` = `"12"` Defined in: payload/dist/tags.d.ts:51 # POI_STATIC > `const` **POI\_STATIC**: `"11"` = `"11"` Defined in: payload/dist/tags.d.ts:50 # SUB_ADD_BILL_NUMBER > `const` **SUB\_ADD\_BILL\_NUMBER**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:40 # SUB_ADD_CONSUMER_DATA_REQUEST > `const` **SUB\_ADD\_CONSUMER\_DATA\_REQUEST**: `"09"` = `"09"` Defined in: payload/dist/tags.d.ts:48 # SUB_ADD_CUSTOMER_LABEL > `const` **SUB\_ADD\_CUSTOMER\_LABEL**: `"06"` = `"06"` Defined in: payload/dist/tags.d.ts:45 # SUB_ADD_LOYALTY_NUMBER > `const` **SUB\_ADD\_LOYALTY\_NUMBER**: `"04"` = `"04"` Defined in: payload/dist/tags.d.ts:43 # SUB_ADD_MOBILE_NUMBER > `const` **SUB\_ADD\_MOBILE\_NUMBER**: `"02"` = `"02"` Defined in: payload/dist/tags.d.ts:41 # SUB_ADD_PURPOSE_OF_TRANSACTION > `const` **SUB\_ADD\_PURPOSE\_OF\_TRANSACTION**: `"08"` = `"08"` Defined in: payload/dist/tags.d.ts:47 # SUB_ADD_REFERENCE_LABEL > `const` **SUB\_ADD\_REFERENCE\_LABEL**: `"05"` = `"05"` Defined in: payload/dist/tags.d.ts:44 # SUB_ADD_STORE_LABEL > `const` **SUB\_ADD\_STORE\_LABEL**: `"03"` = `"03"` Defined in: payload/dist/tags.d.ts:42 # SUB_ADD_TERMINAL_LABEL > `const` **SUB\_ADD\_TERMINAL\_LABEL**: `"07"` = `"07"` Defined in: payload/dist/tags.d.ts:46 # SUB_BILL_BILLER_ID > `const` **SUB\_BILL\_BILLER\_ID**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:37 # SUB_BILL_REFERENCE_1 > `const` **SUB\_BILL\_REFERENCE\_1**: `"02"` = `"02"` Defined in: payload/dist/tags.d.ts:38 # SUB_BILL_REFERENCE_2 > `const` **SUB\_BILL\_REFERENCE\_2**: `"03"` = `"03"` Defined in: payload/dist/tags.d.ts:39 # SUB_GUID > `const` **SUB\_GUID**: `"00"` = `"00"` Defined in: payload/dist/tags.d.ts:29 # SUB_PROMPTPAY_BANK_ACCOUNT > `const` **SUB\_PROMPTPAY\_BANK\_ACCOUNT**: `"04"` = `"04"` Defined in: payload/dist/tags.d.ts:33 # SUB_PROMPTPAY_EWALLET > `const` **SUB\_PROMPTPAY\_EWALLET**: `"03"` = `"03"` Defined in: payload/dist/tags.d.ts:32 # SUB_PROMPTPAY_MOBILE > `const` **SUB\_PROMPTPAY\_MOBILE**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:30 # SUB_PROMPTPAY_NATIONAL_ID > `const` **SUB\_PROMPTPAY\_NATIONAL\_ID**: `"02"` = `"02"` Defined in: payload/dist/tags.d.ts:31 # SUB_PROMPTPAY_OTA > `const` **SUB\_PROMPTPAY\_OTA**: `"05"` = `"05"` Defined in: payload/dist/tags.d.ts:34 # SUB_TRUE_MONEY > `const` **SUB\_TRUE\_MONEY**: `"03"` = `"03"` Defined in: payload/dist/tags.d.ts:35 # SUB_VAT_AMOUNT > `const` **SUB\_VAT\_AMOUNT**: `"02"` = `"02"` Defined in: payload/dist/tags.d.ts:64 # SUB_VAT_RATE > `const` **SUB\_VAT\_RATE**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:63 # SUB_VAT_SELLER_TAX_BRANCH_ID > `const` **SUB\_VAT\_SELLER\_TAX\_BRANCH\_ID**: `"00"` = `"00"` Defined in: payload/dist/tags.d.ts:62 # TAG_ADDITIONAL_DATA > `const` **TAG\_ADDITIONAL\_DATA**: `"62"` = `"62"` Defined in: payload/dist/tags.d.ts:25 # TAG_CHECKSUM > `const` **TAG\_CHECKSUM**: `"63"` = `"63"` Defined in: payload/dist/tags.d.ts:26 # TAG_COUNTRY_CODE > `const` **TAG\_COUNTRY\_CODE**: `"58"` = `"58"` Defined in: payload/dist/tags.d.ts:21 # TAG_LANGUAGE_TEMPLATE > `const` **TAG\_LANGUAGE\_TEMPLATE**: `"64"` = `"64"` Defined in: payload/dist/tags.d.ts:27 # TAG_MERCHANT_ACCOUNT_BILL_PAYMENT > `const` **TAG\_MERCHANT\_ACCOUNT\_BILL\_PAYMENT**: `"30"` = `"30"` Defined in: payload/dist/tags.d.ts:13 # TAG_MERCHANT_ACCOUNT_KSHOP > `const` **TAG\_MERCHANT\_ACCOUNT\_KSHOP**: `"31"` = `"31"` Defined in: payload/dist/tags.d.ts:14 # TAG_MERCHANT_ACCOUNT_PROMPTPAY > `const` **TAG\_MERCHANT\_ACCOUNT\_PROMPTPAY**: `"29"` = `"29"` Defined in: payload/dist/tags.d.ts:12 # TAG_MERCHANT_CATEGORY_CODE > `const` **TAG\_MERCHANT\_CATEGORY\_CODE**: `"52"` = `"52"` Defined in: payload/dist/tags.d.ts:15 # TAG_MERCHANT_CITY > `const` **TAG\_MERCHANT\_CITY**: `"60"` = `"60"` Defined in: payload/dist/tags.d.ts:23 # TAG_MERCHANT_NAME > `const` **TAG\_MERCHANT\_NAME**: `"59"` = `"59"` Defined in: payload/dist/tags.d.ts:22 # TAG_PAYLOAD_FORMAT > `const` **TAG\_PAYLOAD\_FORMAT**: `"00"` = `"00"` Defined in: payload/dist/tags.d.ts:10 EMVCo Merchant-Presented-Mode QR Code Specification — tag registry. Source: EMVCo MPM v1.1 §3 — public spec; Bank of Thailand and KASIKORN adopt the same numbering with Thai-specific GUIDs under templates 29-31. Tags are stringly-typed (two-character zero-padded decimal) on the wire but exposed here as named constants so call sites stay readable. # TAG_PERSONAL_MESSAGE > `const` **TAG\_PERSONAL\_MESSAGE**: `"81"` = `"81"` Defined in: payload/dist/tags.d.ts:28 # TAG_POINT_OF_INITIATION > `const` **TAG\_POINT\_OF\_INITIATION**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:11 # TAG_POSTAL_CODE > `const` **TAG\_POSTAL\_CODE**: `"61"` = `"61"` Defined in: payload/dist/tags.d.ts:24 # TAG_TIP_FIXED > `const` **TAG\_TIP\_FIXED**: `"56"` = `"56"` Defined in: payload/dist/tags.d.ts:19 # TAG_TIP_OR_CONVENIENCE_INDICATOR > `const` **TAG\_TIP\_OR\_CONVENIENCE\_INDICATOR**: `"55"` = `"55"` Defined in: payload/dist/tags.d.ts:18 # TAG_TIP_PERCENTAGE > `const` **TAG\_TIP\_PERCENTAGE**: `"57"` = `"57"` Defined in: payload/dist/tags.d.ts:20 # TAG_TRANSACTION_AMOUNT > `const` **TAG\_TRANSACTION\_AMOUNT**: `"54"` = `"54"` Defined in: payload/dist/tags.d.ts:17 # TAG_TRANSACTION_CURRENCY > `const` **TAG\_TRANSACTION\_CURRENCY**: `"53"` = `"53"` Defined in: payload/dist/tags.d.ts:16 # TAG_VAT_TQRC > `const` **TAG\_VAT\_TQRC**: `"80"` = `"80"` Defined in: payload/dist/tags.d.ts:61 # TIP_FIXED > `const` **TIP\_FIXED**: `"02"` = `"02"` Defined in: payload/dist/tags.d.ts:59 # TIP_PERCENTAGE > `const` **TIP\_PERCENTAGE**: `"03"` = `"03"` Defined in: payload/dist/tags.d.ts:60 # TIP_PROMPT > `const` **TIP\_PROMPT**: `"01"` = `"01"` Defined in: payload/dist/tags.d.ts:58 # TRUE_MONEY_PREFIX > `const` **TRUE\_MONEY\_PREFIX**: `"14"` = `"14"` Defined in: payload/dist/tags.d.ts:36 # CardTheme > **CardTheme** = `"color"` \| `"silhouette"` Defined in: render/dist/card.d.ts:37 # EncodingMode > **EncodingMode** = `"numeric"` \| `"alphanumeric"` \| `"byte"` Defined in: qr/dist/mode.d.ts:13 # ErrorCorrectionLevel > **ErrorCorrectionLevel** = `"L"` \| `"M"` \| `"Q"` \| `"H"` Defined in: qr/dist/version.d.ts:12 Capacity tables + version metadata from ISO/IEC 18004 §6.5 and Annex D. Each version 1-40 has 4 ECC levels (L, M, Q, H). For each (version, ECC) the spec defines: - Total data codewords (`dataCodewords`) - Number of error-correction blocks (groups) - Block sizes within each group The matrix dimension is `(version - 1) * 4 + 21`. # PromptPayRecipientType > **PromptPayRecipientType** = `"mobile"` \| `"nationalId"` \| `"eWallet"` \| `"bankAccount"` Defined in: payload/dist/recipient.d.ts:11 # TipMode > **TipMode** = \{ `mode`: `"prompt"`; \} \| \{ `fromSatang?`: `boolean`; `mode`: `"fixed"`; `value`: `number`; \} \| \{ `mode`: `"percentage"`; `value`: `number`; \} Defined in: payload/dist/builder.d.ts:28 # Live demo > Every wire format, every option — playground for the full public API. Runs in your browser. import { QrDemo } from '../../components/QrDemo.tsx'; The demo below imports `thai-qr-payment` straight from this site's bundle and renders the SVG on every keystroke. Drop a PromptPay phone number into the form, set an amount, and **scan with your banking app**. ## What just happened 1. `payloadFor()` built the EMVCo MPM wire string from your inputs 2. `parsePayload()` round-tripped it to verify the CRC + decode the merchant template 3. `encodeQR()` ran ISO/IEC 18004 Reed-Solomon ECC + mask selection 4. `renderThaiQRPayment()` composed the final SVG (card mode) or `renderThaiQRPaymentMatrix()` emitted just the QR matrix Every step ran client-side. No network call, no server. Same code-path a production app takes. ## Known limitations of the demo - The dummy phone `0812345678` is not a real PromptPay account — your banking app will scan it correctly but reject the recipient at the "confirm" step. - The card mode embeds the Thai QR Payment + PromptPay marks. Production apps must comply with the [official brand guidelines](https://www.bot.or.th/) when using these logos. # Brand assets > Thai QR Payment + PromptPay SVG marks in color + silhouette flavors. ![Thai QR Payment color logo](/img/brand/logo-color.svg) `@thai-qr-payment/assets` ships true vector SVGs for the canonical Thai QR Payment and PromptPay marks. Traced via [vtracer](https://github.com/visioncortex/vtracer) (color) and [potrace](http://potrace.sourceforge.net/) (silhouette), then SVGO-optimized. ![PromptPay color logo](/img/brand/promptpay1.svg) ## Available marks | Name | Color | Silhouette | | ------------------------- | ----- | ---------- | | `Thai_QR_Payment_Logo-01` | ✓ | ✓ | | `PromptPay1` | ✓ | ✓ | Only the canonical layouts ship to keep the bundle small (~5 KB brotli). Alternative orientations (`-02` through `-06`, `PromptPay2`) were dropped in commit `bdadef3`. Need a different layout? Re-trace via `scripts/build-assets.sh` and drop the result into `packages/assets/src/svg/`. ## Usage ```ts import { colorLogo, silhouetteLogo, COLOR_LOGOS, SILHOUETTE_LOGOS } from 'thai-qr-payment/assets'; // As a string (e.g. innerHTML, HTTP response) const svg = colorLogo('Thai_QR_Payment_Logo-01'); // In React
// In a Cloudflare Worker return new Response(svg, { headers: { 'content-type': 'image/svg+xml; charset=utf-8' }, }); ``` ## Why assets are opt-in from the umbrella `import { ... } from 'thai-qr-payment'` (the default umbrella entry) does **not** include the brand SVGs — that keeps the surface lean (~3 KB for payload-only callers). The renderer helpers (`renderThaiQRPayment`, `renderCard`) still reach for the assets internally; they're only excluded from the top-level re-export. To get the asset map at the top level: ```ts import { COLOR_LOGOS, colorLogo } from 'thai-qr-payment/assets'; ``` ## Brand compliance The marks belong to their respective rights-holders: - **Thai QR Payment** logo — Bank of Thailand / Thai Bankers' Association - **PromptPay** logo — Bank of Thailand / National ITMX This package redistributes the raster → vector conversion of publicly distributed artwork. **Downstream apps must comply with the official Thai QR Payment Brand Guidelines.** If a rights-holder requests removal, open a [GitHub issue](https://github.com/uunw/thai-qr-payment/issues) and the mark will be pulled from the next published version within 7 days. # BOT barcode > Build + parse the Bank of Thailand 1D bill-payment barcode. ## Why The **Bank of Thailand 1D bill-payment barcode** is the one-dimensional ASCII string printed on Thai utility bills, scanned at bank tellers, 7-Eleven counters, and kiosk machines for over-the-counter bill payments. It is **not** EMVCo, **not** a QR, **not** TLV — the wire format is a `|`-led `\r`-delimited string with no checksum. It lives in the same `@thai-qr-payment/payload` package because the `billerId` / `ref1` / `ref2` vocabulary matches the Thai bill-payment merchant template (EMVCo tag 30), but the on-wire bytes are unrelated. The module sits behind its own export so callers who only need the QR path can tree-shake it away. ```ts import { buildBOTBarcode, parseBOTBarcode } from 'thai-qr-payment'; ``` ## Build `buildBOTBarcode({ billerId, ref1, ref2?, amount? })`. `billerId` is the 15-char cross-bank biller id (Tax ID + suffix); shorter inputs are zero-padded on the left, longer ones throw. `ref1` is required; `ref2` defaults to the empty string on the wire when omitted. ```ts buildBOTBarcode({ billerId: '099400016550100', ref1: '123456789012', ref2: '670429', amount: 3649.22, }); // '|099400016550100\r123456789012\r670429\r364922' ``` The trailing amount is stored as **integer satang** (baht × 100, rounded). Omit it (or pass `0`) for a counter-keyed total — the literal `'0'` sentinel is written and the cashier types the amount in by hand: ```ts buildBOTBarcode({ billerId: '099999999999990', ref1: '111222333444' }); // '|099999999999990\r111222333444\r\r0' ``` Throws on malformed input — negative / non-finite amounts, over-long biller ids, CR characters inside any field, empty `ref1`. The caller never silently produces an unscannable barcode. ## Parse `parseBOTBarcode(barcode)` returns the decoded fields, or `null` on any structural issue (missing prefix, wrong field count, biller id too short). Amount comes back as a decimal baht number; the `'0'` sentinel surfaces as `undefined`. ```ts parseBOTBarcode('|099400016550100\r123456789012\r670429\r364922'); // { // billerId: '099400016550100', // ref1: '123456789012', // ref2: '670429', // amount: 3649.22, // } parseBOTBarcode('|099999999999990\r111222333444\r\r0'); // { billerId: '099999999999990', ref1: '111222333444' } ``` `null` instead of an exception lets you branch without `try / catch` — useful when consuming arbitrary scanner input that may or may not be a BOT barcode. ## Sample wires | Wire (escaped) | Decoded | | ------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `\|099999999999990\r111222333444\r\r0` | `{ billerId: '099999999999990', ref1: '111222333444' }` | | `\|099400016550100\r123456789012\r670429\r364922` | `{ billerId: '099400016550100', ref1: '123456789012', ref2: '670429', amount: 3649.22 }` | Wire bytes: `\|` is a literal pipe (0x7C, the sentinel); each `\r` is a single carriage return (0x0D); no terminator at the end. The string is always exactly one pipe + three `\r` separators regardless of which optional fields are populated — empty slots are zero-width on the wire. # CLI > thai-qr-payment / tqp command-line tool for one-off QR generation. ![Sample CLI output card](/img/samples/qr-card-hero.svg) ```bash # Zero-install — npx (umbrella package, single tarball) npx thai-qr-payment 0812345678 --amount 50 -o qr.svg npx tqp 0812345678 --amount 50 -o qr.svg # Global install pnpm add -g thai-qr-payment thai-qr-payment 0812345678 --amount 50 --merchant "Acme Coffee" -o qr.svg tqp 0812345678 --format payload ``` ### npx + scoped CLI package `@thai-qr-payment/cli` exposes the same two binaries (`thai-qr-payment` and `tqp`), but the **binary names don't match the package name**. npx can't auto-resolve `@thai-qr-payment/cli` to a binary called `thai-qr-payment`, so `npx @thai-qr-payment/cli 0812345678` fails with `command not found`. Pass the binary name explicitly via `--package`: ```bash # Wrong — npx looks for a `@thai-qr-payment/cli` binary, finds none npx @thai-qr-payment/cli 0812345678 --amount 50 # → sh: thai-qr-payment: command not found # Right — use the umbrella (recommended, single tarball) npx thai-qr-payment 0812345678 --amount 50 # Right — scoped CLI with --package npx --package=@thai-qr-payment/cli thai-qr-payment 0812345678 --amount 50 npx --package=@thai-qr-payment/cli tqp 0812345678 --amount 50 ``` The umbrella is preferred (one tarball, all deps inlined). Reach for the scoped CLI only if you're pinning specific package versions in an automation script. ## Modes ### Card (default) ```bash thai-qr-payment 0812345678 --amount 50 --merchant "Acme Coffee" -o qr.svg ``` Full SVG card with Thai QR Payment + PromptPay headers, merchant name, and amount label. ### Matrix ```bash thai-qr-payment 0812345678 --amount 50 --format matrix --size 512 -o qr.svg ``` Just the QR matrix as a square SVG. Caller-controlled size. ### Payload ```bash thai-qr-payment 0812345678 --amount 50 --format payload # 00020101021229370016A00000067701011101130066812345678530376454065000.005802TH63041234 ``` Raw EMVCo wire string. Useful for piping into another tool. ## Flags | Flag | Short | Notes | | ------------------- | ----- | ----------------------------------------------------------- | | `--recipient ` | `-r` | phone, nationalId, eWallet | | `--amount ` | `-a` | omit for static QR | | `--satang` | — | treat `--amount` as integer satang | | `--type ` | — | `mobile` / `nationalId` / `eWallet` — overrides auto-detect | | `--ecc ` | — | `L` / `M` / `Q` / `H` (default `M`) | | `--format ` | `-f` | `card` (default) / `matrix` / `payload` | | `--theme ` | — | `color` (default) / `silhouette` | | `--merchant ` | `-m` | rendered above the QR (card mode) | | `--size ` | — | matrix mode output size | | `--output ` | `-o` | write to file (default stdout) | | `--help` | `-h` | show help | | `--version` | `-v` | show CLI version | ## Examples ```bash # Dynamic 50 THB card written to file thai-qr-payment 0812345678 --amount 50 --merchant "Acme" -o qr.svg # Bare 512 px QR matrix with high error correction thai-qr-payment 0812345678 --amount 50 --format matrix --size 512 --ecc H -o qr.svg # Print just the payload (for piping) thai-qr-payment 0812345678 --amount 50 --format payload | tee payload.txt # Pay 50.50 from satang thai-qr-payment 0812345678 --amount 5050 --satang -o qr.svg # Silhouette theme (monochrome brand artwork) thai-qr-payment 0812345678 --amount 50 --theme silhouette -o qr.svg # National ID recipient thai-qr-payment 1234567890123 --type nationalId --amount 100 -o qr.svg # e-Wallet recipient thai-qr-payment 123456789012345 --type eWallet --amount 200 -o qr.svg ``` # Payload (EMVCo TLV) > Build + parse Thai QR Payment wire payloads with @thai-qr-payment/payload. ![Sample Thai QR Payment card](/img/samples/qr-card-merchant.svg) `@thai-qr-payment/payload` implements the **EMVCo Merchant-Presented-Mode v1.1** TLV grammar plus the **Bank of Thailand Thai QR Payment supplement** (PromptPay, BillPayment, TrueMoney, OTA, VAT TQRC, cross-border ASEAN remittance). Zero dependencies, every JS runtime. ## One-shot helper ```ts import { payloadFor } from 'thai-qr-payment'; const wire = payloadFor({ recipient: '0812345678', amount: 50 }); // 00020101021229370016A000000677010111011300668123456785303764540550.005802TH6304XXXX ``` Reach for `ThaiQRPaymentBuilder` when you need merchant info, references, OTA, bank-account credit transfer, TrueMoney, VAT TQRC, or cross-border. ## Builder ```ts import { ThaiQRPaymentBuilder } from 'thai-qr-payment'; ``` Three terminal methods regardless of what you configure: `.build()` returns the wire string, `.buildWithChecksum()` splits the body / CRC for inspection, `.toBytes()` returns a `Uint8Array` for hashing or transport. ### `.promptpay(recipient, type?)` Mobile, national ID, or e-wallet recipient. Type is inferred from digit length when omitted: 9–12 → `mobile`, 13 → `nationalId`, 15 → `eWallet`. The override exists for the (rare) ambiguous case. ```ts new ThaiQRPaymentBuilder().promptpay('0812345678').amount(50).build(); new ThaiQRPaymentBuilder().promptpay('1234567890123', 'nationalId').amount(50).build(); new ThaiQRPaymentBuilder().promptpay('123456789012345', 'eWallet').amount(50).build(); ``` Mobile recipients are zero-padded to the 13-char `0066xxxxxxxxxx` wire form before encoding. ### `.bankAccount(bankCode, accountNo)` PromptPay credit transfer to a bank account (sub-tag 04 under tag 29). `bankCode` is the 3-digit BoT bank identifier (`'002'` Bangkok Bank, `'014'` SCB, …); `accountNo` is the variable-length numeric account. Combined wire value is capped at 43 chars per the EMVCo sub-tag limit. ```ts new ThaiQRPaymentBuilder().bankAccount('014', '1234567890').amount(100).build(); // 00020101021229370016A0000006770101110413014123456789053037645406100.005802TH6304901D ``` This method exists separately from `.promptpay(..., 'bankAccount')` because the wire value needs the (bankCode, accountNo) split a single string can't carry — calling `.promptpay(x, 'bankAccount')` throws. ### `.ota(otaCode)` Attach a **One-Time Authorization** code (sub-tag 05, exactly 10 chars). The AID swap is the whole point: the builder flips tag 29's GUID from `A000000677010111` (standard PromptPay) to `A000000677010114` (PromptPay OTA) so the receiving bank routes the payload through the single-use credit-transfer flow instead of the repeatable PromptPay merchant flow. ```ts new ThaiQRPaymentBuilder().promptpay('0812345678').ota('1234567890').amount(50).build(); // 00020101021229510016A00000067701011401130066812345678051012345678905303764540550.005802TH63048856 ``` Combines cleanly with `.bankAccount()` for an OTA bank-account transfer. ### `.trueMoney(mobileNo, { amount?, message? })` TrueMoney Wallet QR. Same merchant template tag as PromptPay (29) but with the literal `'14'` prefix on sub-tag 03 — that prefix is how the TrueMoney app discriminates its own payloads from a plain e-wallet QR. Mobile is zero-padded left to 13 digits, then prefixed; final sub-tag 03 value is always 15 chars. ```ts new ThaiQRPaymentBuilder().trueMoney('0801111111').build(); // 00020101021129390016A000000677010111031514000080111111153037645802TH63047C0F new ThaiQRPaymentBuilder().trueMoney('0801111111', { amount: 10, message: 'Hello World!' }).build(); // includes tag 81: '814800480065006C006C006F00200057006F0072006C00640021' ``` The optional `message` is carried in tag 81 as **UTF-16BE** hex (each Unicode code unit becomes 4 uppercase hex chars). It surfaces only inside the TrueMoney app — other wallets ignore it. See [personal message codec](#personal-message-codec) below for the raw encoder. ### `.billPayment({ billerId, reference1?, reference2?, crossBorder? })` BillPayment merchant template (tag 30). `billerId` is the cross-bank biller identifier (15 chars on the wire); references are application-defined. ```ts new ThaiQRPaymentBuilder() .billPayment({ billerId: '123456789012345', reference1: 'INV001', reference2: 'CUST42', }) .amount(250.5) .build(); ``` Pass `crossBorder: true` to emit the **ASEAN-region remittance AID** (`A000000677012006`) instead of the domestic one (`A000000677010112`) — same sub-tag layout, but receivers route the payment through the ASEAN PayNow / DuitNow / QRIS interop rails instead of the local PromptPay biller switch. ```ts new ThaiQRPaymentBuilder() .billPayment({ billerId: '099400016550100', reference1: '123456789012', crossBorder: true }) .amount(100) .build(); // 00020101021230550016A0000006770120060115099400016550100021212345678901253037645406100.005802TH63049D1C ``` Cross-border payloads pair with the `purposeOfTransaction` additional-data sub-field (tag 62 sub-tag 08), which carries an 18-char triple: currency code (3 digits) + local amount (13 digits) + country code (2 chars). The builder treats that triple opaquely — compose and parse it at the call site. ### `.amount(value, opts?)` THB amount. Two-decimal output, integer-math rounding (no `0.30000000000000004` surprises). Omit / pass `undefined` for a static QR — the consumer's banking app then prompts for the amount. ```ts .amount(50) // 50.00 .amount(99.5) // 99.50 .amount(12345, { fromSatang: true }) // 123.45 — integer satang input .amount(12345n, { fromSatang: true }) // BigInt also works .amount(undefined) // static QR (no tag 54) .amount(0) // same — zero collapses to static ``` Max wire value: 9,999,999,999.99 THB. Negative, `NaN`, or `Infinity` throws. Setting any non-zero amount flips the point-of-initiation tag from `11` (static) to `12` (dynamic) automatically. Override with `.pointOfInitiation('static' | 'dynamic')` if you need to force one. ### `.merchant({ name?, city?, postalCode?, categoryCode? })` Display fields. `name` is truncated to 25 chars, `city` to 15. `categoryCode` is the 4-digit ISO 18245 MCC. ```ts .merchant({ name: 'Acme Coffee', city: 'BANGKOK', postalCode: '10310', categoryCode: '5814', // Fast Food Restaurants }) ``` ### `.additionalData({...})` Sub-fields of tag 62. All nine slots: ```ts .additionalData({ billNumber: 'INV-2026-001', // sub-tag 01 mobileNumber: '02-123-4567', // sub-tag 02 storeLabel: 'STR01', // sub-tag 03 loyaltyNumber: 'LOY42', // sub-tag 04 referenceLabel: 'REF99', // sub-tag 05 customerLabel: 'CUST42', // sub-tag 06 terminalLabel: 'T01', // sub-tag 07 purposeOfTransaction: 'PURCHASE', // sub-tag 08 (or cross-border triple) consumerDataRequest: 'EMAIL', // sub-tag 09 }) ``` Multiple `.additionalData()` calls merge — later keys overwrite earlier ones for the same slot. ### `.tipPolicy({...})` Tags 55–57. ```ts .tipPolicy({ mode: 'prompt' }) // app asks the payer .tipPolicy({ mode: 'fixed', value: 10 }) // 10.00 THB .tipPolicy({ mode: 'fixed', value: 1000, fromSatang: true }) .tipPolicy({ mode: 'percentage', value: 5 }) // 5.00 % .tipPolicy(undefined) // clear ``` A zero fixed tip throws — pass `undefined` instead. ### `.vatTqrc({ sellerTaxBranchId, vatRate?, vatAmount })` Bank of Thailand **VAT TQRC** extension (top-level tag 80). Promotes a regular PromptPay payment QR into a **Tax-Qualified-QR-Code** source for Thai e-tax-receipt integrations — the receiving system reads the VAT split off the QR and emits a compliant electronic receipt without a separate API call. ```ts new ThaiQRPaymentBuilder() .promptpay('0812345678') .amount(107) .vatTqrc({ sellerTaxBranchId: '0001', vatRate: '7', vatAmount: '7.00' }) .build(); // …8021000400010101702047.00 6304XXXX ``` Field-length rules from the BoT extension spec: - `sellerTaxBranchId` — exactly 4 chars - `vatRate` — 1–5 chars when present (e.g. `'7'` or `'7.00'`); omit for VAT-inclusive receipts that don't display a rate - `vatAmount` — 1–13 chars, required Pass `undefined` to clear. ### `.build()` / `.buildWithChecksum()` / `.toBytes()` ```ts const wire = builder.build(); // "00020101…6304XXXX" const { body, checksum, payload } = builder.buildWithChecksum(); // body ends with "6304" (the CRC tag header is part of the hashed input) // checksum is the 4-char uppercase hex CRC // payload === body + checksum const bytes = builder.toBytes(); // Uint8Array — one byte per ASCII char in payload ``` CRC is **CRC-16/CCITT-FALSE** (poly `0x1021`, init `0xFFFF`, no reflect, no XOR out), computed over the body **plus** the `6304` tag header. Missing that header in your verifier is the classic off-by-spec mistake. ## Parser ```ts import { parsePayload } from 'thai-qr-payment'; ``` ### `parsePayload(payload, { strict? })` ```ts const parsed = parsePayload(wire); // { // payloadFormat: '01', // pointOfInitiation: 'dynamic', // merchant: { kind: 'promptpay', recipientType: 'mobile', recipient: '0812345678' }, // amount: 50, // currency: '764', // country: 'TH', // merchantName: 'Acme Coffee', // crc: { value: '901D', valid: true, truncated: false }, // rawTags: [...], // getTag(id), getTagValue(id, subId?), // ... // } ``` Default behaviour: - Verifies the trailing CRC. If the 4-char tail matches the recomputed checksum, returns `crc: { valid: true, truncated: false }`. - If the tail is 1–3 chars (some Thai banking apps strip leading zeros when re-encoding), tries left-padding with `0` until the checksum matches. On success returns `crc: { valid: true, truncated: true }` — the parsed merchant data is correct; surface a warning to the user if you care about reporting the source app's bug. - On unrecoverable mismatch: throws. Pass `{ strict: true }` to refuse the truncated-CRC auto-fix and throw on missing / mismatched CRC immediately. Use strict for trust-boundary parses (slip OCR, payment-link inputs); leave it off when consuming the output of a known-buggy app. ### `ParsedPayload` shape The `merchant` field is a discriminated union — narrow on `.kind`: ```ts type Merchant = ParsedPromptPay | ParsedBillPayment | ParsedTrueMoney | null; interface ParsedPromptPay { kind: 'promptpay'; recipientType: 'mobile' | 'nationalId' | 'eWallet' | 'bankAccount'; recipient: string; bankCode?: string; // set when recipientType === 'bankAccount' accountNo?: string; // set when recipientType === 'bankAccount' ota?: string; // 10-char OTA code when present } interface ParsedBillPayment { kind: 'billPayment'; billerId: string; reference1?: string; reference2?: string; crossBorder: boolean; // true when AID is A000000677012006 } interface ParsedTrueMoney { kind: 'trueMoney'; mobileNo: string; message?: string; // decoded from tag 81 UTF-16BE hex } ``` `merchant` is `null` only for payloads that lack a recognised merchant template — every PromptPay / BillPayment / TrueMoney shape resolves to a concrete kind. VAT TQRC, when present, lands at the top level: ```ts parsed.vatTqrc; // { sellerTaxBranchId: '0001', vatRate: '7', vatAmount: '7.00' } ``` In strict mode, a tag 80 with a malformed sub-template throws; otherwise it silently degrades to `vatTqrc: undefined`. ### Raw tag accessors For unknown / future tags, drop down to the raw TLV view: ```ts parsed.rawTags; // readonly [{ tag: '00', value: '01' }, { tag: '01', value: '12' }, …] parsed.getTag('58'); // { tag: '58', value: 'TH' } parsed.getTagValue('29', '00'); // 'A000000677010111' — the AID inside the merchant template parsed.getTagValue('62', '01'); // 'INV-2026-001' — billNumber sub-field ``` `getTagValue(id, subId?)` descends one level — pass just `id` for a top-level value, `(id, subId)` for nested templates (tags 29–31, 62, 64, 80). ## Low-level TLV helpers For tools that need to introspect / synthesise raw TLV runs without the full builder: ```ts import { encodeField, // (tag, value) → 'IILLDDDD…' encodeFields, // ([tag, value][]) → concatenated, null/empty entries dropped parseFields, // (input) → Map iterateFields, // (input) → IterableIterator<{tag, value}> checksum, // (input) → 4-char uppercase hex CRC-16/CCITT-FALSE Tags, // namespace of every spec-defined tag id constant } from 'thai-qr-payment'; encodeField('58', 'TH'); // '5802TH' encodeFields([ ['00', '01'], ['01', null], ]); // '000201' parseFields('5802TH5303764').get('53'); // '764' checksum('00020101…6304'); // 'ABCD' Tags.TAG_TRANSACTION_AMOUNT; // '54' Tags.GUID_PROMPTPAY; // 'A000000677010111' ``` `encodeField` throws if the value exceeds 99 bytes (the EMVCo 2-digit length cap); split across multiple tags at the call site. ## Personal message codec Tag 81's wire format is the UTF-16BE encoding of the message expressed as uppercase hex. Each Unicode code unit produces 4 hex chars. ```ts import { encodePersonalMessage, decodePersonalMessage } from 'thai-qr-payment'; encodePersonalMessage('Hello'); // '00480065006C006C006F' decodePersonalMessage('00480065006C006C006F'); // 'Hello' ``` `.trueMoney(mobile, { message })` calls `encodePersonalMessage` internally; `parsePayload` calls `decodePersonalMessage` for any tag 81 attached to a TrueMoney merchant. The raw codec is exported for callers that want to put the message on a different envelope. ## Tag coverage See the [spec coverage reference](/reference/spec/) for the complete tag-by-tag implementation table. # QR encoder > ISO/IEC 18004 QR Code encoder — Reed-Solomon + Galois field, zero dependencies. ![Bare QR matrix output](/img/samples/qr-matrix.svg) The `@thai-qr-payment/qr` package implements ISO/IEC 18004 Model-2 QR Code generation. Reed-Solomon error correction over GF(2^8) is hand-rolled — no `qrcode`, no native bindings. ## Quickstart ```ts import { encodeQR } from 'thai-qr-payment'; const { size, modules, version, mask, errorCorrectionLevel } = encodeQR( '00020101021229370016A000000677010111...6304ABCD', { errorCorrectionLevel: 'H' }, ); // modules: boolean[][] — modules[y][x] === true → dark module // size: number — matrix dimension in modules // version: 1..40 // mask: 0..7 ``` The output is a pure data structure. Pair with `@thai-qr-payment/render` for SVG. ## API ### `encodeQR(text, options?)` | Option | Default | Notes | | ---------------------- | ------- | ------------------------------------------------- | | `errorCorrectionLevel` | `'M'` | `'L'` / `'M'` / `'Q'` / `'H'` | | `minVersion` | `1` | floor for version selection | | `maxVersion` | `40` | ceiling — throws if input doesn't fit | | `forceMask` | auto | `0..7` — auto-selected by penalty score otherwise | ### `detectMode(text)` ```ts detectMode('1234567890'); // 'numeric' detectMode('HELLO WORLD'); // 'alphanumeric' detectMode('สวัสดี'); // 'byte' (UTF-8 fallback) ``` EMVCo payloads always fit in `alphanumeric` mode (`[0-9A-Z $%*+-./:]`). ## How it works 1. **Mode detection** — narrowest viable mode (numeric → alphanumeric → byte) 2. **Version selection** — smallest version that fits the bit budget at the requested ECC level 3. **Bit packing** — mode indicator + char-count + data bits → packed codewords + filler 4. **Reed-Solomon ECC** — appended per ISO/IEC 18004 §7.5, blocks interleaved per §7.6 5. **Module placement** — finder + alignment + timing + format-info + version-info + data zigzag 6. **Mask selection** — all 8 masks scored on the four spec penalty rules; lowest wins ## Property tests | Invariant | Status | | -------------------------------------------------------------------- | -------------------- | | RS linearity: `enc(a) ⊕ enc(b) === enc(a ⊕ b)` | ✓ verified | | GF(2^8) distributivity: `a · (b ⊕ c) === (a·b) ⊕ (a·c)` | ✓ verified | | CRC-16/CCITT-FALSE determinism over 200 random inputs | ✓ | | Alignment-pattern centres pinned to ISO/IEC 18004 Annex E for v2-v40 | ✓ 10 pinned versions | ## v0.1.0 → v0.1.1 fix The initial v0.1.0 release shipped a bug in `alignmentCentres()` — every QR at version ≥ 2 placed alignment patterns at the wrong coordinates, so scanners rejected the output as "invalid". Fixed in v0.1.1 (commit `e4af92f`) with regression tests pinning the Annex E positions. **Pin to ≥ 0.1.1 in production.** # React component > and for React 18+ apps. ![Rendered React component output](/img/samples/qr-card-merchant.svg) `@thai-qr-payment/react` wires the renderer into a typed React component. Works in CSR + SSR (Next.js, Remix, TanStack Start, vanilla Vite) — no jsdom needed, no `useEffect` rigging. ## Install ```bash pnpm add @thai-qr-payment/react react ``` `react` is a **peer dependency** — bring whichever version you're already using (≥ 18). ## Full card ```tsx import { ThaiQRPayment } from '@thai-qr-payment/react'; export function PaymentScreen() { return ( ); } ``` ## Bare matrix ```tsx import { ThaiQRPaymentMatrix } from '@thai-qr-payment/react'; ; ``` ## SSR Both components serialize on the server via `react-dom/server.renderToStaticMarkup`. The SVG is embedded directly into the HTML — no hydration handshake required. ```tsx // Next.js app router — server component export default function Page() { return ; } ``` ## Accessibility The wrapper carries `role="img"` and a generated `aria-label` (`"Thai QR Payment for "`). Override with `ariaLabel`: ```tsx ``` ## All props | Prop | Type | Notes | | --------------------------------- | --------------------------------------- | --------------------------------------- | | `recipient` | `string` | phone / nationalId / eWallet — required | | `amount` | `number` | THB, omit for static QR | | `recipientType` | `'mobile' \| 'nationalId' \| 'eWallet'` | override auto-detection | | `fromSatang` | `boolean` | treat `amount` as integer satang | | `errorCorrectionLevel` | `'L' \| 'M' \| 'Q' \| 'H'` | default `'M'` | | `merchantName` | `string` | rendered above the QR (card mode only) | | `amountLabel` | `string` | rendered below the QR (card mode only) | | `theme` | `'color' \| 'silhouette'` | brand artwork flavor | | `className`, `style`, `ariaLabel` | DOM pass-through | | ## React 19 ready `@thai-qr-payment/react` declares `react@>=18` as peer dep. The component itself uses no APIs removed in React 19 — string refs, `propTypes`/`defaultProps` for function components, legacy context — so it runs unmodified on both major versions. # SVG renderer > Compose a Thai QR Payment SVG card or bare matrix from a wire payload. ![Sample card with brand-spec layout](/img/samples/qr-card-hero.svg) `@thai-qr-payment/render` ties together the payload builder, QR encoder, and brand assets into a single SVG string. No DOM, no canvas — works in every runtime. ## One-shot card ```ts import { renderThaiQRPayment } from 'thai-qr-payment'; const svg = renderThaiQRPayment({ recipient: '0812345678', amount: 50, merchantName: 'Acme Coffee', amountLabel: '฿ 50.00', errorCorrectionLevel: 'H', }); ``` Returns a full SVG card: Thai QR Payment header band + PromptPay sub-mark + bordered QR + amount label. ## Bare matrix When you want to wrap the QR in your own design system: ```ts import { renderThaiQRPaymentMatrix } from 'thai-qr-payment'; const svg = renderThaiQRPaymentMatrix({ recipient: '0812345678', amount: 50, size: 320, quietZone: 4, }); ``` ## Card options | Option | Default | Notes | | --------------- | ------------------------- | ------------------------------------------------------ | | `theme` | `color` | `'silhouette'` swaps brand artwork to monochrome paths | | `merchantName` | — | rendered above the QR | | `amountLabel` | — | rendered below the QR | | `background` | `#fff` | card backdrop | | `accent` | `#0a2540` | text + silhouette fill colour | | `headerLogo` | `Thai_QR_Payment_Logo-01` | override via `@thai-qr-payment/assets` registry name | | `promptpayLogo` | `PromptPay1` | override | ## Low-level building blocks ```ts import { encodeQR } from 'thai-qr-payment'; import { renderCard, renderQRSvg, matrixToPath } from 'thai-qr-payment'; const matrix = encodeQR(wireString, { errorCorrectionLevel: 'H' }); const svg = renderCard(matrix, { merchantName: 'Acme', amountLabel: '฿ 50' }); // Or even lower: const justTheQr = renderQRSvg(matrix, { size: 512, quietZone: 4 }); const pathData = matrixToPath(matrix); ``` ## XSS-safe by construction Every interpolated string runs through `escapeXmlAttribute` before landing in the SVG markup, so values like `` in `merchantName` come out as the harmless escaped form. Verified by a dedicated test fixture in the render package. ## Server response ```ts return new Response(svg, { headers: { 'content-type': 'image/svg+xml; charset=utf-8' }, }); ``` Works directly from Cloudflare Workers, Vercel Edge, Bun, Deno, Node — no runtime-specific glue needed. # Slip Verify > Build + parse the Mini-QR printed on Thai bank transfer slips. ## Why A **Slip Verify Mini-QR** is the small square QR printed on a bank transfer slip (and shown inside the PromptPay app's slip-detail view). It is **not** a payment QR — its sole purpose is to feed a bank Open API the reference it needs to look the transaction up after the slip image is OCR'd or scanned. Use it to verify that a customer who claims to have paid actually did. The envelope shares the EMVCo TLV grammar but uses its own root tags — see the [wire format table](#wire-format) below. Two variants exist: the standard one defined by the **Bank of Thailand Thai QR Payment supplement**, and a TrueMoney variant emitted by the TrueMoney Wallet app. ```ts import { buildSlipVerify, parseSlipVerify, buildTrueMoneySlipVerify, parseTrueMoneySlipVerify, } from 'thai-qr-payment'; ``` ## Standard slip-verify `buildSlipVerify({ sendingBank, transRef })` emits the wire payload; `parseSlipVerify(payload)` recovers the two fields. `sendingBank` is the 3-digit BoT bank code (`'002'` Bangkok Bank, `'014'` SCB, etc.); `transRef` is the reference printed on the slip. ```ts const wire = buildSlipVerify({ sendingBank: '002', transRef: '0002123123121200011', }); // '004000060000010103002021900021231231212000115102TH91049C30' parseSlipVerify(wire); // { sendingBank: '002', transRef: '0002123123121200011' } ``` The parser returns `null` (not an exception) on any payload that isn't a valid slip-verify envelope — wrong root tag, wrong CRC tag, wrong API marker, or unrecoverable checksum mismatch. Callers can branch on the result without `try / catch`. Truncated-CRC auto-fix is on by default: some bank apps strip leading zeros from the tag-91 hex CRC when re-encoding, so a 1–3 char tail is left-padded with `0` and re-verified before giving up. ```ts // Bank app emitted "…91049C30" with the leading '0' dropped — still parses parseSlipVerify('…91049C3'); // → { sendingBank, transRef } (auto-fixed) ``` ## TrueMoney slip-verify TrueMoney's variant uses the same envelope (root tag 00, country tag 51, CRC tag 91) with a different sub-tag layout. `date` is a **`DDMMYYYY` 8-char string** — the builder throws if the length is wrong. ```ts const wire = buildTrueMoneySlipVerify({ eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024', }); // '00480002010102010203P2P0313TXN00012345670408250120249104b425' parseTrueMoneySlipVerify(wire); // { eventType: 'P2P', transactionId: 'TXN0001234567', date: '25012024' } ``` **Lowercase-CRC quirk:** the TrueMoney variant emits the tag-91 CRC as **lowercase** hex (`9104b425`), not the uppercase form everyone else uses. The parser accepts either case so you can re-hash, normalise, or store in any form — but if you're handing the wire bytes to another tool, preserve the case TrueMoney shipped or its own scanner may refuse. The two parsers are strict about which envelope they accept: `parseSlipVerify` returns `null` on a TrueMoney payload, and `parseTrueMoneySlipVerify` returns `null` on a standard one. Try both in order if you don't know which variant your input is. ## Wire format ### Standard slip-verify Root template at tag 00; country tag 51; CRC at tag 91 (uppercase hex). Tag 00's value is itself a TLV run: | Tag | Name | Length | Example value | | --- | -------------------- | ------ | ------------------ | | 00 | Root template | var | (nested TLV below) | | 51 | Country | 2 | `TH` | | 91 | CRC-16 / CCITT-FALSE | 4 | `9C30` | Sub-tags inside tag 00: | Sub-tag | Name | Length | Example value | | ------- | --------------- | ------ | --------------------- | | 00 | API type marker | 6 | `000001` | | 01 | Sending bank | var | `002` | | 02 | Transaction ref | var | `0002123123121200011` | ### TrueMoney slip-verify Same root tag / country tag / CRC tag, different sub-tag layout (and lowercase CRC): | Tag | Name | Length | Example value | | --- | -------------------- | ------ | ------------------ | | 00 | Root template | var | (nested TLV below) | | 91 | CRC-16 / CCITT-FALSE | 4 | `b425` | Sub-tags inside tag 00: | Sub-tag | Name | Length | Example value | | ------- | ----------------- | ------ | --------------- | | 00 | Marker A (`'01'`) | 2 | `01` | | 01 | Marker B (`'01'`) | 2 | `01` | | 02 | Event type | var | `P2P` | | 03 | Transaction id | var | `TXN0001234567` | | 04 | Date (`DDMMYYYY`) | 8 | `25012024` | The marker pair (sub-tags 00 + 01 both `'01'`) is the discriminator that distinguishes a TrueMoney envelope from the standard one — without it `parseTrueMoneySlipVerify` returns `null`. # Install > Add thai-qr-payment to your project — one umbrella install or scoped sub-packages. ## One package, everything included The umbrella `thai-qr-payment` carries the **payload builder, QR encoder, SVG renderer, brand assets, and CLI** in a single dependency. ```bash pnpm add thai-qr-payment # or npm install thai-qr-payment # or bun add thai-qr-payment ``` That's it — no peer dependencies, no transitive packages, no install scripts. `npm install thai-qr-payment` literally pulls one tarball. ## Scoped sub-packages (tighter dep graph) For consumers who want only one slice (e.g. payload-only on edge runtimes): | Need | Install | | -------------------------------- | -------------------------- | | Wire payload builder + parser | `@thai-qr-payment/payload` | | QR Code encoder | `@thai-qr-payment/qr` | | SVG renderer | `@thai-qr-payment/render` | | Thai QR Payment + PromptPay SVGs | `@thai-qr-payment/assets` | | CLI only | `@thai-qr-payment/cli` | | React component (peer-dep React) | `@thai-qr-payment/react` | Or import from the umbrella sub-paths — same bytes, same tree-shake: ```ts import { ThaiQRPaymentBuilder } from 'thai-qr-payment/payload'; import { encodeQR } from 'thai-qr-payment/qr'; import { renderCard } from 'thai-qr-payment/render'; import { COLOR_LOGOS } from 'thai-qr-payment/assets'; ``` ## CDN (skip the bundler) Every published `dist/*.js` ships pre-compressed `.br` + `.gz` siblings, so CDNs serve the smallest variant via `Accept-Encoding`: ```html ``` ## Engine requirements | Runtime | Minimum | | ------------- | ----------------------------------------------------------------------------- | | Node | ≥ 18 | | pnpm | ≥ 8 (10.x recommended) | | Browser | any module-supporting browser (Chrome 80+, Safari 14+, Firefox 78+, Edge 80+) | | Edge runtimes | tested on Cloudflare Workers, Vercel Edge | ## Verify the install ```ts import { payloadFor, parsePayload } from 'thai-qr-payment'; const wire = payloadFor({ recipient: '0812345678', amount: 50 }); console.log(wire); // 00020101021229370016A00000067701011101130066812345678530376454... const parsed = parsePayload(wire); console.log(parsed.amount); // 50 console.log(parsed.merchant); // { kind: 'promptpay', recipientType: 'mobile', recipient: '0812345678' } ``` Next: [try it in the live demo](/demo/) or jump into the [payload guide](/guide/payload/). # For LLMs > Plain-text dumps of every documentation page in formats designed for LLM ingestion. `thai-qr-payment` ships three plain-text mirrors of this documentation site for use by large language models. They follow the [llms.txt](https://llmstxt.org) proposal and are emitted on every docs build by [`starlight-llms-txt`](https://delucis.github.io/starlight-llms-txt/). | Endpoint | Purpose | | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | | [`/llms.txt`](/llms.txt) | Short index file. Links to the two longer dumps. Drop into an LLM's context to give it an entry-point to the rest. | | [`/llms-full.txt`](/llms-full.txt) | Full plain-text dump of every doc page. ~4.6k lines. Good when the model has a large context window. | | [`/llms-small.txt`](/llms-small.txt) | Abridged variant. Notes, tips, and the live demo page are stripped so the file fits in smaller context windows. | ## How to use Paste the URL into ChatGPT, Claude, or Gemini as a source. Or fetch programmatically: ```bash curl https://thai-qr-payment.js.org/llms.txt curl https://thai-qr-payment.js.org/llms-full.txt ``` The three files regenerate on every push to `main`, so they stay in sync with the published docs site. # CDN usage > Load thai-qr-payment straight from unpkg or JSDelivr — no bundler required. Every published `dist/*.js` ships with pre-compressed `.br` + `.gz` siblings. CDNs that honour `Accept-Encoding` (unpkg, JSDelivr) serve the smaller variant automatically — no runtime compression, no extra round-trip. ## unpkg ```html ``` Pinned version: ```html ``` ## JSDelivr ```html ``` ## Sub-paths over CDN The umbrella's sub-path exports (`payload`, `qr`, `render`, `assets`) work too: ```html ``` ## Pre-compressed file paths If you self-host, serve the variants directly with the right `Content-Encoding` header: | File | Content-Encoding | | ------------------ | ---------------- | | `dist/index.js` | identity | | `dist/index.js.br` | `br` | | `dist/index.js.gz` | `gzip` | A typical nginx config: ```nginx location ~ \.js$ { gzip_static on; brotli_static on; add_header Cache-Control "public, max-age=31536000, immutable"; } ``` Cloudflare Workers / Pages handle this automatically when the file is present. ## React from CDN The React adapter relies on a peer-dep React; for CDN use, mount it through ESM: ```html ``` # Edge runtimes > thai-qr-payment runs unchanged on Cloudflare Workers, Vercel Edge, Deno, Bun. The full umbrella (and every scoped package) avoids Node-only APIs. The only exception is `@thai-qr-payment/cli`, which is the CLI binary — that one uses `node:fs/promises` for file output. ## Compatibility matrix | Runtime | Status | Notes | | -------------------------------------------------------- | ------ | ----------------------------------------------- | | Browsers (Chrome 80+, Safari 14+, Firefox 78+, Edge 80+) | ✓ | ESM via `