### Install aioyookassa using pip Source: https://pypi.org/project/aioyookassa Installs the aioyookassa library using pip, the standard Python package installer. ```bash pip install aioyookassa ``` -------------------------------- ### Clone Repository and Install Development Dependencies Source: https://pypi.org/project/aioyookassa Clones the aioyookassa repository from GitHub and installs the necessary dependencies for development, including pre-commit hooks. ```bash # Клонирование репозитория git clone https://github.com/masasibata/aioyookassa.git cd aioyookassa # Установка зависимостей для разработки make install-dev # Установка pre-commit хуков make pre-commit # Запуск всех проверок make all-checks ``` -------------------------------- ### Create and Get Deals Source: https://pypi.org/project/aioyookassa Create a deal with specified fee moments and retrieve a list of deals. ```python from aioyookassa.types.params import CreateDealParams from aioyookassa.types.enum import FeeMoment # Создание безопасной сделки params = CreateDealParams( fee_moment=FeeMoment.PAYMENT_SUCCEEDED, description="Безопасная сделка" ) deal = await client.deals.create_deal(params) ``` ```python # Получение списка сделок deals = await client.deals.get_deals() ``` -------------------------------- ### Create and Get Payment Source: https://pypi.org/project/aioyookassa Shows how to create a new payment with specified amount, confirmation type, and description. Also demonstrates how to retrieve a list of payments based on creation date and status. ```python from datetime import datetime from aioyookassa.types.enum import PaymentStatus, ConfirmationType, Currency from aioyookassa.types.params import CreatePaymentParams, GetPaymentsParams # Создание платежа (используем Pydantic модель) params = CreatePaymentParams( amount=Money(value=1000.00, currency=Currency.RUB), confirmation=Confirmation(type=ConfirmationType.REDIRECT, return_url="https://example.com/return"), description="Оплата заказа #12345" ) payment = await client.payments.create_payment(params) # Получение списка платежей (используем Pydantic модель) params = GetPaymentsParams( created_at=datetime(2023, 1, 1, 12, 0, 0), status=PaymentStatus.SUCCEEDED, limit=10 ) payments = await client.payments.get_payments(params) # Получение конкретного платежа payment = await client.payments.get_payment("payment_id") ``` -------------------------------- ### Webhook Server for Payment Events Source: https://pypi.org/project/aioyookassa Set up a basic webhook server to handle payment succeeded events. This is a quick start option. ```python from aioyookassa.contrib.webhook_server import WebhookServer from aioyookassa.core.webhook_handler import WebhookHandler from aioyookassa.types.enum import WebhookEvent from aioyookassa.types.payment import Payment handler = WebhookHandler() @handler.register_callback(WebhookEvent.PAYMENT_SUCCEEDED) async def on_payment_succeeded(payment: Payment): print(f"✅ Платеж {payment.id} успешно выполнен") # Ваша бизнес-логика server = WebhookServer(handler=handler) server.run(host="0.0.0.0", port=8080) ``` -------------------------------- ### Create and Get Receipt Source: https://pypi.org/project/aioyookassa Use Pydantic models to create and retrieve receipt information. ```python params = CreateReceiptParams( type=ReceiptType.PAYMENT, payment_id="payment_id", customer=Customer(email="customer@example.com"), items=[ ReceiptRegistrationItem( description="Товар", quantity=1, amount=Money(value=1000.00, currency=Currency.RUB), vat_code=1, payment_subject=PaymentSubject.COMMODITY, payment_mode=PaymentMode.FULL_PAYMENT ) ], settlements=[ Settlement(type="prepayment", amount=Money(value=1000.00, currency=Currency.RUB)) ], tax_system_code=1 ) receipt = await client.receipts.create_receipt(params) ``` ```python # Получение информации о чеке receipt_info = await client.receipts.get_receipt("receipt_id") ``` -------------------------------- ### Conventional Commits Examples Source: https://pypi.org/project/aioyookassa Provides examples of commit messages following the Conventional Commits specification, which standardizes commit messages for better readability and automation. ```git feat: add new payment method support fix: resolve timeout issue in payment creation docs: update API documentation test: add tests for refund functionality refactor: improve error handling ``` -------------------------------- ### Create and Get Webhooks Source: https://pypi.org/project/aioyookassa Create a webhook for a specific event and retrieve a list of configured webhooks. Requires an OAuth token. ```python from aioyookassa.types.params import CreateWebhookParams from aioyookassa.types.enum import WebhookEvent # Создание webhook (требует OAuth токен) params = CreateWebhookParams( event=WebhookEvent.PAYMENT_SUCCEEDED, url="https://example.com/webhook" ) webhook = await client.webhooks.create_webhook( params=params, oauth_token="your_oauth_token" ) ``` ```python # Получение списка webhooks webhooks = await client.webhooks.get_webhooks(oauth_token="your_oauth_token") ``` -------------------------------- ### Create and Get Invoice Source: https://pypi.org/project/aioyookassa Create and retrieve invoice details using Pydantic models. ```python from aioyookassa.types.params import CreateInvoiceParams # Создание счета (используем Pydantic модель) params = CreateInvoiceParams( amount=Money(value=2000.00, currency=Currency.RUB), description="Счет на оплату" ) invoice = await client.invoices.create_invoice(params) ``` ```python # Получение информации о счете invoice_info = await client.invoices.get_invoice("invoice_id") ``` -------------------------------- ### Create and Get Refund Source: https://pypi.org/project/aioyookassa Demonstrates the process of creating a refund, including partial refunds, by specifying the payment ID, amount, and a description. It also shows how to retrieve information about a specific refund. ```python from aioyookassa.types.params import CreateRefundParams # Создание возврата (используем Pydantic модель) params = CreateRefundParams( payment_id="payment_id", amount=Money(value=500.00, currency=Currency.RUB), description="Частичный возврат" ) refund = await client.refunds.create_refund(params) # Получение информации о возврате refund_info = await client.refunds.get_refund("refund_id") ``` -------------------------------- ### Create and Get Payout Source: https://pypi.org/project/aioyookassa Perform payouts to a bank card and retrieve payout information. ```python from aioyookassa.types.params import ( CreatePayoutParams, BankCardPayoutDestinationData, BankCardPayoutCardData ) # Выплата на банковскую карту params = CreatePayoutParams( amount=Money(value=1000.00, currency=Currency.RUB), payout_destination_data=BankCardPayoutDestinationData( card=BankCardPayoutCardData(number="5555555555554477") ), description="Выплата по договору" ) payout = await client.payouts.create_payout(params) ``` ```python # Получение информации о выплате payout_info = await client.payouts.get_payout("payout_id") ``` -------------------------------- ### Run Local Development Pipeline Source: https://pypi.org/project/aioyookassa Executes the local development pipeline, which likely includes setup, testing, and linting steps to ensure the development environment is correctly configured. ```bash # Локальная разработка make dev # Запуск пайплайна разработки локально ``` -------------------------------- ### Get Refund Source: https://pypi.org/project/aioyookassa Retrieves information about a specific refund. ```APIDOC ## Get Refund ### Description Retrieves detailed information about a specific refund. ### Method `GET` ### Endpoint `/refunds/{refund_id}` ### Parameters #### Path Parameters - **refund_id** (string) - Required - The ID of the refund to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the refund. - **payment_id** (string) - The ID of the payment that was refunded. #### Response Example ```json { "id": "refund_id_456", "payment_id": "payment_id_123" } ``` ``` -------------------------------- ### Commit Changes with Conventional Commits Source: https://pypi.org/project/aioyookassa Example of how to stage and commit changes using the Conventional Commits specification, which helps in automating changelog generation and semantic versioning. ```bash # Зафиксируйте изменения git add . git commit -m "feat: add new feature" ``` -------------------------------- ### Get Payment Source: https://pypi.org/project/aioyookassa Retrieves information about a specific payment using its ID. ```APIDOC ## Get Payment ### Description Retrieves detailed information about a specific payment. ### Method `GET` ### Endpoint `/payments/{payment_id}` ### Parameters #### Path Parameters - **payment_id** (string) - Required - The ID of the payment to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the payment. - **status** (string) - The current status of the payment. #### Response Example ```json { "id": "payment_id_123", "status": "succeeded" } ``` ``` -------------------------------- ### Get Payments List Source: https://pypi.org/project/aioyookassa Retrieves a list of payments based on specified filters like creation date and status. ```APIDOC ## Get Payments List ### Description Retrieves a list of payments, optionally filtered by creation date, status, and limit. ### Method `GET` ### Endpoint `/payments` ### Parameters #### Query Parameters - **created_at** (datetime) - Optional - Filter payments created at or after this date/time. - **status** (PaymentStatus) - Optional - Filter payments by their status (e.g., SUCCEEDED). - **limit** (integer) - Optional - The maximum number of payments to return. ### Response #### Success Response (200) - **list** (array) - A list of payment objects. - Each payment object contains details like `id`, `status`, etc. #### Response Example ```json { "type": "list", "items": [ { "id": "payment_id_1", "status": "succeeded" }, { "id": "payment_id_2", "status": "succeeded" } ], "next_cursor": "cursor_string" } ``` ``` -------------------------------- ### Build and Serve Documentation Locally Source: https://pypi.org/project/aioyookassa Commands to build the project's documentation and serve it locally using a development server. This allows for previewing documentation changes. ```bash # Документация make docs # Сборка документации make docs-serve # Локальный сервер документации ``` -------------------------------- ### Initialize YooKassa Client and Create Payment Source: https://pypi.org/project/aioyookassa Demonstrates how to initialize the YooKassa client using a context manager and create a new payment. The client is automatically closed upon exiting the 'async with' block. ```python async with YooKassa(api_key="your_key", shop_id=12345) as client: # Создание платежа (используем Pydantic модель) params = CreatePaymentParams( amount=Money(value=100.00, currency=Currency.RUB), confirmation=Confirmation(type=ConfirmationType.REDIRECT, return_url="https://example.com/return") ) payment = await client.payments.create_payment(params) ``` -------------------------------- ### Basic Usage of YooKassa Client Source: https://pypi.org/project/aioyookassa Demonstrates the basic initialization, payment creation, retrieval, and listing of payments using the YooKassa client. Ensure to replace 'your_api_key' and the shop ID with your actual credentials. ```python import asyncio from datetime import datetime from aioyookassa import YooKassa from aioyookassa.types.payment import Money, Confirmation from aioyookassa.types.enum import PaymentStatus, ConfirmationType, Currency from aioyookassa.types.params import CreatePaymentParams, GetPaymentsParams async def main(): # Инициализация клиента client = YooKassa(api_key="your_api_key", shop_id=12345) # Создание платежа (используем Pydantic модель) params = CreatePaymentParams( amount=Money(value=100.00, currency=Currency.RUB), confirmation=Confirmation(type=ConfirmationType.REDIRECT, return_url="https://example.com/return"), description="Тестовый платеж" ) payment = await client.payments.create_payment(params) print(f"Payment created: {payment.id}") print(f"Confirmation URL: {payment.confirmation.url}") # Получение информации о платеже payment_info = await client.payments.get_payment(payment.id) print(f"Payment status: {payment_info.status}") # Получение списка платежей за сегодня (используем Pydantic модель) today = datetime.now() params = GetPaymentsParams( created_at=today, status=PaymentStatus.SUCCEEDED ) payments = await client.payments.get_payments(params) print(f"Found {len(payments.list)} successful payments today") # Закрытие клиента await client.close() # Запуск asyncio.run(main()) ``` -------------------------------- ### Create Payment Source: https://pypi.org/project/aioyookassa Demonstrates how to create a new payment using the CreatePaymentParams model. ```APIDOC ## Create Payment ### Description Creates a new payment with specified amount, confirmation method, and description. ### Method `POST` ### Endpoint `/payments` ### Parameters #### Request Body - **amount** (Money) - Required - The payment amount and currency. - **confirmation** (Confirmation) - Required - The confirmation method (e.g., REDIRECT). - **description** (string) - Optional - A description for the payment. ### Request Example ```json { "amount": { "value": 100.00, "currency": "RUB" }, "confirmation": { "type": "REDIRECT", "return_url": "https://example.com/return" }, "description": "Тестовый платеж" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the payment. - **confirmation** (Confirmation) - Details about the payment confirmation, including the URL. - **status** (string) - The current status of the payment. #### Response Example ```json { "id": "payment_id_123", "confirmation": { "type": "REDIRECT", "url": "https://yoomoney.ru/checkout/...?paymentId=payment_id_123" }, "status": "waiting_for_capture" } ``` ``` -------------------------------- ### Create Self-Employed Source: https://pypi.org/project/aioyookassa Register a self-employed individual with confirmation details. ```python from aioyookassa.types.params import ( CreateSelfEmployedParams, SelfEmployedConfirmationData ) # Создание самозанятого params = CreateSelfEmployedParams( itn="123456789012", confirmation=SelfEmployedConfirmationData( type="redirect", confirmation_url="https://example.com/confirm" ) ) self_employed = await client.self_employed.create_self_employed(params) ``` -------------------------------- ### Create Receipt Source: https://pypi.org/project/aioyookassa Provides the necessary imports for creating a receipt, including customer details, settlement information, and item details for registration. ```python from aioyookassa.types.payment import Customer, Settlement from aioyookassa.types.enum import ReceiptType, PaymentSubject, PaymentMode, Currency from aioyookassa.types.params import CreateReceiptParams from aioyookassa.types.receipt_registration import ReceiptRegistrationItem ``` -------------------------------- ### Build and Clean Project Artifacts Source: https://pypi.org/project/aioyookassa Commands for building the aioyookassa package and cleaning up generated artifacts. This is typically used during the release process. ```bash # Сборка и публикация make build # Сборка пакета make clean # Очистка артефактов ``` -------------------------------- ### Deals Source: https://pypi.org/project/aioyookassa Methods for creating and retrieving deal information. ```APIDOC ## Create Deal ### Description Creates a new deal. ### Method POST ### Endpoint /deals ### Parameters #### Request Body - **params** (CreateDealParams) - Required - Parameters for creating the deal. ### Request Example ```python params = CreateDealParams( fee_moment=FeeMoment.PAYMENT_SUCCEEDED, description="Безопасная сделка" ) deal = await client.deals.create_deal(params) ``` ### Response #### Success Response (200) - **deal** (Deal) - The created deal object. #### Response Example ```json { "id": "deal_id", "status": "active" } ``` ``` ```APIDOC ## Get Deals ### Description Retrieves a list of deals. ### Method GET ### Endpoint /deals ### Response #### Success Response (200) - **deals** (list[Deal]) - A list of deal objects. #### Response Example ```json [ { "id": "deal_id_1", "status": "active" }, { "id": "deal_id_2", "status": "closed" } ] ``` ``` -------------------------------- ### Add aioyookassa using Poetry Source: https://pypi.org/project/aioyookassa Adds the aioyookassa library as a dependency to your project using Poetry, a dependency management tool for Python. ```bash poetry add aioyookassa ``` -------------------------------- ### Webhooks Source: https://pypi.org/project/aioyookassa Methods for creating, managing, and handling webhooks. ```APIDOC ## Create Webhook ### Description Creates a new webhook subscription. ### Method POST ### Endpoint /webhooks ### Parameters #### Request Body - **params** (CreateWebhookParams) - Required - Parameters for creating the webhook. - **oauth_token** (string) - Required - Your OAuth token. ### Request Example ```python params = CreateWebhookParams( event=WebhookEvent.PAYMENT_SUCCEEDED, url="https://example.com/webhook" ) webhook = await client.webhooks.create_webhook( params=params, oauth_token="your_oauth_token" ) ``` ### Response #### Success Response (200) - **webhook** (Webhook) - The created webhook object. #### Response Example ```json { "id": "webhook_id", "event": "payment.succeeded", "url": "https://example.com/webhook" } ``` ``` ```APIDOC ## Get Webhooks ### Description Retrieves a list of configured webhooks. ### Method GET ### Endpoint /webhooks ### Parameters #### Query Parameters - **oauth_token** (string) - Required - Your OAuth token. ### Response #### Success Response (200) - **webhooks** (list[Webhook]) - A list of webhook objects. #### Response Example ```json [ { "id": "webhook_id_1", "event": "payment.succeeded", "url": "https://example.com/webhook" } ] ``` ``` ```APIDOC ## Handle Webhook Notifications ### Description Provides examples for handling incoming webhook notifications, including a ready-to-use server and integration with existing applications. ### Code Examples **Option 1: Ready-made server** ```python from aioyookassa.contrib.webhook_server import WebhookServer from aioyookassa.core.webhook_handler import WebhookHandler from aioyookassa.types.enum import WebhookEvent from aioyookassa.types.payment import Payment handler = WebhookHandler() @handler.register_callback(WebhookEvent.PAYMENT_SUCCEEDED) async def on_payment_succeeded(payment: Payment): print(f"✅ Платеж {payment.id} успешно выполнен") # Ваша бизнес-логика server = WebhookServer(handler=handler) server.run(host="0.0.0.0", port=8080) ``` **Option 2: Integration with an existing application** ```python from aiohttp import web from aioyookassa.core.webhook_handler import WebhookHandler from aioyookassa.types.enum import WebhookEvent from aioyookassa.types.payment import Payment handler = WebhookHandler() @handler.register_callback(WebhookEvent.PAYMENT_SUCCEEDED) async def on_payment_succeeded(payment: Payment): await process_payment(payment) async def webhook_endpoint(request): # Валидация IP (рекомендуется) if not handler.validator.is_allowed(request.remote): raise web.HTTPForbidden() # Обработка уведомления data = await request.json() notification = handler.parse_notification(data) await handler.handle_notification(notification) return web.Response(status=200) app = web.Application() app.router.add_post("/webhook", webhook_endpoint) web.run_app(app) ``` **Registering callbacks for multiple events:** ```python # Несколько событий @handler.register_callback([ WebhookEvent.PAYMENT_SUCCEEDED, WebhookEvent.PAYMENT_CANCELED ]) async def on_payment_status_change(payment: Payment): print(f"Payment {payment.id} status changed") ``` ``` -------------------------------- ### Capture and Cancel Payment Source: https://pypi.org/project/aioyookassa Illustrates how to confirm a payment by capturing a specified amount and how to cancel an existing payment using its ID. ```python # Подтверждение платежа (используем Pydantic модель) from aioyookassa.types.params import CapturePaymentParams params = CapturePaymentParams(amount=Money(value=1000.00, currency=Currency.RUB)) payment = await client.payments.capture_payment("payment_id", params) # Отмена платежа payment = await client.payments.cancel_payment("payment_id") ``` -------------------------------- ### Run Tests with Coverage Source: https://pypi.org/project/aioyookassa Executes all tests for the aioyookassa library and generates a code coverage report. This is useful for ensuring comprehensive test coverage. ```bash # Тестирование make test # Запуск тестов make test-cov # Тесты с покрытием кода make test-fast # Быстрые тесты без покрытия ``` -------------------------------- ### Integrate Webhook Handler with Existing App Source: https://pypi.org/project/aioyookassa Integrate the YooKassa webhook handler into an existing aiohttp application. Includes IP validation and notification parsing. ```python from aiohttp import web from aioyookassa.core.webhook_handler import WebhookHandler from aioyookassa.types.enum import WebhookEvent from aioyookassa.types.payment import Payment handler = WebhookHandler() @handler.register_callback(WebhookEvent.PAYMENT_SUCCEEDED) async def on_payment_succeeded(payment: Payment): await process_payment(payment) async def webhook_endpoint(request): # Валидация IP (рекомендуется) if not handler.validator.is_allowed(request.remote): raise web.HTTPForbidden() # Обработка уведомления data = await request.json() notification = handler.parse_notification(data) await handler.handle_notification(notification) return web.Response(status=200) app = web.Application() app.router.add_post("/webhook", webhook_endpoint) web.run_app(app) ``` -------------------------------- ### Perform Code Quality Checks Source: https://pypi.org/project/aioyookassa Runs various code quality checks including linting, formatting, and type checking using tools like Black and MyPy. ```bash # Качество кода make lint # Линтинг (Black) make format # Форматирование кода make type-check # Проверка типов (MyPy) make all-checks # Все проверки качества ``` -------------------------------- ### Create Refund Source: https://pypi.org/project/aioyookassa Creates a refund for a payment, either full or partial. ```APIDOC ## Create Refund ### Description Initiates a refund for a specified payment. ### Method `POST` ### Endpoint `/refunds` ### Parameters #### Request Body - **payment_id** (string) - Required - The ID of the payment to refund. - **amount** (Money) - Required - The amount to refund. - **description** (string) - Optional - A description for the refund. ### Request Example ```json { "payment_id": "payment_id_123", "amount": { "value": 500.00, "currency": "RUB" }, "description": "Частичный возврат" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the refund. - **payment_id** (string) - The ID of the payment that was refunded. #### Response Example ```json { "id": "refund_id_456", "payment_id": "payment_id_123" } ``` ``` -------------------------------- ### Invoices Source: https://pypi.org/project/aioyookassa Methods for creating and retrieving invoice information. ```APIDOC ## Create Invoice ### Description Creates a new invoice with the provided amount and description. ### Method POST ### Endpoint /invoices ### Parameters #### Request Body - **params** (CreateInvoiceParams) - Required - Parameters for creating the invoice. ### Request Example ```python params = CreateInvoiceParams( amount=Money(value=2000.00, currency=Currency.RUB), description="Счет на оплату" ) invoice = await client.invoices.create_invoice(params) ``` ### Response #### Success Response (200) - **invoice** (Invoice) - The created invoice object. #### Response Example ```json { "id": "invoice_id", "status": "pending" } ``` ``` ```APIDOC ## Get Invoice ### Description Retrieves information about a specific invoice. ### Method GET ### Endpoint /invoices/{invoice_id} ### Parameters #### Path Parameters - **invoice_id** (string) - Required - The ID of the invoice to retrieve. ### Response #### Success Response (200) - **invoice_info** (Invoice) - The invoice information. #### Response Example ```json { "id": "invoice_id", "status": "pending" } ``` ``` -------------------------------- ### Receipts Source: https://pypi.org/project/aioyookassa Methods for creating and retrieving receipt information. ```APIDOC ## Create Receipt ### Description Creates a new receipt with the provided payment details. ### Method POST ### Endpoint /receipts ### Parameters #### Request Body - **params** (CreateReceiptParams) - Required - Parameters for creating the receipt. ### Request Example ```python params = CreateReceiptParams( type=ReceiptType.PAYMENT, payment_id="payment_id", customer=Customer(email="customer@example.com"), items=[ ReceiptRegistrationItem( description="Товар", quantity=1, amount=Money(value=1000.00, currency=Currency.RUB), vat_code=1, payment_subject=PaymentSubject.COMMODITY, payment_mode=PaymentMode.FULL_PAYMENT ) ], settlements=[ Settlement(type="prepayment", amount=Money(value=1000.00, currency=Currency.RUB)) ], tax_system_code=1 ) receipt = await client.receipts.create_receipt(params) ``` ### Response #### Success Response (200) - **receipt** (Receipt) - The created receipt object. #### Response Example ```json { "id": "receipt_id", "status": "succeeded" } ``` ``` ```APIDOC ## Get Receipt ### Description Retrieves information about a specific receipt. ### Method GET ### Endpoint /receipts/{receipt_id} ### Parameters #### Path Parameters - **receipt_id** (string) - Required - The ID of the receipt to retrieve. ### Response #### Success Response (200) - **receipt_info** (Receipt) - The receipt information. #### Response Example ```json { "id": "receipt_id", "status": "succeeded" } ``` ``` -------------------------------- ### Self-Employed Source: https://pypi.org/project/aioyookassa Methods for creating self-employed registrations. ```APIDOC ## Create Self-Employed ### Description Creates a self-employed registration. ### Method POST ### Endpoint /self-employed ### Parameters #### Request Body - **params** (CreateSelfEmployedParams) - Required - Parameters for creating the self-employed registration. ### Request Example ```python params = CreateSelfEmployedParams( itn="123456789012", confirmation=SelfEmployedConfirmationData( type="redirect", confirmation_url="https://example.com/confirm" ) ) self_employed = await client.self_employed.create_self_employed(params) ``` ### Response #### Success Response (200) - **self_employed** (SelfEmployed) - The created self-employed object. #### Response Example ```json { "id": "self_employed_id", "status": "pending" } ``` ``` -------------------------------- ### Register Multiple Webhook Events Source: https://pypi.org/project/aioyookassa Register a single callback function to handle multiple webhook events, such as payment succeeded and payment canceled. ```python # Несколько событий @handler.register_callback([ WebhookEvent.PAYMENT_SUCCEEDED, WebhookEvent.PAYMENT_CANCELED ]) async def on_payment_status_change(payment: Payment): print(f"Payment {payment.id} status changed") ``` -------------------------------- ### Payouts Source: https://pypi.org/project/aioyookassa Methods for creating and retrieving payout information. ```APIDOC ## Create Payout ### Description Creates a payout to a bank card. ### Method POST ### Endpoint /payouts ### Parameters #### Request Body - **params** (CreatePayoutParams) - Required - Parameters for creating the payout. ### Request Example ```python params = CreatePayoutParams( amount=Money(value=1000.00, currency=Currency.RUB), payout_destination_data=BankCardPayoutDestinationData( card=BankCardPayoutCardData(number="5555555555554477") ), description="Выплата по договору" ) payout = await client.payouts.create_payout(params) ``` ### Response #### Success Response (200) - **payout** (Payout) - The created payout object. #### Response Example ```json { "id": "payout_id", "status": "processing" } ``` ``` ```APIDOC ## Get Payout ### Description Retrieves information about a specific payout. ### Method GET ### Endpoint /payouts/{payout_id} ### Parameters #### Path Parameters - **payout_id** (string) - Required - The ID of the payout to retrieve. ### Response #### Success Response (200) - **payout_info** (Payout) - The payout information. #### Response Example ```json { "id": "payout_id", "status": "processing" } ``` ``` -------------------------------- ### Register Payment Event Handler Source: https://pypi.org/project/aioyookassa Registers a callback handler for all payment-related events. This function will be executed whenever a payment event occurs. ```python @handler.register_callback("payment.*") async def handle_all_payments(payment: Payment): print(f"Payment event: {payment.id}") ``` -------------------------------- ### Retrieve Recent Payments Source: https://pypi.org/project/aioyookassa Shows how to retrieve a list of recent payments that have succeeded within the last hour. This uses Pydantic models for defining the query parameters. ```python # Получение платежей за последний час (используем Pydantic модель) params = GetPaymentsParams( created_at=datetime.now(), status=PaymentStatus.SUCCEEDED, limit=5 ) recent_payments = await client.payments.get_payments(params) ``` -------------------------------- ### Push Changes to Remote Repository Source: https://pypi.org/project/aioyookassa Pushes committed changes from the local feature branch to the remote repository on GitHub, preparing for a Pull Request. ```bash # Отправьте изменения git push origin feature/your-feature-name ``` -------------------------------- ### Capture Payment Source: https://pypi.org/project/aioyookassa Captures a previously authorized payment. ```APIDOC ## Capture Payment ### Description Captures an authorized payment, transferring funds. ### Method `POST` ### Endpoint `/payments/{payment_id}/capture` ### Parameters #### Path Parameters - **payment_id** (string) - Required - The ID of the payment to capture. #### Request Body - **amount** (Money) - Required - The amount to capture. ### Request Example ```json { "amount": { "value": 1000.00, "currency": "RUB" } } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the captured payment. - **status** (string) - The updated status of the payment (e.g., `succeeded`). #### Response Example ```json { "id": "payment_id_123", "status": "succeeded" } ``` ``` -------------------------------- ### Cancel Payment Source: https://pypi.org/project/aioyookassa Cancels a payment that has not yet been captured. ```APIDOC ## Cancel Payment ### Description Cancels a payment that has not been captured. ### Method `POST` ### Endpoint `/payments/{payment_id}/cancel` ### Parameters #### Path Parameters - **payment_id** (string) - Required - The ID of the payment to cancel. ### Response #### Success Response (200) - **id** (string) - The ID of the canceled payment. - **status** (string) - The updated status of the payment (e.g., `canceled`). #### Response Example ```json { "id": "payment_id_123", "status": "canceled" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.