Skip to content

Thai Payment QR generator in Python for SCB MaeManee and K-Shop.

License

Notifications You must be signed in to change notification settings

TamRaiDee/PyThaiPaymentQR

Repository files navigation

PyThaiPaymentQR

A Python tool for generating SCB MaeManee QR Codes.

Requirements

  • Python 3.9 or higher (tested on Python 3.9, 3.10, and 3.11)

Installation

  1. Clone this repository:

    git clone https://github.com/TamRaiDee/PyThaiPaymentQR.git
    cd PyThaiPaymentQR
  2. Install the required dependencies:

    pip install -r requirements.txt

Usage

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)

Example

See the example.py file for a more detailed example.

python example.py|qrencode -o - -t ANSIUTF8

Example QR Code

Testing

Tests are written using pytest. To run the test suite, simply execute:

pytest

Code Formatting and Pre-Commit Hooks

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:

  1. Install pre-commit if you haven't already:

    pip install pre-commit
  2. 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 .

License

The MIT License

About

Thai Payment QR generator in Python for SCB MaeManee and K-Shop.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages