Khan Bank payment gateway SDK for Python
Project description
mongolian-payment-khanbank
Khan Bank payment gateway SDK for Python. Supports both synchronous and asynchronous usage.
Installation
pip install mongolian-payment-khanbank
Usage
Synchronous
from mongolian_payment_khanbank import KhanBankClient, KhanBankConfig, OrderRegisterInput
client = KhanBankClient(KhanBankConfig(
endpoint="https://ecommerce.khanbank.com/payment/rest",
username="your_username",
password="your_password",
))
# Register a new order
result = client.register_order(OrderRegisterInput(
order_number="ORD-001",
amount=50000,
success_callback="https://example.com/success",
fail_callback="https://example.com/fail",
))
print(result.order_id) # Bank-assigned order ID
print(result.form_url) # Redirect user to this URL
# Check order status
status = client.check_order(result.order_id)
print(status.success) # True if payment succeeded
print(status.error_code)
print(status.error_message)
Asynchronous
import asyncio
from mongolian_payment_khanbank import AsyncKhanBankClient, KhanBankConfig, OrderRegisterInput
async def main():
async with AsyncKhanBankClient(KhanBankConfig(
endpoint="https://ecommerce.khanbank.com/payment/rest",
username="your_username",
password="your_password",
)) as client:
result = await client.register_order(OrderRegisterInput(
order_number="ORD-001",
amount=50000,
success_callback="https://example.com/success",
fail_callback="https://example.com/fail",
))
status = await client.check_order(result.order_id)
print(status.success)
asyncio.run(main())
Configuration from Environment Variables
from mongolian_payment_khanbank import KhanBankClient, load_config_from_env
client = KhanBankClient(load_config_from_env())
Required environment variables:
| Variable | Description |
|---|---|
KHANBANK_ENDPOINT |
Khan Bank API base URL |
KHANBANK_USERNAME |
API username |
KHANBANK_PASSWORD |
API password |
Optional environment variables:
| Variable | Description | Default |
|---|---|---|
KHANBANK_LANGUAGE |
Language code (mn or en) |
mn |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongolian_payment_khanbank-1.0.0.tar.gz.
File metadata
- Download URL: mongolian_payment_khanbank-1.0.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2275efe5fa4791150f07109ad43a51d7f0b24e70f9659dc1b750b3770a0ad45f
|
|
| MD5 |
f9a2f8862fe92b1496b5f094f235ebcf
|
|
| BLAKE2b-256 |
438722e1e63c95a150059e3ed1e41650a0a650cfed1bff9ec0f9c2db6c5137a3
|
File details
Details for the file mongolian_payment_khanbank-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mongolian_payment_khanbank-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce58d2be474d0b8150438208980deb2d43d829f47966c7911824b2c0ae1abf1b
|
|
| MD5 |
3cc49e800ae7848797169b72adb09435
|
|
| BLAKE2b-256 |
8bf8f4d0bd4d1a21f7b701b04acffdeca082e43bbb7b31de54f513b3bde6c5d1
|