Handle panel webhook variants and remove Tribute cancel
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user