Skip to content

API Reference ​

@heigoly/qris/parse ​

fromString(input) ​

typescript
function fromString(input: string): QRISDocument

Decodes a raw QRIS string into a structured QRISDocument. Throws QRISError if the Point of Initiation Method (tag 01) is missing or invalid.


@heigoly/qris/verify ​

verify(doc) ​

typescript
function verify(doc: QRISDocument): VerifyIssue[]

Checks structural integrity: required tags, value patterns, merchant info presence. Returns an array of issues. Empty = valid.

verifyCRC(doc) ​

typescript
function verifyCRC(doc: QRISDocument): boolean

Checks whether the CRC16 checksum matches the payload data.

isSecure(doc) ​

typescript
function isSecure(doc: QRISDocument): boolean

Performs both structural and CRC checks. Returns true only if both pass.


@heigoly/qris/upgrade ​

charge(doc, amount, fee?) ​

typescript
function charge(doc: QRISDocument, amount: number, fee?: FeeOption): QRISDocument

Upgrades a static QRIS to dynamic. Throws QRISError if the document is already dynamic. Returns a new document with amount and optional fee.

setAmount(doc, amount, fee?) ​

typescript
function setAmount(doc: QRISDocument, amount: number, fee?: FeeOption): QRISDocument

Sets amount on any QRIS document (static or dynamic). Does NOT check for static-first. Returns a new document.


@heigoly/qris/encode ​

encode(doc) ​

typescript
function encode(doc: QRISDocument): string

Serializes a QRISDocument back to its raw string representation, including the computed CRC checksum.


@heigoly/qris/create ​

create(config) ​

typescript
function create(config: QRISConfig): QRISDocument

Builds a new QRISDocument from scratch. At least one payment account is required.

typescript
create({
  merchantName: 'Toko Saya',
  merchantCity: 'Jakarta',
  merchantCategoryCode: '5812',
  accounts: [{ guid: 'ID.DANA.WWW', pan: '081234567890' }],
})

@heigoly/qris/format ​

format(doc) ​

Compact single-line summary: "Warung Sayur | Rp50.000 +Rp2.000 | DANA"

formatDetailed(doc) ​

Multi-line formatted breakdown of all fields.


@heigoly/qris/crc ​

computeCRC(input) ​

typescript
function computeCRC(input: string): string

Computes CRC16-CCITT. Uses a pre-computed lookup table internally. Returns 4-character uppercase hex.

attachCRC(body) ​

typescript
function attachCRC(body: string): string

Appends 6304 + computed CRC to a TLV body string.

stripCRC(full) ​

typescript
function stripCRC(full: string): { body: string; declared: string }

Splits a CRC-terminated string into its data body and declared CRC value.


@heigoly/qris/pipe ​

pipe(input, ...fns) ​

typescript
function pipe(input: unknown, ...fns: Array<(arg: unknown) => unknown>): unknown

Composes functions left to right. Useful for building transformation pipelines.