This commit is contained in:
Yuriy Yuriev
2026-07-05 16:59:33 +07:00
parent f262616aad
commit 44ce29d2e0
9 changed files with 188 additions and 31 deletions
+12
View File
@@ -344,6 +344,18 @@ class PaymentStorage:
payments.pop(payment_id, None)
await asyncio.to_thread(self._save_sync, payments)
async def pop(self, payment_id: str) -> Optional[dict]:
"""Get and mark payment as processed. Returns None if not found or already processed."""
async with self._lock:
payments = await asyncio.to_thread(self._load_sync)
data = payments.get(payment_id)
if data is None or data.get("processed"):
return None
payments[payment_id]["processed"] = True
payments[payment_id]["processed_at"] = datetime.now().isoformat(timespec="seconds")
await asyncio.to_thread(self._save_sync, payments)
return data
async def get_by_user(self, user_id: int) -> Optional[dict]:
async with self._lock:
payments = await asyncio.to_thread(self._load_sync)