Skip to content

Getting Started

Install

bash
pnpm add @heigoly/qris

One-Line Payment Upgrade

The most common task: decode a static QRIS, attach an amount, and get a new QRIS string ready to display.

typescript
import { pipe } from '@heigoly/qris'
import { fromString } from '@heigoly/qris/parse'
import { charge } from '@heigoly/qris/upgrade'
import { encode } from '@heigoly/qris/encode'

const output = pipe(
  '0002010102112619...6304C8C0',
  fromString,              // string → QRISDocument
  (d) => charge(d, 50000), // attach Rp50.000 amount
  encode,                  // QRISDocument → string with CRC
) as string
// Result: "000201010212..."

Or import only what you need

typescript
import { fromString } from '@heigoly/qris/parse'
import { verify } from '@heigoly/qris/verify'
import { charge } from '@heigoly/qris/upgrade'
import { encode } from '@heigoly/qris/encode'
import { format } from '@heigoly/qris/format'

// Decode
const doc = fromString('000201010211...')

// Inspect
doc.merchantName  // "Toko Berkah Jaya"
doc.amount        // undefined (static QRIS)
doc.providers[0]?.name // "DANA"

// Verify integrity
const issues = verify(doc)  // [] if valid

// Upgrade
const paid = charge(doc, 50000, { type: 'fixed', value: 2000 })

// Serialize
const finalString = encode(paid)

Deep imports for tree-shaking

typescript
import { fromString } from '@heigoly/qris/parse'
import { verify } from '@heigoly/qris/verify'
import { charge, setAmount } from '@heigoly/qris/upgrade'
import { encode } from '@heigoly/qris/encode'
import { create } from '@heigoly/qris/create'
import { format, formatDetailed } from '@heigoly/qris/format'
import { computeCRC } from '@heigoly/qris/crc'