Skip to main content

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

  1. Using a Singapore Bank App (e.g. UOB TMRW), generate a MyQR code for payment

    1. For example, using UOB TMRW on the iPhone (updated as of 2026-06-15).
    2. Open and login to UOB TMRW app.
    3. Tap Scan to pay.
    4. On top top menu bar, choose MR QR.
    5. Scan the QR code generated using any QR Reader.
    6. Get the string sgqr_str = "00020101021125280009SG.PAYNOW010100211+659876543203011530370254040.005802SG5913TAN AH GAO 63042968"
  2. Create an instance of the SgQRGenerator class with the initial_string.

  3. 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 decimal import Decimal
    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(Decimal("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 segno to export QR codes in high-resolution scales.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sgqrgen-0.1.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sgqrgen-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file sgqrgen-0.1.2.tar.gz.

File metadata

  • Download URL: sgqrgen-0.1.2.tar.gz
  • Upload date:
  • Size: 15.1 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

Hashes for sgqrgen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 629d00e057bea132b46ecf85750dcf3feed279a9b9bb204a080a806b2ad29b11
MD5 d883eafff10b2e8a760f5f9a962a240b
BLAKE2b-256 e06b5f774aeed98af5b914975d50fa8cca9f6a4330e64de47337b43f1cc99716

See more details on using hashes here.

File details

Details for the file sgqrgen-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sgqrgen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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

Hashes for sgqrgen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df19228e4ebf0968d99f0776567826d01cc4deb1c7945e71e27d02184646044a
MD5 1962badb649dfd413e465f7412d07df0
BLAKE2b-256 f776815f11e451f0c925fdb3034e2e2e7bf66c3ac7f375e3a2796208cc543037

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page