A Python library to parse, modify, and generate SGQR (Singapore Quick Response) codes.
Project description
SGQR Generator: Singapore Bank Friendly
A Python package for parsing, modifying, and generating SGQR (Singapore Quick Response) codes.
SGQR is a unified payment QR code standard used in Singapore. It wraps various payment schemes (e.g. PayNow, NETS, GrabPay) using a Tag-Length-Value (TLV) encoding format. This library allows you to easily load an SGQR payload, update its fields (like transaction amount or payment reference), and generate a new, valid SGQR payload with a recomputed CRC16 checksum.
Installation
Install the package via pip or your favorite package manager:
pip install sgqrgen
Or with uv:
uv add sgqrgen
Quick Start
-
Using a Singapore Bank App (e.g. UOB TMRW), generate a MyQR code for payment
- For example, using UOB TMRW on the iPhone (updated as of 2026-06-15).
- Open and login to UOB TMRW app.
- Tap
Scan to pay. - On top top menu bar, choose
MR QR. - Scan the QR code generated using any QR Reader.
- Get the string
sgqr_str = "00020101021125280009SG.PAYNOW010100211+659876543203011530370254040.005802SG5913TAN AH GAO 63042968"
-
Create an instance of the
SgQRGeneratorclass with theinitial_string. -
Here is a simple example of how to parse an existing SGQR code, modify the price and comment, and output the updated QR code image:
from sgqrgen import SgQRGenerator # Initial SGQR string (e.g. PayNow merchant QR code) sgqr_str = "00020101021125280009SG.PAYNOW010100211+659876543203011530370254040.005802SG5913TAN AH GAO 63042968" # Initialize generator qr_gen = SgQRGenerator(sgqr_str) # Modify amount to $8.00 and set comment/reference to "membership" qr_gen.change_price(8.00).change_comment("membership") # Export updated QR code image qr_gen.output_qrcode("output-qrcode.png") # Get updated raw SGQR string payload print("Updated payload:", qr_gen.qr)
Features
- TLV Parsing: Easily decodes standard Tag-Length-Value SGQR payloads.
- Price Modification: Update the transaction amount dynamically (Tag 54) with automatic formatting.
- Comment/Reference Update: Add or update payment reference notes (Tag 62 / Sub-tag 01).
- CRC16 Verification: Automatic recomputation of the CRC16 checksum (Tag 63) when the payload is built/modified.
- High-Quality QR Image Generation: Utilizes
segnoto export QR codes in high-resolution scales.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sgqrgen-0.1.1.tar.gz.
File metadata
- Download URL: sgqrgen-0.1.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2262a36b3eb4412cc972a6bf9de0cc1de4839124daa49dc040854db3165dce9b
|
|
| MD5 |
637a6699fedfbaed0eef37ad076f8bd1
|
|
| BLAKE2b-256 |
797f0d5b8c9d28546265381ab72c8766fa8479d499fb77d27242016dcbaeaed9
|
File details
Details for the file sgqrgen-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sgqrgen-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
607abebfb997910b57ad744be0411d80c1fe9330d09ad1b3d4a4fd9bde2c46cc
|
|
| MD5 |
1c653dace8979400c3368e54aeb8ca3a
|
|
| BLAKE2b-256 |
51d3f425024d3f6f648e99520bfe45cd3f013a080736272c13587747903da591
|