Handle panel webhook variants and remove Tribute cancel

This commit is contained in:
Machka Pasla
2025-07-11 23:40:33 +07:00
parent b5b740611c
commit c7b124ad4c
10 changed files with 146 additions and 183 deletions
+5 -13
View File
@@ -76,7 +76,11 @@ class TributeService:
event_name = payload.get('name')
data = payload.get('payload', {})
user_id = data.get('telegram_user_id')
price_val = data.get('price')
price_val = (
data.get('amount')
or data.get('amount_paid')
or data.get('price')
)
if not user_id or price_val is None:
return web.Response(status=200, text="ok_missing_fields")
@@ -168,18 +172,6 @@ class TributeService:
float(price_rub),
currency="RUB",
)
elif event_name == 'cancelled_subscription':
db_user = await user_dal.get_user_by_id(session, user_id)
lang = db_user.language_code if db_user and db_user.language_code else settings.DEFAULT_LANGUAGE
_ = lambda k, **kw: i18n.gettext(lang, k, **kw)
try:
await bot.send_message(user_id, _("subscription_cancelled_notification"))
except Exception as e:
logging.warning(
f"Failed to notify user {user_id} about cancellation: {e}")
await subscription_dal.set_skip_notifications_for_provider(
session, user_id, 'tribute', False)
await session.commit()
else:
await session.commit()
return web.Response(status=200, text="ok")