Skip to main content

Generate PromptPay QR code payloads and images (EMV QRCPS compliant)

Reason this release was yanked:

broken

Project description

promptpay-qr

A minimal Python library for generating PromptPay QR code payloads and images, compliant with the EMV QRCPS Merchant Presented Mode specification.

Features

  • Generate PromptPay QR payload strings from a phone number, national/tax ID, or e-Wallet ID
  • Optionally embed a pre-filled transfer amount
  • Render the payload as a PNG image (requires qrcode[pil])
  • Zero required dependencies for payload-only generation

Installation

pip install promptpay-qr

To also generate QR images:

pip install "promptpay-qr[image]"
# or manually:
pip install qrcode[pil]

Quick start

from promptpay_qr import generate_payload, generate_qr_image

# Payload only
payload = generate_payload('091xxxxxxx')
payload = generate_payload('091xxxxxxx', amount=67.67)

# Save QR image to file
generate_qr_image('091xxxxxxx', filename='qr.png')
generate_qr_image('091xxxxxxx', amount=67.67, filename='qr_100.png')

# Get a PIL.Image object (e.g. to display in a notebook)
img = generate_qr_image('091xxxxxxx', amount=67.67)
img.show()

API

generate_payload(target, amount=None) -> str

Generates the raw PromptPay QR payload string.

Parameter Type Description
target str PromptPay ID — phone number (10 digits), national/tax ID (13 digits), or e-Wallet ID (15+ digits). Dashes and spaces are stripped automatically.
amount float | None Transfer amount in THB. When provided, banking apps pre-fill the amount field.

Returns a str that can be encoded as any standard QR code.


generate_qr_image(target, amount=None, filename=None, size=300)

Generates a PromptPay QR code image.

Parameter Type Description
target str PromptPay ID (same rules as above).
amount float | None Optional amount in THB.
filename str | None Path to save the image (PNG recommended). If None, returns a PIL.Image instead.
size int Output image size in pixels (default 300).

Returns PIL.Image when filename is None, otherwise saves the file and returns None.

Requires qrcode[pil] — raises ImportError with installation instructions if missing.

Supported PromptPay ID types

Type Digits Example
Phone number 10 091xxxxxxx
National / tax ID 13 1234567890123
e-Wallet ID 15+ 004999000288505

Leading 0 in phone numbers is automatically converted to the +66 country prefix per the PromptPay spec.

Specification

Built on the EMV QRCPS Merchant Presented Mode specification and the Bank of Thailand PromptPay standard.

License

MIT

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

promptpay_qr-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

promptpay_qr-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file promptpay_qr-0.1.1.tar.gz.

File metadata

  • Download URL: promptpay_qr-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for promptpay_qr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 281eb2c6a1cac75c4f94d77edf5f2d944523c11121af9445b8ecd254861bd986
MD5 c581fa14170b0f8021bc178797357b3c
BLAKE2b-256 a26971117f2f552800607d5665cc9c212bccd6ba1b3d0430fb600b92ffc3927b

See more details on using hashes here.

File details

Details for the file promptpay_qr-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: promptpay_qr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for promptpay_qr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9362785b32bbc8ba8e62157da65855a0c6484cc638d531ce9d0743184c0cb716
MD5 618d193b3dd88042de066655e9c1ea07
BLAKE2b-256 73f371f37d17f4a369ef91ac226f4ed0d7bcb0287a184af5da12c96dc7cff9aa

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