Pass payment gateway SDK for Python
Project description
mongolian-payment-pass
Pass payment gateway SDK for Python. Supports both synchronous and asynchronous usage.
Installation
pip install mongolian-payment-pass
Usage
Synchronous
from mongolian_payment_pass import PassClient, PassConfig
client = PassClient(PassConfig(
endpoint="https://api.pass.mn",
ecommerce_token="your_token",
callback="https://example.com/callback",
))
# Create a new order (amount is multiplied by 100 automatically)
result = client.create_order(1500)
print(result.order_id)
print(result.shop)
# Create order with callback query params
result = client.create_order(1500, callback_params={"ref": "order-123"})
# Check order status
status = client.inquiry_order(result.order_id)
print(status.status) # "paid", "pending", "cancelled", "voided"
print(status.resp_code)
# Notify a phone number about an order
client.notify_order(result.order_id, "99112233")
# Cancel an order
client.cancel_order(result.order_id)
# Void an order
client.void_order(result.order_id)
Asynchronous
import asyncio
from mongolian_payment_pass import AsyncPassClient, PassConfig
async def main():
async with AsyncPassClient(PassConfig(
endpoint="https://api.pass.mn",
ecommerce_token="your_token",
callback="https://example.com/callback",
)) as client:
result = await client.create_order(1500)
status = await client.inquiry_order(result.order_id)
print(status.status)
asyncio.run(main())
Webhook Parsing
from mongolian_payment_pass import PassClient
# Parse incoming webhook payload (works as a static method)
webhook = PassClient.parse_webhook(request_body)
print(webhook.order_id)
print(webhook.operation) # "payment" or "void"
print(webhook.is_success)
Configuration from Environment Variables
from mongolian_payment_pass import PassClient, load_config_from_env
client = PassClient(load_config_from_env())
Required environment variables:
| Variable | Description |
|---|---|
PASS_ENDPOINT |
Pass API base URL |
PASS_ECOMMERCE_TOKEN |
E-commerce token for authentication |
PASS_CALLBACK |
Callback URL for order notifications |
Status Constants
from mongolian_payment_pass import (
OrderInquiryStatusPaid, # "paid"
OrderInquiryStatusPending, # "pending"
OrderInquiryStatusCancelled, # "cancelled"
OrderInquiryStatusVoided, # "voided"
WebhookOperationPayment, # "payment"
WebhookOperationVoid, # "void"
)
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_pass-1.0.0.tar.gz.
File metadata
- Download URL: mongolian_payment_pass-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
121b1f2abf30a19b88a889eae91a1e3eee56e9b896efbad75dbc0188c01178c5
|
|
| MD5 |
1becb7cdd27dbc065666c09a97406653
|
|
| BLAKE2b-256 |
3db4b3b88548dcd0603ab7fe87a6b004d74915cd847ada56bfdece301d81681b
|
File details
Details for the file mongolian_payment_pass-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mongolian_payment_pass-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
743c1c0e96db9816ee5c4a9bcf6c0c263332358278a16de3bbc9df971ad8ab26
|
|
| MD5 |
ebef84f1326f508bba79bcaadb1931ff
|
|
| BLAKE2b-256 |
f69b7615f1a0cf79c9accd946a239d6bf3e5e7bea8e20aecdcde65735179739c
|