Unofficial API client for YooKassa
Project description
Async YooKassa (unofficial)
Неофициальный асинхронный клиент для работы с платежами по API ЮKassa
За основу взята официальная библиотека от ЮМани.
Установка
# pip
pip install --upgrade async_yookassa
# poetry
poetry add async_yookassa
# uv
uv add async_yookassa
Быстрый старт (v0.6+)
from async_yookassa import YooKassaClient
from async_yookassa.models.payment_request import PaymentRequest
from async_yookassa.models.payment_submodels.amount import Amount
from async_yookassa.models.payment_submodels.confirmation import Confirmation
async with YooKassaClient(account_id="<Идентификатор магазина>", secret_key="<Секретный ключ>") as client:
# Создание платежа
payment = await client.payment.create(
PaymentRequest(
amount=Amount(value="100.00", currency="RUB"),
confirmation=Confirmation(type="redirect", return_url="https://example.com/return"),
description="Тестовый платёж",
)
)
print(payment.confirmation.confirmation_url)
# Получение информации о платеже
payment = await client.payment.find_one("payment_id")
# Список платежей
payments = await client.payment.list()
OAuth авторизация
async with YooKassaClient(auth_token="<OAuth Token>") as client:
payment = await client.payment.find_one("payment_id")
Интеграция с DI (пример для Dishka)
from dishka import Provider, Scope, provide, FromDishka
class YooKassaProvider(Provider):
@provide(scope=Scope.APP)
def get_client(self) -> YooKassaClient:
return YooKassaClient(account_id="...", secret_key="...")
# Применение
async def create_payment(client: FromDishka[YooKassaClient]):
async with client:
payment = await client.payment.create(...)
Доступные сервисы
| Сервис | Описание | Методы |
|---|---|---|
client.payment |
Платежи | create, find_one, capture, cancel, list |
client.refund |
Возвраты | create, find_one, list |
client.receipt |
Чеки | create, find_one, list |
client.payout |
Выплаты | create, find_one |
client.invoice |
Счета | create, find_one, cancel, list |
client.deal |
Сделки | create, find_one, list |
client.webhook |
Вебхуки | create, find_one, delete, list |
Миграция с v0.x
📖 Инструкция по миграции
Было (v0.x):
from async_yookassa import Configuration, Payment
Configuration.configure(account_id="...", secret_key="...")
payment = await Payment.create({"amount": {"value": "100.00", "currency": "RUB"}})
Стало (v0.6+):
from async_yookassa import YooKassaClient
from async_yookassa.models.payment_request import PaymentRequest
from async_yookassa.models.payment_submodels.amount import Amount
async with YooKassaClient(account_id="...", secret_key="...") as client:
payment = await client.payment.create(
PaymentRequest(amount=Amount(value="100.00", currency="RUB"))
)
Основные изменения:
- Контекстный менеджер — клиент теперь используется через
async with - Instance-based — больше нет глобального состояния в
Configuration - Сервисы — методы доступны через
client.payment,client.refund, и т.д.
Старый API продолжает работать, но выдаёт
DeprecationWarningи будет удалён в v2.0.
Требования
- Python >=3.11
Лицензия
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async_yookassa-0.6.0rc2.tar.gz
(35.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_yookassa-0.6.0rc2.tar.gz.
File metadata
- Download URL: async_yookassa-0.6.0rc2.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6f8c710ecbf2b9cb8d9613076f0d2ff343a9c90fad8e8c6af7eccd2aed032f5
|
|
| MD5 |
2b3cb9ce6ee697be357916eb4b6eb327
|
|
| BLAKE2b-256 |
4078b0ff8fe3d8ba9ab14b37e3b63ac5f1909a785686626b80472f40548466c3
|
File details
Details for the file async_yookassa-0.6.0rc2-py3-none-any.whl.
File metadata
- Download URL: async_yookassa-0.6.0rc2-py3-none-any.whl
- Upload date:
- Size: 81.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc726c480d63fa761f8da7e228e93a9f94be2999fa7dedfa183a9ea5229c46f4
|
|
| MD5 |
b0b85d6284df588a69376e10b78cc8df
|
|
| BLAKE2b-256 |
76ab5e2c69575ee001326b2ffbe538ec4260e0eb1bf2e81ba0043aa623bb54b4
|