/promptpay

Python library to generate PromptPay QR Code

Primary LanguagePythonMIT LicenseMIT

PromptPay

flake8 + pytest PyPI version fury.io License: MIT codecov

Python library to generate PromptPay QR Code, inspired from dtinth/promptpay-qr

Installation

pip install promptpay

# or
git clone https://github.com/jojoee/promptpay
cd promptpay
python setup.py install

Usage

Library

from promptpay import qrcode

# generate a payload
id_or_phone_number = "0841234567"
payload = qrcode.generate_payload(id_or_phone_number)
payload_with_amount = qrcode.generate_payload(id_or_phone_number, 1.23)

# export to PIL image
img = qrcode.to_image(payload)

# export to file
qrcode.to_file(payload, "./qrcode-0841234567.png")
qrcode.to_file(payload_with_amount, "/Users/joe/Downloads/qrcode-0841234567.png") 

CLI

python -m promptpay qrcode --id="0841234567"
python -m promptpay qrcode --id="0841234567" --file="./qrcode-cli.png"
python -m promptpay qrcode --id="0841234567" --show=true
python -m promptpay qrcode \
  --id="0841234567" \
  --amount=2.34 \
  --file="/Users/joe/Downloads/qrcode-cli-with-amount.png"

Reference