Skip to main content

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

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.2.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.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: promptpay_qr-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 3a6ee1188aadfb75a0f25a1207726bbd1229e19f89900baa0f0f1676a0ec6729
MD5 eb65b8a0677d5b8bfd7e5e36109a3bcd
BLAKE2b-256 2ada0587adca2b56dbe4122825b6357bb87c09718183790c8636a4921fe6e437

See more details on using hashes here.

File details

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

File metadata

  • Download URL: promptpay_qr-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5370abead99acf6b9a3c8ba20c612a1456f4c18da4d01a182090b73849e98396
MD5 3b2a3f990ed9085d68f77e6dfc811941
BLAKE2b-256 469ed61f815e19e6ec4b1713e8c38c912c08a695fb2d59eed3cf87182e63ef59

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