Appearance
Parsing QRIS
Use fromString() to decode a raw QRIS string into a structured document.
typescript
import { fromString } from '@heigoly/qris/parse'
const doc = fromString('0002010102112619...6304C8C0')The returned QRISDocument contains all decoded fields:
typescript
{
method: 'static', // or 'dynamic'
poi: '11', // '11' = static, '12' = dynamic
merchantName: 'Toko Berkah Jaya',
merchantCity: 'Surabaya',
merchantCategory: '5411',
merchantCategoryLabel: 'Grocery Stores and Supermarkets',
currency: '360',
country: 'ID',
amount: undefined, // number if dynamic
convenienceFee: undefined, // { type, value } if present
providers: [
{ templateTag: '26', name: 'DANA', guid: 'ID.DANA.WWW0115' }
],
accounts: [
{ providerTag: '26', pan: '123456012345' }
],
crc: 'C8C0',
raw: [ /* TLV[] */ ], // raw parsed elements
}Error handling
fromString throws QRISError if the QRIS structure is fundamentally broken (e.g., missing Point of Initiation Method).
typescript
import { QRISError } from '@heigoly/qris'
try {
fromString('invalid')
} catch (e) {
if (e instanceof QRISError) {
console.log(e.code) // 'INVALID_POI'
console.log(e.tag) // '01'
}
}Low-level TLV extraction
typescript
import { extract } from '@heigoly/qris/tlv'
const elements = extract(qrisString)
// Returns TLV[] with tag, name, length, value