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('0910783112')
payload = generate_payload('0910783112', amount=4.22)

# Save QR image to file
generate_qr_image('0910783112', filename='qr.png')
generate_qr_image('0910783112', amount=100.0, filename='qr_100.png')

# Get a PIL.Image object (e.g. to display in a notebook)
img = generate_qr_image('0910783112', amount=50.0)
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 0910783112
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.0.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.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: promptpay_qr-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ec970caee6cf293fa6c9c0cc340934a517e44c701b981910834bdc5b8dba7068
MD5 6330a84c9b414b5fa926e6c5b0d78503
BLAKE2b-256 e00b8d98ecdf29b7e5aedd22a8338cff512b5571e8a03792b691d0f9b01017de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: promptpay_qr-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d83060df33d01d6458c4410c5ad5d7e6244b2bd2bff7e817dab7be0b11922955
MD5 0cfe14d428a9ae3e1082570f5acf97fa
BLAKE2b-256 9e76f08e518365d8ce75e351b7af2850f1b0c6c4a78d9bcc7099ede06495e800

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