mongolian-payment-monpay
MonPay payment gateway SDK for Python. Supports both QR and Deeplink payment flows with synchronous and asynchronous clients.
Installation
pip install mongolian-payment-monpay
QR Payments
Sync
from mongolian_payment_monpay import MonPayQrClient, MonPayQrConfig
client = MonPayQrClient(MonPayQrConfig(
endpoint="https://api.monpay.mn",
username="my-username",
account_id="my-account-id",
callback_url="https://example.com/callback",
))
# Generate a QR code
qr = client.generate_qr(5000)
print(qr.result.qrcode) # base64 QR image
print(qr.result.uuid) # unique payment ID
# Check payment status
status = client.check_qr(qr.result.uuid)
print(status.result.transaction_id)
# Parse a callback URL
callback = MonPayQrClient.parse_callback(
"https://example.com/callback?amount=5000&uuid=abc&status=paid&tnxId=txn-1"
)
print(callback.amount, callback.status)
Async
import asyncio
from mongolian_payment_monpay import AsyncMonPayQrClient, MonPayQrConfig
async def main():
async with AsyncMonPayQrClient(MonPayQrConfig(
endpoint="https://api.monpay.mn",
username="my-username",
account_id="my-account-id",
callback_url="https://example.com/callback",
)) as client:
qr = await client.generate_qr(5000)
print(qr.result.qrcode)
asyncio.run(main())
Deeplink Payments
Sync
from mongolian_payment_monpay import MonPayDeeplinkClient, MonPayDeeplinkConfig
client = MonPayDeeplinkClient(MonPayDeeplinkConfig(
endpoint="https://api.monpay.mn",
client_id="my-client-id",
client_secret="my-client-secret",
grant_type="client_credentials",
webhook_url="https://example.com/webhook",
redirect_url="https://example.com/redirect",
))
# Create a deeplink invoice (authenticates automatically)
invoice = client.create_deeplink(
amount=5000,
invoice_type="P2B",
branch_username="branch1",
description="Order #123",
)
print(invoice.result.id)
print(invoice.result.status)
# Check invoice status
status = client.check_invoice(invoice.result.id)
print(status.result.status)
# Parse a callback URL
callback = MonPayDeeplinkClient.parse_callback(
"https://example.com/webhook?amount=5000&invoiceId=123&status=paid&tnxId=txn-1&info=ok"
)
print(callback.amount, callback.invoice_id, callback.status)
Async
import asyncio
from mongolian_payment_monpay import AsyncMonPayDeeplinkClient, MonPayDeeplinkConfig
async def main():
async with AsyncMonPayDeeplinkClient(MonPayDeeplinkConfig(
endpoint="https://api.monpay.mn",
client_id="my-client-id",
client_secret="my-client-secret",
grant_type="client_credentials",
webhook_url="https://example.com/webhook",
redirect_url="https://example.com/redirect",
)) as client:
invoice = await client.create_deeplink(5000, "P2B", "branch1", "Order #123")
print(invoice.result.id)
asyncio.run(main())
Environment Variables
You can load configuration from environment variables:
from mongolian_payment_monpay import (
MonPayQrClient,
MonPayDeeplinkClient,
load_qr_config_from_env,
load_deeplink_config_from_env,
)
# QR: reads MONPAY_ENDPOINT, MONPAY_USERNAME, MONPAY_ACCOUNT_ID, MONPAY_CALLBACK_URL
qr_client = MonPayQrClient(load_qr_config_from_env())
# Deeplink: reads MONPAY_ENDPOINT, MONPAY_CLIENT_ID, MONPAY_CLIENT_SECRET,
# MONPAY_GRANT_TYPE, MONPAY_WEBHOOK_URL, MONPAY_REDIRECT_URL
dl_client = MonPayDeeplinkClient(load_deeplink_config_from_env())
License
MIT
Metadata
Release files for mongolian-payment-monpay 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_monpay-1.0.0.tar.gz | 10.5 kB | Without provenance | Details for mongolian_payment_monpay-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongolian_payment_monpay-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for mongolian_payment_monpay-1.0.0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / mongolian_payment_monpay-1.0.0.tar.gz
| Download URL | mongolian_payment_monpay-1.0.0.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7813e12e4583c09766454d0e0cde3e24442fbfef6096bc9bdbbe52efd0c546f
|
|
BLAKE2b-256 checksum How to use checksums |
67b4a4a3890b999bc5e0780d30c9c0e0f65f532a6ea34efcd3df9c60b17bfd3f
|
| 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_monpay-1.0.0-py3-none-any.whl
| Download URL | mongolian_payment_monpay-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6985f3417409ef2ce571a7d7b27984154b9901db07d03a6290babe22cd0e502
|
|
BLAKE2b-256 checksum How to use checksums |
0b787b260bd032345fe1e968171994f2d33d5ae6de4b812beed92026500713c2
|
| 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-monpay 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.