Skip to main content

Bonum PSP payment gateway SDK for Python

Project description

mongolian-payment-bonum

Bonum PSP payment gateway SDK for Python. Supports both synchronous and asynchronous usage.

Installation

pip install mongolian-payment-bonum

Usage

Synchronous

from mongolian_payment_bonum import BonumClient, BonumConfig, ProcessPaymentInput

client = BonumClient(BonumConfig(
    endpoint="https://psp.bonum.mn",
    merchant_key="your-merchant-key",
))

# Process a payment (Apple Pay / card token)
result = client.process_payment(ProcessPaymentInput(
    token="payment-token-from-authorization",
    order_id="ORDER-001",
))

print(result.success)      # True/False
print(result.status_code)  # e.g. "000"
print(result.order_id)     # "ORDER-001"
print(result.desc)         # Description

# Process a Google Pay payment
from mongolian_payment_bonum import ProcessGooglePayInput

gpay_result = client.process_google_pay(ProcessGooglePayInput(
    token="encrypted-gpay-token",
    order_id="ORDER-002",
    amount=50000,
    currency_code="MNT",
))

# Validate merchant for Apple Pay
from mongolian_payment_bonum import MerchantValidateInput

session = client.validate_merchant(MerchantValidateInput(
    validation_url="https://apple-pay-gateway.apple.com/paymentservices/startSession",
))

# Check payment log
logs = client.get_payment_log("ORDER-001")
for entry in logs:
    print(entry.merchant_order_id, entry.amount, entry.success, entry.created_at)

Asynchronous

import asyncio
from mongolian_payment_bonum import AsyncBonumClient, BonumConfig, ProcessPaymentInput

async def main():
    async with AsyncBonumClient(BonumConfig(
        endpoint="https://psp.bonum.mn",
        merchant_key="your-merchant-key",
    )) as client:
        result = await client.process_payment(ProcessPaymentInput(
            token="payment-token",
            order_id="ORDER-001",
        ))
        print(result.success)

        logs = await client.get_payment_log("ORDER-001")
        print(logs)

asyncio.run(main())

Configuration from Environment Variables

from mongolian_payment_bonum import BonumClient, load_config_from_env

client = BonumClient(load_config_from_env())

Required environment variables:

Variable Description
BONUM_ENDPOINT Bonum PSP API base URL
BONUM_MERCHANT_KEY Merchant key from Bonum PSP

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongolian_payment_bonum-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongolian_payment_bonum-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file mongolian_payment_bonum-1.0.0.tar.gz.

File metadata

  • Download URL: mongolian_payment_bonum-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for mongolian_payment_bonum-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e832cb76579b03a1fe17d34ad7d8227c21c492c4250ac0b3a4fca32800f62dc8
MD5 72a5d09f2cb61837d732fa607fe6afcd
BLAKE2b-256 de9f22a5d30612d8d6988837d3ef377de2e34641d454de5c5416d0e87852a696

See more details on using hashes here.

File details

Details for the file mongolian_payment_bonum-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mongolian_payment_bonum-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 207ac492a91af797fa335ab6725710c6646bcbef642e498d9b5e870e50949f9d
MD5 c646c6ee3b73ecc8b64847a206cf7e56
BLAKE2b-256 af8a22bf0be12ce21ec978693634a21963735ee03376cb15614d6c5099458651

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page