Refunds API¶
API для работы с возвратами.
- class aioyookassa.core.api.refunds.RefundsAPI(client: BaseAPIClient)[source]¶
Bases:
BaseAPI[CreateRefundParams,Refund]YooKassa refunds API client.
Provides methods for creating, retrieving, and listing refunds.
Initialize base API client.
- Parameters:
client – Base API client instance.
- async create_refund(params: CreateRefundParams) Refund[source]¶
Create a new refund for a successful payment.
- Parameters:
params (CreateRefundParams) – Refund creation parameters (CreateRefundParams).
- Returns:
Refund object.
- Return type:
Refund
- Seealso:
- Example:
>>> from aioyookassa.types.params import CreateRefundParams >>> from aioyookassa.types.payment import PaymentAmount >>> params = CreateRefundParams( ... payment_id="payment_id", ... amount=PaymentAmount(value=100.00, currency=Currency.RUB) ... ) >>> refund = await client.refunds.create_refund(params)
- async get_refunds(params: GetRefundsParams | None = None, **kwargs: Any) RefundsList[source]¶
Retrieve a list of refunds with optional filtering.
- Parameters:
params (Optional[GetRefundsParams]) – Filter parameters (GetRefundsParams).
kwargs – Additional parameters (merged with params).
- Returns:
Refunds list object.
- Return type:
RefundsList
- Seealso:
- Example:
>>> from aioyookassa.types.params import GetRefundsParams >>> params = GetRefundsParams(status="succeeded", limit=10) >>> refunds = await client.refunds.get_refunds(params)
Методы¶
create_refund¶
Создание нового возврата.
from aioyookassa.types.enum import Currency
from aioyookassa.types.params import CreateRefundParams
from aioyookassa.types.payment import PaymentAmount
params = CreateRefundParams(
payment_id="payment_id",
amount=PaymentAmount(value=50.00, currency=Currency.RUB),
description="Частичный возврат"
)
refund = await client.refunds.create_refund(params)
get_refunds¶
Получение списка возвратов с возможностью фильтрации.
from aioyookassa.types.params import GetRefundsParams
params = GetRefundsParams(
payment_id="payment_id",
status="succeeded",
limit=10
)
refunds = await client.refunds.get_refunds(params)
get_refund¶
Получение информации о конкретном возврате.
refund = await client.refunds.get_refund("refund_id")