Skip to main content

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 code
  • response -- 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)

Source distribution for mongolian-payment-socialpay 1.0.0
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)

Table of built distributions (wheels) for mongolian-payment-socialpay 1.0.0
File Interpreter ABI Platform Actions
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

Release files / mongolian_payment_socialpay-1.0.0.tar.gz

Download URL mongolian_payment_socialpay-1.0.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e7321ea487cc48f9129a1821ed7ed604b3e27ce6e977e1cb07b0412014c317d9
BLAKE2b-256 checksum
How to use checksums
9efbd0634d6368bb8731adbbbd55f3b00166fdfd1e0bb6abe706b114a984a8de
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_socialpay-1.0.0-py3-none-any.whl

Download URL mongolian_payment_socialpay-1.0.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f498bd83f83e83dc1bf9b822a0b5ee58a108dc7c3f1c92196a4238e150d183b2
BLAKE2b-256 checksum
How to use checksums
530db4e6005e228bc283d3ab5b928db1212b116ed9e5e5aa6c84d41cb578e991
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-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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page