Skip to main content

Python SDK for ABA PayWay payment gateway (QR, Check, Close Transaction)

Project description

ABA Payway Python SDK

A clean, dependency-free Python SDK for the ABA PayWay payment gateway.

Python 3.10+ · No third-party dependencies · Stdlib only


Image Preview

ABA PayWay SDK


Quick Start

1. Install

pip install aba-payway

2. Configure

from aba_sdk import PayWayClient, PayWayConfig, Environment

config = PayWayConfig(
    merchant_id="your_merchant_id",
    api_key="your_api_key",
    env=Environment.sandbox,   # OR Environment.production
)
client = PayWayClient(config)

3. Generate a QR Code

from aba_sdk.models import QRRequest, Currency, PaymentOption
from aba_sdk.utils import encode_items, encode_url
from aba_sdk.utils.timestamp import get_req_time


request = QRRequest(
    tran_id=tran_id = f"ORDER-{get_req_time()}",
    amount=8.00,
    currency=Currency.USD,      # Supported KHR, USD
    payment_option=PaymentOption.ABAPAY_KHQR,
    first_name="Khon",
    last_name="Chanphearaa",
    email="phearaa@example.com",
    phone="012345678",

    # Optional
    items=encode_items([
        {"name": "Coffee", "quantity": 2, "price": 2.50},
        {"name": "Sandwich", "quantity": 1, "price": 3.00},
    ]),
    callback_url=encode_url("https://yoursite.com/payway/callback"),
    lifetime=6,
)

response = client.qr.generate_qr(request)

print(response.qr_string)           # Raw KHQR string
print(response.abapay_deeplink)     # Deep link for ABA Mobile
response.save_qr_image("qr.png")    # Save Base64 PNG to disk

Error Handling

from aba_sdk import PayWayAPIError, PayWayRequestError

try:
    response = client.qr.generate_qr(request)
except PayWayAPIError as e:

    # API returned an error (wrong domain, invalid hash, etc.)
    print(f"[{e.code}] {e.message}  trace={e.trace_id}")
except PayWayRequestError as e:

    # Network timeout or connection error
    print(f"Network error: {e}")

Enums Reference

Currency

Value Constant
USD Currency.USD
KHR Currency.KHR

PaymentOption

Value Constant Notes
abapay PaymentOption.ABAPAY
khqr PaymentOption.KHQR
abapay_khqr PaymentOption.ABAPAY_KHQR Most common
wechat PaymentOption.WECHAT USD only
alipay PaymentOption.ALIPAY USD only
abapay_khqr_wechat_alipay PaymentOption.ALL USD only

QRImageTemplate

TEMPLATE1, TEMPLATE1_COLOR, TEMPLATE2, TEMPLATE2_COLOR, TEMPLATE3, TEMPLATE3_COLOR


Extending the SDK

Each API group gets its own file in aba_sdk/api/ and its own models in aba_sdk/models/. Then register the new client in PayWayClient:

# aba_sdk/client.py
from .api.checkout import CheckoutClient   # new module

class PayWayClient:
    def __init__(self, config):
        self.qr = QRClient(config)
        self.checkout = CheckoutClient(config)   # add here

Scope Project Feature

  • Generate QRCode
  • Check Transaction
  • Close Transaction

Example How to Usages

Folder /examples

Run Python File

Environments

Environment Base URL
Sandbox https://checkout-sandbox.payway.com.kh
Production https://checkout.payway.com.kh

Note: Your IP/domain must be whitelisted by PayWay before production calls work. Contact paywaysales@ababank.com for production credentials.

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

aba_payway-0.1.2.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aba_payway-0.1.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aba_payway-0.1.2.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aba_payway-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f2973fb67fe07e4fe9f98a3dadb230e6fd035aa47c11e951ff4002b45847c3e4
MD5 329ee468d5d2b59a64caad194fe7afc9
BLAKE2b-256 e343bde02a2e216ac1e776b0cb6c83be3aad284c7f1ca9fcc5776d2892a07c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for aba_payway-0.1.2.tar.gz:

Publisher: publish.yml on Sourcedevkh/py-payway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: aba_payway-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aba_payway-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0d9c055197182b5c203345afebbd1d32567f4f636a250c822b0bd50f9196ec3c
MD5 edfbd4f0d4df8e71cfd6fdb8b637ffbc
BLAKE2b-256 8a9644d384e16a7fa4dc52b824593734d404bbd4da8acb825e65df0b5784f8c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for aba_payway-0.1.2-py3-none-any.whl:

Publisher: publish.yml on Sourcedevkh/py-payway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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