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
Metadata
Release files for promptpay-qr 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptpay_qr-0.1.2.tar.gz | 4.0 kB | Without provenance | Details for promptpay_qr-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptpay_qr-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for promptpay_qr-0.1.2-py3-none-any.whl |
Total release size: 8.9 kB
Release files / promptpay_qr-0.1.2.tar.gz
| Download URL | promptpay_qr-0.1.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a6ee1188aadfb75a0f25a1207726bbd1229e19f89900baa0f0f1676a0ec6729
|
|
BLAKE2b-256 checksum How to use checksums |
2ada0587adca2b56dbe4122825b6357bb87c09718183790c8636a4921fe6e437
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / promptpay_qr-0.1.2-py3-none-any.whl
| Download URL | promptpay_qr-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5370abead99acf6b9a3c8ba20c612a1456f4c18da4d01a182090b73849e98396
|
|
BLAKE2b-256 checksum How to use checksums |
469ed61f815e19e6ec4b1713e8c38c912c08a695fb2d59eed3cf87182e63ef59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for promptpay-qr 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.