fix time and text/ cosmetic fixes/ description of the payment/ vat_code

This commit is contained in:
Vladless
2025-07-18 02:07:30 +03:00
parent 16cf8bb1d5
commit b44302deb3
17 changed files with 129 additions and 299 deletions
+4 -2
View File
@@ -2,23 +2,24 @@ import base64
import aiohttp
from aiohttp import web
import json
import logging
from database import async_session_maker, update_balance, add_payment
from handlers.payments.utils import send_payment_success_notification
from config import WATA_RU_TOKEN, WATA_SBP_TOKEN, WATA_INT_TOKEN
from logger import logger
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.backends import default_backend
PUBLIC_KEY_URL = "https://api.wata.pro/api/h2h/public-key"
async def get_wata_public_key():
async with aiohttp.ClientSession() as session:
async with session.get(PUBLIC_KEY_URL) as resp:
data = await resp.json()
return data["value"].encode()
async def verify_signature(raw_json: bytes, signature: str, public_key_pem: bytes) -> bool:
try:
public_key = serialization.load_pem_public_key(public_key_pem, backend=default_backend())
@@ -34,6 +35,7 @@ async def verify_signature(raw_json: bytes, signature: str, public_key_pem: byte
logger.error(f"Ошибка проверки подписи WATA: {e}")
return False
async def wata_payment_webhook(request: web.Request):
try:
raw_json = await request.read()