Enhance payment processing and user detail updates in YooKassa integration

- Added handling for 'waiting_for_capture' event in the YooKassa webhook to manage bind-only payment flows, including saving payment methods and canceling authorizations.
- Introduced a new method in the YooKassaService to cancel payments, improving error handling and logging for payment cancellations.
- Updated user detail synchronization to conditionally update descriptions only when they differ from the current panel state, enhancing efficiency.
This commit is contained in:
machka-pasla
2025-09-04 16:30:45 +03:00
parent e0e2cde9a7
commit 257597ccb7
3 changed files with 46 additions and 1 deletions
+13
View File
@@ -206,6 +206,19 @@ class YooKassaService:
logging.error(
"YooKassa is not configured. Cannot get payment info.")
return None
async def cancel_payment(self, payment_id_in_yookassa: str) -> bool:
if not self.configured:
logging.error("YooKassa is not configured. Cannot cancel payment.")
return False
try:
loop = asyncio.get_running_loop()
await loop.run_in_executor(None, lambda: YooKassaPayment.cancel(payment_id_in_yookassa))
logging.info(f"Cancelled YooKassa payment {payment_id_in_yookassa}")
return True
except Exception as e:
logging.error(f"Failed to cancel YooKassa payment {payment_id_in_yookassa}: {e}")
return False
try:
logging.info(
f"Fetching payment info from YooKassa for ID: {payment_id_in_yookassa}"