monapay
MONA Pay là cổng thanh toán và API ngân hàng của The MONA Group, giúp doanh nghiệp Việt Nam nhận và xác nhận tiền chuyển khoản theo thời gian thực qua tài khoản ảo (VA), VietQR, webhook và Telegram — thiết kế để cả lập trình viên lẫn AI agent tích hợp trong vài phút.
SDK Python đồng bộ, chỉ dùng standard library. MONA Pay miễn phí hoàn toàn.
Cài đặt
pip install monapay
Bắt đầu nhanh
import os
from monapay import MonaPay
mona = MonaPay(
os.environ["MONA_USERNAME"],
os.environ["MONA_PASSWORD"],
client_secret=os.getenv("MONA_CLIENT_SECRET"),
)
# Tự login và giữ token.
print(mona.me())
# Lần đầu: secret chỉ hiện một lần. SDK giữ key mới cho instance hiện tại.
key = mona.keys.generate("Web ban hang")
print("Lưu MONA_CLIENT_SECRET an toàn:", key["client_secret"])
mona.webhooks.create({
"name": "Web ban hang",
"webhook_url": "https://shop.vn/webhooks/monapay",
"auth_type": "HMAC_SHA256",
"secret_key": os.environ["MONA_WEBHOOK_SECRET"],
"payload_format": "application/json",
})
qr = mona.qr.generate({
"ownerNumber": "123456789", "ownerType": "ORG",
"merchantId": "MC00012345", "terminalId": "TM0001", "orderId": "DH10234",
"virtualAccountPrefix": "MONA", "beneficiaryName": "CONG TY ABC",
"amount": 2500000, "description": "Thanh toan DH10234",
})
print(qr["qr_data_url"])
Client tự login lại và thử request đúng một lần khi gặp HTTP 401. Các method trả trực tiếp trường data; ApiError có status và body.
Các nhóm method: keys, va, bank_accounts, qr, transactions, webhooks, webhook_logs. Tên method dùng snake_case, ví dụ va.register_notification(...) và transactions.retry(id, target_type="WEBHOOK", target_id=...).
Đọc hết các trang giao dịch:
for tx in mona.iter_transactions("MONA0000010234", limit=100):
print(tx["transaction_code"], tx["amount"])
Xác thực webhook
Luôn truyền đúng request.body dạng bytes, không parse rồi encode lại.
from monapay import verify_webhook
result = verify_webhook(raw_body, headers, os.environ["MONA_WEBHOOK_SECRET"])
if not result.ok:
return {"reason": result.reason}, 401
save_once(result.payload["transaction_code"], result.payload)
Ví dụ nhận webhook cho Flask, FastAPI và Django nằm trong examples/. Dùng transaction_code làm unique key để chống xử lý trùng.
Tài liệu: https://monapay.vn/docs · AI/LLM: https://monapay.vn/llms.txt · Hotline 1900 636 648 · info@themona.global
Test
Từ thư mục chứa python/:
python3 -m unittest discover python/tests
License MIT.
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 monapay-0.1.0.tar.gz.
File metadata
- Download URL: monapay-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eed3c5b1efe4db4559d333525b942ec49a58687b4b4887ac2aee7ff9f2274c2
|
|
| MD5 |
72478cc10edf6754eb2861460109bee2
|
|
| BLAKE2b-256 |
f7a9ece4aee7e89acfdaea2b3c34c79e412a2666667ba9a7c325cd97d66dcf73
|
File details
Details for the file monapay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: monapay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57c28c71063c2ec70081a09cdb30d2776591875dc237973b55c10332c71ce18a
|
|
| MD5 |
65d39d82ec84426925ddc66e1d9d78fa
|
|
| BLAKE2b-256 |
4aa0f9694f46310ad6cf19c24a9f17985048530b8d501e44470e8cb9e8225584
|