Skip to main content

aioplatega

Modern, fully asynchronous SDK for the Platega payment API.

PyPI Python Downloads Tests License

Documentation · Getting started · API reference

Install

pip install aioplatega
uv add aioplatega

Requires Python 3.12 or newer.

Quick start

import asyncio

from aioplatega import PaymentDetails, PaymentMethodInt, Platega


async def main():
    async with Platega(merchant_id="your-id", secret="your-secret") as client:
        result = await client.create_transaction(
            payment_method=PaymentMethodInt.SBP_QR,
            payment_details=PaymentDetails(amount=100.0, currency="RUB"),
            description="Order #42",
        )
        print(result.redirect)


asyncio.run(main())

Send the payer to result.redirect, then wait for the callback.

from aioplatega import PaymentStatus
from aioplatega.exceptions import PlategaValidationError


@app.route("/callback", methods=["POST"])  # Flask
def callback():
    try:
        payload = client.verify_callback(request.headers, request.get_data())
    except PlategaValidationError:
        return "", 401

    if payload.status == PaymentStatus.CONFIRMED:
        mark_paid(payload.payload)
    return "", 200

[!IMPORTANT] Platega authenticates callbacks by echoing your own X-MerchantId and X-Secret back at you. There is no signature over the body, so the comparison is all that stands between you and a forged callback. verify_callback does it with hmac.compare_digest; if you roll your own, do the same.

What it covers

Payments Hosted links with or without a fixed method, H2H QR codes, status lookup
Subscriptions Recurring SBP charges, with callbacks for each charge and status change
Refunds Cancellation, and a check of whether it is possible and what it costs
Reporting Balances, conversions, CSV / Excel / JSON exports
Payouts RUB card payouts over the separate PG-HMAC signed API

Every endpoint is reachable two ways: a method on the client, or a method object dispatched through it.

from aioplatega.methods import CreateTransaction

result = await client(CreateTransaction(...))

See the API reference for the full surface.

Design

  • Fully asynchronous, built on aiohttp with a lazily created connection pool
  • Type safe. Pydantic v2 models throughout, complete annotations, mypy --strict clean
  • Immutable. Every model is frozen, and tolerant of unknown fields so a new attribute added server side does not break you
  • One exception hierarchy. Everything raised derives from PlategaError, including argument errors caught before a request goes out
PlategaError
├── PlategaAPIError
│   ├── PlategaBadRequestError          (400)
│   ├── PlategaUnauthorizedError        (401)
│   ├── PlategaForbiddenError           (403)
│   ├── PlategaNotFoundError            (404)
│   ├── PlategaConflictError            (409)
│   ├── PlategaUnprocessableEntityError (422)
│   ├── PlategaRateLimitError           (429)
│   └── PlategaServerError              (5xx)
├── PlategaNetworkError
├── PlategaValidationError
└── ClientDecodeError
A note on the API specification

Platega publishes its API in three places and they do not fully agree: the OpenAPI documents linked from docs.platega.io/llms.txt, the prose on the rendered pages, and an older GitBook that still documents endpoints and payment methods the current reference omits.

This library is built against all three. Where they conflict it accepts the union and types the affected fields permissively, so a value one specification leaves out does not make a whole response unreadable. The cases where that matters are called out in the relevant docstrings.

Payouts

Payouts are a separate client, because they are a separate security model: a secret issued once that Platega cannot recover, an HMAC-SHA256 signature over every request, and an idempotency key on every write.

from aioplatega import PayoutClient

async with PayoutClient(merchant_id="your-id", secret="payout-secret") as payouts:
    cards = await payouts.get_cards()
    result = await payouts.create_card_payout(
        card_id=cards[0].card_id,
        amount_rub=1500,
        idempotency_key="order-42-payout",
    )

[!WARNING] Pass your own idempotency_key whenever a retry has to be safe. Without one a fresh key is generated per call, so a retried request counts as a second payout.

The feature is disabled by default on a Platega account and enabled on request.

Contributing

make install     # sync every dependency group and install the pre-commit hooks
make lint        # ruff, formatting, mypy
make test        # pytest with coverage
make docs-serve  # docs with live reload on :8000

Commits follow Conventional Commits; releases are cut from them by release-please.

License

MIT

Metadata

Release files for aioplatega 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aioplatega 0.2.3
File Size Uploaded
aioplatega-0.2.3.tar.gz 181.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aioplatega 0.2.3
File Interpreter ABI Platform
aioplatega-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 232.1 kB

Release files / aioplatega-0.2.3.tar.gz

Download URL aioplatega-0.2.3.tar.gz
Size 181.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e39fdc02f77145e220e3d38f645d1920d43913430d4ba4e5ac8ff3560cd67820
BLAKE2b-256 checksum
How to use checksums
31fcfd7b8797bd87a0ba94ac04ba6bf459bd5cfec5fd2a9309f63193a957bb8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Release files / aioplatega-0.2.3-py3-none-any.whl

Download URL aioplatega-0.2.3-py3-none-any.whl
Size 50.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3259509fdac173004298c7771261aec9fae4eb938ac27a9245542ece61b1a02
BLAKE2b-256 checksum
How to use checksums
9265c5955db7922a90c5454aee09976628209f2438d7af713801932e8b45634f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.0

2 release files

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