Skip to content

Types & Interfaces

TLV

typescript
interface TLV {
  readonly tag: string
  readonly name: string
  readonly length: number
  readonly value: string
  readonly children?: readonly TLV[]
}

A single Tag-Length-Value element. children is present for container tags (26–51 for merchant templates, 62 for additional data).


QRISDocument

typescript
interface QRISDocument {
  readonly raw: readonly TLV[]
  readonly payloadFormat: string
  readonly method: 'static' | 'dynamic'
  readonly poi: '11' | '12'
  readonly merchantName: string
  readonly merchantCity: string
  readonly merchantCategory: string
  readonly merchantCategoryLabel: string
  readonly currency: string
  readonly country: string
  readonly postalCode?: string
  readonly amount?: number
  readonly convenienceFee?: FeeInfo
  readonly providers: readonly ProviderInfo[]
  readonly accounts: readonly AccountInfo[]
  readonly additionalData?: Record<string, string>
  readonly crc: string
}

The central data model. Produced by fromString() and create(), consumed by verify(), charge(), encode(), and format().


ProviderInfo

typescript
interface ProviderInfo {
  readonly templateTag: string
  readonly name: string
  readonly guid: string
}

Identifies a payment provider (e.g. DANA, GoPay, ShopeePay) found in a merchant account template.

FieldDescription
templateTagThe merchant template tag (e.g. "26")
nameHuman-readable provider name
guidRaw GUID from template subtag 00

AccountInfo

typescript
interface AccountInfo {
  readonly providerTag: string
  readonly pan?: string
  readonly merchantId?: string
  readonly merchantCriteria?: string
}

Payment account details extracted from a merchant template.

FieldDescription
providerTagThe merchant template tag (e.g. "26")
panMerchant account number / PAN (subtag 01)
merchantIdMerchant ID (subtag 02)
merchantCriteriaMerchant criteria (subtag 03)

FeeOption

typescript
interface FeeOption {
  readonly type: 'fixed' | 'percentage'
  readonly value: number
}

Convenience fee configuration. Passed to charge() or setAmount().

typevalue unit
fixedAmount in IDR (e.g. 2000 for Rp2.000)
percentagePercentage (e.g. 2.5 for 2.5%)

VerifyIssue

typescript
interface VerifyIssue {
  readonly severity?: 'error' | 'warning'
  readonly message: string
  readonly code: string
  readonly tag?: string
  readonly position?: number
}

A single validation issue returned by verify(). An empty array means the document is valid.

FieldDescription
severity"error" (default) or "warning"
messageHuman-readable description
codeMachine-readable error code (e.g. MISSING_TAG, DUPLICATE_TAG)
tagThe TLV tag the issue relates to, if applicable
positionByte position in the raw string, if applicable

QRISConfig

typescript
interface QRISConfig {
  readonly merchantName: string
  readonly merchantCity: string
  readonly merchantCategoryCode?: string
  readonly countryCode?: string
  readonly currency?: string
  readonly postalCode?: string
  readonly accounts: readonly QRISAccountConfig[]
}

Configuration object for create().


QRISAccountConfig

typescript
interface QRISAccountConfig {
  readonly guid: string
  readonly pan?: string
  readonly merchantId?: string
  readonly merchantCriteria?: string
}

A single payment account definition for create().

FieldDescription
guidPayment provider GUID (e.g. "ID.DANA.WWW")
panMerchant account number / PAN
merchantIdMerchant ID
merchantCriteriaMerchant criteria

QRISError

typescript
class QRISError extends Error {
  readonly code: string
  readonly tag?: string
  readonly position?: number

  constructor(message: string, code: string, tag?: string, position?: number)
}

The single error class used throughout the library. Thrown by fromString(), charge(), setAmount(), and create().

PropertyDescription
messageHuman-readable description
codeMachine-readable error code (e.g. INVALID_POI, ALREADY_DYNAMIC, NO_ACCOUNTS)
tagThe TLV tag that caused the error, if applicable
positionByte position in the raw string, if applicable

Error codes:

CodeThrown byCondition
INVALID_POIfromStringPoint of Initiation method is missing or not 11/12
ALREADY_DYNAMICchargeDocument is already dynamic
INVALID_AMOUNTsetAmountAmount is zero, negative, or non-integer
INVALID_FEEsetAmountFee is negative or percentage exceeds 100
NO_ACCOUNTScreateNo payment accounts provided
TOO_MANY_ACCOUNTScreateMore than 26 accounts

TagInfo

typescript
type TagCategory =
  | 'header'
  | 'merchant'
  | 'classification'
  | 'financial'
  | 'location'
  | 'additional'
  | 'integrity'

interface TagInfo {
  readonly name: string
  readonly required: boolean
  readonly category: TagCategory
  readonly pattern?: RegExp
  readonly description?: string
}

Schema metadata for each TLV tag. Used internally by the tag registry (TAG_SCHEMA).