mongolian-payment-socialpay
SocialPay payment gateway SDK for Python.
Provides both synchronous and asynchronous clients with automatic HMAC-SHA256 checksum generation.
Installation
pip install mongolian-payment-socialpay
Quick start
Synchronous usage
from mongolian_payment_socialpay import SocialPayClient, SocialPayConfig
config = SocialPayConfig(
terminal="YOUR_TERMINAL",
secret="YOUR_SECRET",
endpoint="https://api.socialpay.mn",
)
with SocialPayClient(config) as client:
# Create an invoice with phone notification
result = client.invoice_phone(amount=5000, invoice="INV001", phone="99001234")
print(result.description, result.status)
# Create an invoice with QR code
qr = client.invoice_qr(amount=3000, invoice="INV002")
# Check a transaction
txn = client.check_transaction(amount=5000, invoice="INV001")
print(txn.approval_code, txn.response_code)
# Cancel an invoice
client.cancel_invoice(amount=5000, invoice="INV001")
# Cancel a transaction
client.cancel_transaction(amount=5000, invoice="INV001")
# Settle transactions
settlement = client.transaction_settlement(settlement_id="SETTLE001")
print(settlement.amount, settlement.count)
Asynchronous usage
import asyncio
from mongolian_payment_socialpay import AsyncSocialPayClient, SocialPayConfig
config = SocialPayConfig(
terminal="YOUR_TERMINAL",
secret="YOUR_SECRET",
endpoint="https://api.socialpay.mn",
)
async def main():
async with AsyncSocialPayClient(config) as client:
result = await client.invoice_phone(amount=5000, invoice="INV001", phone="99001234")
print(result.description, result.status)
asyncio.run(main())
Configuration from environment variables
Set the following environment variables:
export SOCIALPAY_TERMINAL="YOUR_TERMINAL"
export SOCIALPAY_SECRET="YOUR_SECRET"
export SOCIALPAY_ENDPOINT="https://api.socialpay.mn"
Then load them:
from mongolian_payment_socialpay import SocialPayClient, load_config_from_env
config = load_config_from_env()
client = SocialPayClient(config)
Error handling
All API errors raise SocialPayError, which includes:
status_code-- the HTTP or SocialPay-level error coderesponse-- the raw response body, if available
from mongolian_payment_socialpay import SocialPayError
try:
client.invoice_qr(amount=1000, invoice="INV999")
except SocialPayError as e:
print(e.status_code, e.response)
License
MIT
Metadata
Release files for mongolian-payment-socialpay 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_socialpay-1.0.0.tar.gz | 7.4 kB | Without provenance | Details for mongolian_payment_socialpay-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongolian_payment_socialpay-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for mongolian_payment_socialpay-1.0.0-py3-none-any.whl |
Total release size: 14.9 kB
Security for mongolian-payment-socialpay 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.