Skip to main content

Official Python SDK for OxaPay — accept crypto payments, exchanges, and payouts.

Project description

OxaPay Python SDK

Official Python SDK for OxaPay — accept crypto payments, exchanges, and payouts.

Python: 3.8+
Docs: https://docs.oxapay.com

Installation

pip install oxapay-python

Quick start

from oxapay_python import OxaPayManager

oxapay = OxaPayManager(timeout=10)
res = (
    oxapay
    .payment("XXXXXX-XXXXXX-XXXXXX-XXXXXX")
    .generate_invoice({
        "amount": 10.5,
        "currency": "USDT",
    })
)

print(res)

Handling Webhooks (Payments & Payouts)

OxaPay sends HMAC header (sha512 over raw request body).

from oxapay_python import OxaPayManager
from oxapay_python.exceptions import WebhookSignatureException

raw_body = request.get_data(as_text=True)  # Flask example
headers = dict(request.headers)            # Flask example

oxapay = OxaPayManager()

# Merchant webhook
try:
    data = oxapay.webhook(merchant_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX", raw_body=raw_body, headers=headers).get_data()
except WebhookSignatureException:
    pass

# Payout webhook
try:
    data = oxapay.webhook(payout_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX", raw_body=raw_body, headers=headers).get_data()
except WebhookSignatureException:
    pass

# Both
try:
    data = oxapay.webhook(
        merchant_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX",
        payout_api_key="XXXXXX-XXXXXX-XXXXXX-XXXXXX",
        raw_body=raw_body,
        headers=headers,
    ).get_data()
except WebhookSignatureException:
    pass

# Or skip verification
data = oxapay.webhook(raw_body=raw_body, headers=headers).get_data(verify=False)

Available methods

🔹payment

  • generate_invoice – Create invoice & get payment URL. More details
  • generate_white_label – White-label payment. More details
  • generate_static_address – Create static deposit address. More details
  • revoke_static_address – Revoke static address. More details
  • static_address_list – List static addresses. More details
  • information – Single payment information. More details
  • history – Payment history list. More details
  • accepted_currencies – Accepted currencies. More details

🔹account

🔹payout

🔹exchange

🔹common

🔹webhook

  • verify – Validates HMAC header (sha512 of raw body).
  • get_data – Validates HMAC header and return webhook data. More details

Raw responses

By default, endpoints return the unwrapped data field. To receive the full API response (data, status, message, error, version), enable raw mode:

from oxapay_python import OxaPayManager

sdk = OxaPayManager(timeout=20, raw=True)
res = sdk.payment("MERCHANT_API_KEY").generate_invoice({"amount": 1, "currency": "USDT"})
print(res["data"])  # unwrap manually

Exceptions

All SDK exceptions extend oxapay.exceptions.OxaPayException:

  • ValidationRequestException (HTTP 400)
  • InvalidApiKeyException (HTTP 401)
  • NotFoundException (HTTP 404)
  • RateLimitException (HTTP 429)
  • ServerErrorException (HTTP 500)
  • ServiceUnavailableException (HTTP 503)
  • HttpException (network/unknown)
  • MissingApiKeyException (missing api key)
  • MissingTrackIdException (missing track id)
  • MissingAddressException (missing address)
  • WebhookSignatureException (bad/missing HMAC)
  • WebhookNotReceivedException (webhook request was not received)

Security Notes

  • Verify webhook HMAC before use input data.
  • Whitelist OxaPay IPs on your firewall (ask support).
  • Use HTTPS everywhere.
  • Store keys in .env, not code.
  • Rotate keys regularly.

Testing (safe & offline)

This package uses pytest and responses for testing.

pip install -e ".[dev]"
pytest

Compatibility

  • Python 3.8+

Security

If you discover a security vulnerability, please email contact@oxapay.com. Do not disclose publicly until it has been fixed.

Contributing

Pull requests are welcome. For major changes, open an issue first.

pip install -e ".[dev]"
ruff check .
pytest

License

Apache-2.0 — see LICENSE.

Changelog

See CHANGELOG.md for version history.


OxaPay Made with ♥ for Python.

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

oxapay_python-1.1.0.tar.gz (43.4 kB view details)

Uploaded Source

Built Distribution

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

oxapay_python-1.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file oxapay_python-1.1.0.tar.gz.

File metadata

  • Download URL: oxapay_python-1.1.0.tar.gz
  • Upload date:
  • Size: 43.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for oxapay_python-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9ba99caca4b2c22629854e51a108193f4ad04c4f7aa68e4763660963ee021024
MD5 8bac9053804559f452105d83682fd6c8
BLAKE2b-256 fa9de12f1fd44a15d2d6ac23f388ac5728b8449140e1ee7b0e9d206ebcf8eb47

See more details on using hashes here.

File details

Details for the file oxapay_python-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: oxapay_python-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for oxapay_python-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ded534de57c4ebd48aa942fd890992f202a917e71d36ffc5d1857a23e5683ea6
MD5 be71d2c8fd8352cf05a855f822141341
BLAKE2b-256 9dd3314955171637dd1eb083266fa01a05a246d1196f216a53f723efd390bb7c

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