A Python tool for generating SCB MaeManee QR Codes.
- Python 3.9 or higher (tested on Python 3.9, 3.10, and 3.11)
-
Clone this repository:
git clone https://github.com/TamRaiDee/PyThaiPaymentQR.git cd PyThaiPaymentQR
-
Install the required dependencies:
pip install -r requirements.txt
Below is a simple example that generates a MaeManee QR code string.
from PyThaiPaymentQR import MaeManeeQR
# from PyThaiPaymentQR import KShopQR
# Your Shop ID from the MaeManee App
shopID = '014000000820910'
# A reference message to include in the transaction details
ref = 'TamRaiDeeTestQR'
# Create the PaymentQR object
qr_obj = MaeManeeQR(shopID, ref)
# Set the amount for the QR Code payment
qr_obj.setAmount(168.88)
# Print the QR code content (can be used with QR code generators)
print(qr_obj)
See the example.py file for a more detailed example.
python example.py|qrencode -o - -t ANSIUTF8
Tests are written using pytest. To run the test suite, simply execute:
pytest
This repository uses Black for code formatting and pre-commit to ensure code quality checks run automatically before each commit.
To set up pre-commit hooks:
-
Install
pre-commit
if you haven't already:pip install pre-commit
-
Install the hooks defined in
.pre-commit-config.yaml
:pre-commit install
From now on, when you run git commit
, Black and other checks will run automatically. If any formatting issues are found, they will be fixed, and you can commit again.
To format code manually:
black --line-length=100 --target-version=py311 .