Skip to main content

APays API client for Python

Project description

apays

Python 3.8+ httpx pydantic v2

apays is an asynchronous Python client for the APays payment API. It provides methods to create payments, check status, and (optionally) poll until completion.

GitHub Repository

Quick start

import asyncio
from apays import APaysClient, APayError

async def main():
    client = APaysClient(client_id=123, secret_key="abc123")
    try:
        # Создаём платёж на сумму 45.67 (будет сконвертировано в 4567 копеек)
        resp = await client.create_order(45.67)
        print("Order ID:", resp.order_id)
        print("Payment URL:", resp.url)

        # Проверяем статус
        status = await client.get_order(resp.order_id)
        print("Current status:", status.order_status)
    except APayError as e:
        print("APays error:", e)
    finally:
        await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Polling example

import asyncio
from apays import APaysClient, APayError

async def main():
    client = APaysClient(client_id=123, secret_key="abc123")
    try:
        resp = await client.create_order(10.50)
        print("Order ID:", resp.order_id)

        # Ждём завершения платежа (проверяем каждые 5 секунд, максимум 2 минуты)
        final = await client.start_order_polling(
            order_id=resp.order_id,
            interval=5.0,
            timeout=120.0
        )
        print("Final status:", final.order_status)
    except APayError as e:
        print("APays error:", e)
    finally:
        await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Installation

Since apays isn’t on PyPI yet, you can install it directly from GitHub:

pip install git+https://github.com/Bezdarnost01/apays.git@main#egg=apays

License

MIT © Bezdarnost01

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

apays-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

apays-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file apays-0.1.0.tar.gz.

File metadata

  • Download URL: apays-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for apays-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29a518387f8df15d7e5a4ac401b93eb920331927b6a6178251e85c8aaaf82a01
MD5 a23e72f4be5e18f344ec309175d45aae
BLAKE2b-256 6850d240bdd476fa369dcd91f98ed502e55f4fcf46f3d119cd1d36b72290588f

See more details on using hashes here.

File details

Details for the file apays-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: apays-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for apays-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2757d28179b250db6ea31415b676f3d1158732e0f04d8ba9518d008991af065c
MD5 daa15803da02bdc4c3f48a5b4db1f8de
BLAKE2b-256 4fbe0efa01b65957b7dba2d356b857fa96461b98762e7302e3f6fb3318284431

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