qris-gen
A Rust library for generating dynamic QRIS (Quick Response Code Indonesian Standard) with custom amounts and QR code image generation.
Features
- ✅ Parse static QRIS code
- ✅ Convert static QRIS to dynamic QRIS
- ✅ Set custom transaction amount
- ✅ Generate QR code image (PNG format)
- ✅ Base64 encoding for QR code images
- ✅ Custom QR code size support
- ✅ CRC-16 checksum validation
- ✅ TLV (Tag-Length-Value) parsing
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Or use cargo add:
Usage
Basic Example
use ;
Generate QR Code Image
use ;
Complete Example
use ;
API Documentation
Qris
Main struct for handling QRIS operations.
Methods
from_static(qr: &str) -> Result<Self, QrisError>- Parse a static QRIS stringset_dynamic(self) -> Self- Convert to dynamic QRISamount(self, amount: u64) -> Result<Self, QrisError>- Set transaction amountbuild(self) -> String- Build the final QRIS string with CRC checksum
QR Code Generation
generate_qr_base64(data: &str) -> Result<String, QrisError>- Generate QR code with default sizegenerate_qr_base64_with_size(data: &str, size: u32) -> Result<String, QrisError>- Generate QR code with custom size
Error Handling
use QrisError;
match from_static
QRIS Standard
This library implements the QRIS (Quick Response Code Indonesian Standard) specification:
- Tag 01: Point of Initiation Method (11 = static, 12 = dynamic)
- Tag 54: Transaction Amount
- Tag 63: CRC-16 Checksum
Requirements
- Rust 1.56 or later
- Dependencies:
crc- For CRC-16 checksum calculationqrcode- For QR code generationimage- For image processingbase64- For base64 encodingthiserror- For error handling
Examples
Check the examples/ directory for more usage examples:
Testing
Run tests with:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- QRIS Standard by Bank Indonesia
- Indonesian payment ecosystem
Disclaimer
This library is for educational and development purposes. Make sure to comply with all relevant regulations and standards when implementing payment systems.
Made with ❤️ for Indonesian developers