@nurafandito/qris-static-dynamic-core
v0.2.0
Published
QRIS static to dynamic converter core (parser, validator, converter, CRC16)
Maintainers
Readme
qris-static-dynamic-core
Parse, validate, and convert Indonesian QRIS (Quick Response Code Indonesian Standard) payment codes — turn a static QRIS into a dynamic one with a fixed amount, no UI or framework attached.
Install
npm install @nurafandito/qris-static-dynamic-coreUsage
import { convertQRIS, validateQRIS, parseQRIS, lookupMCC } from "@nurafandito/qris-static-dynamic-core";
const staticQris = "00020101021226340013ID.CO.EXAMPLE...";
// Validate structure + CRC
validateQRIS(staticQris); // { valid: boolean, errors: string[] }
// Convert static -> dynamic with a fixed amount
const dynamicQris = convertQRIS(staticQris, {
amount: 15000,
fee: { type: "fixed", value: 500 }, // optional
});
// Inspect a QRIS string
parseQRIS(dynamicQris); // { method: "dynamic", amount: "15000", merchantName, ... }
// Look up a Merchant Category Code
lookupMCC("5411"); // { description: "Grocery Stores and Supermarkets", category: "Food and Beverage" }
lookupMCC("9999"); // undefined — not every code is in the bundled tableAPI
parseTLV(data: string): TLV[]— parse a raw TLV string into structured elements.parseQRIS(qrisString: string): QRISData— parse a full QRIS payload into a friendly shape.convertQRIS(qrisString: string, options: ConvertOptions): string— convert static to dynamic, injecting amount and optional fee, recalculating the CRC.validateQRIS(qrisString: string): ValidationResult— structural + CRC validation, including a 4-digit format check on the Merchant Category Code.calculateCRC16(str: string): string— EMVCo CRC16-CCITT checksum.lookupMCC(code: string): MccInfo | undefined— look up a Merchant Category Code (sourced from DOKU, 336 codes; not authoritative — ISO 18245 has ~1000).
Development
npm run build # compile to dist/
npm run typecheck
npm test # build + run test/smoke.mjsLicense
MIT
