mongolian-payment-qpay
QPay payment gateway SDK for Python. Supports both synchronous and asynchronous usage.
This is a Python port of the QPay JS SDK.
Installation
pip install mongolian-payment-qpay
Usage
Sync Client
from mongolian_payment_qpay import QPayClient, QPayConfig, CreateInvoiceInput
client = QPayClient(QPayConfig(
username="MY_USERNAME",
password="MY_PASSWORD",
endpoint="https://merchant.qpay.mn/v2",
callback="https://example.com/callback",
invoice_code="MY_INVOICE_CODE",
merchant_id="MY_MERCHANT_ID",
))
# Create an invoice
invoice = client.create_invoice(CreateInvoiceInput(
sender_code="SENDER",
sender_branch_code="BRANCH",
receiver_code="RECEIVER",
description="Test payment",
amount=1000,
))
print(invoice.invoice_id)
print(invoice.qr_text)
print(invoice.qpay_short_url)
# Check payment status
from mongolian_payment_qpay import CheckPaymentOptions
result = client.check_payment(CheckPaymentOptions(invoice_id=invoice.invoice_id))
print(f"Paid: {result.paid_amount}, Count: {result.count}")
for row in result.rows:
print(f" {row.payment_id}: {row.payment_status}")
# Get invoice details
details = client.get_invoice(invoice.invoice_id)
# Cancel an invoice
client.cancel_invoice(invoice.invoice_id)
# Refund a payment
client.refund_payment("payment_id")
Async Client
import asyncio
from mongolian_payment_qpay import AsyncQPayClient, QPayConfig, CreateInvoiceInput
async def main():
client = AsyncQPayClient(QPayConfig(
username="MY_USERNAME",
password="MY_PASSWORD",
endpoint="https://merchant.qpay.mn/v2",
callback="https://example.com/callback",
invoice_code="MY_INVOICE_CODE",
merchant_id="MY_MERCHANT_ID",
))
invoice = await client.create_invoice(CreateInvoiceInput(
sender_code="SENDER",
sender_branch_code="BRANCH",
receiver_code="RECEIVER",
description="Test payment",
amount=1000,
))
print(invoice.invoice_id)
asyncio.run(main())
Loading Config from Environment Variables
Set the following environment variables:
| Variable | Description |
|---|---|
QPAY_USERNAME |
QPay API username |
QPAY_PASSWORD |
QPay API password |
QPAY_ENDPOINT |
QPay API base URL (e.g. https://merchant.qpay.mn/v2) |
QPAY_CALLBACK |
Callback URL for payment notifications |
QPAY_INVOICE_CODE |
Invoice code assigned by QPay |
QPAY_MERCHANT_ID |
Merchant ID assigned by QPay |
Then load the config:
from mongolian_payment_qpay import QPayClient, load_config_from_env
config = load_config_from_env()
client = QPayClient(config)
API Reference
QPayClient / AsyncQPayClient
Both clients have identical method signatures. The async client uses async/await.
| Method | Description |
|---|---|
create_invoice(input_) |
Create a new invoice |
get_invoice(invoice_id) |
Get invoice details by ID |
cancel_invoice(invoice_id) |
Cancel an invoice by ID |
get_payment(payment_id) |
Get payment details by ID |
check_payment(options) |
Check payment status for an invoice |
cancel_payment(options) |
Cancel a payment |
refund_payment(payment_id) |
Refund a payment by ID |
License
MIT
Metadata
Release files for mongolian-payment-qpay 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mongolian_payment_qpay-1.0.0.tar.gz | 9.8 kB | Without provenance | Details for mongolian_payment_qpay-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongolian_payment_qpay-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for mongolian_payment_qpay-1.0.0-py3-none-any.whl |
Total release size: 20.0 kB
Release files / mongolian_payment_qpay-1.0.0.tar.gz
| Download URL | mongolian_payment_qpay-1.0.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d5b552737409fb6c39bc8aad2cea9c907caed07b104a361c96caf456e9a0f71
|
|
BLAKE2b-256 checksum How to use checksums |
86bb52c9ad627c10f33e70b3d5009f84d51356a7d999bdf1d49845eac412b6e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Release files / mongolian_payment_qpay-1.0.0-py3-none-any.whl
| Download URL | mongolian_payment_qpay-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed5374b9abac5115453ed9512bb6f9484d84eb64a4a121d0e3f5cfc231dd6c86
|
|
BLAKE2b-256 checksum How to use checksums |
15687e37a3d05c778ebf888d840b3fbcdb844cb24737f7ab15415b8067f08f6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Security for mongolian-payment-qpay 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.