@agungjsp/qris-dinamis
v1.0.7
Published
Make static QRIS to dynamic QRIS
Maintainers
Readme
QRIS Dinamis
Convert static QRIS (Quick Response Code Indonesian Standard) to dynamic QRIS with payment amounts.
Features
- ✅ Convert static QRIS to dynamic QRIS with embedded amounts
- ✅ Generate QR code images with customizable templates
- ✅ Support for both CommonJS and ES Modules
- ✅ Base64 output option for web applications
- ✅ Fee calculation (percentage or fixed amount)
- ✅ Custom output paths
- ✅ Zero security vulnerabilities
- ✅ Built-in CRC16 validation
Installation
npm i @agungjsp/qris-dinamisNote: This is an improved fork of the original
qris-dinamispackage with security fixes and ES Module support.
Import Module
// CommonJS
const qrisDinamis = require('@agungjsp/qris-dinamis');
// ES Modules (both syntaxes supported)
import qrisDinamis from '@agungjsp/qris-dinamis';
import { makeString, makeFile } from '@agungjsp/qris-dinamis';Usage
Generate Dynamic QRIS String
const qris = '00020101021126570011ID1234567890123456789012340303UMI51440014ID.CO.QRIS.WWW0215ID20232108123456780303UMI520454995802ID5914MERCHANT NAME6007Jakarta61051234662070703A016304ABCD';
const result = qrisDinamis.makeString(qris, { nominal: '5000' });
console.log(result); // Returns modified QRIS string with embedded amountGenerate QR Code Image
const qris = '00020101021126570011ID1234567890123456789012340303UMI51440014ID.CO.QRIS.WWW0215ID20232108123456780303UMI520454995802ID5914MERCHANT NAME6007Jakarta61051234662070703A016304ABCD';
// Basic usage - saves to output/ directory
const result = await qrisDinamis.makeFile(qris, { nominal: '5000' });
// Base64 output for web applications
const base64 = await qrisDinamis.makeFile(qris, {
nominal: '5000',
base64: true
});
// Custom output path
const result = await qrisDinamis.makeFile(qris, {
nominal: '5000',
path: 'custom/path/qris.jpg'
});
// With fee calculation
const result = await qrisDinamis.makeFile(qris, {
nominal: '5000',
fee: '500',
taxtype: 'r' // 'r' for rupiah, 'p' for percent
});
// Browser usage (returns QR code data URL)
const qrDataURL = await qrisDinamis.makeFile(qris, {
nominal: '5000',
base64: true // Required in browser environments
});
// Note: Browser version returns a simple QR code without template overlayAPI Reference
makeString(qris, options)
Converts static QRIS string to dynamic QRIS string.
Parameters:
| Param | Type | Required | Default | Description |
|-----------|--------|----------|---------|-------------|
| qris | string | ✅ | - | Static QRIS string |
| nominal | string | ✅ | - | Payment amount |
| taxtype | string | ❌ | 'p' | Tax type: 'r' (rupiah) or 'p' (percent) |
| fee | string | ❌ | '0' | Fee amount |
Returns: string - Dynamic QRIS string
makeFile(qris, options)
Generates QR code image from dynamic QRIS.
Parameters:
| Param | Type | Required | Default | Description |
|---------------|---------|----------|---------|-------------|
| qris | string | ✅ | - | Static QRIS string |
| nominal | string | ✅ | - | Payment amount |
| base64 | boolean | ❌ | false | Return base64 string instead of file |
| path | string | ❌ | auto | Custom output path (Node.js only) |
| templatePath| string | ❌ | 'assets/template.png' | Custom template image path |
| taxtype | string | ❌ | 'p' | Tax type: 'r' (rupiah) or 'p' (percent) |
| fee | string | ❌ | '0' | Fee amount |
Returns: Promise<string> - File path (Node.js), base64 string (Node.js), or data URL (Browser)
Error Handling
try {
const result = qrisDinamis.makeString(qris, { nominal: '5000' });
} catch (error) {
if (error.message.includes('required')) {
console.log('Missing required parameter');
}
}
try {
const result = await qrisDinamis.makeFile(qris, { nominal: '5000' });
} catch (error) {
console.log('File generation failed:', error.message);
}Requirements
- Node.js >= 12.0.0 (for full template functionality)
- Modern browser with ES6 support (for browser usage)
- The
output/directory will be created automatically if it doesn't exist
Browser vs Node.js Differences
| Feature | Node.js | Browser | |---------|---------|---------| | Template overlay | ✅ Full template with fonts | ❌ Simple QR only | | File output | ✅ Supported | ❌ Not supported | | Base64/Data URL | ✅ Supported | ✅ Supported | | Custom fonts | ✅ Supported | ❌ Not supported |
What's New
🚀 Latest improvements include browser compatibility fixes, security updates, and enhanced error handling.
👉 See full changelog: GitHub Releases
Security
This package has zero security vulnerabilities and uses the latest secure versions of all dependencies.
License
MIT © Rachma Azis
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
- 🐛 Bug reports: GitHub Issues
- 💬 Questions: GitHub Discussions
- 📧 Original author: razisek.com
- 🔧 Fork maintainer: @agungjsp
