Add autorenew cancellation handler and logging for subscription service

- Implemented a new callback handler to allow users to cancel auto-renewal of their subscriptions via a webhook button.
- Added logging to track subscription status and auto-renew settings during webhook checks, improving monitoring and debugging capabilities.
- Enhanced user feedback with appropriate alerts for unsupported actions and confirmation of updates to subscription settings.
This commit is contained in:
machka-pasla
2025-09-05 22:10:56 +03:00
parent 2b592e8abe
commit c208541525
2 changed files with 45 additions and 0 deletions
+7
View File
@@ -213,6 +213,13 @@ class PanelWebhookService:
async with self.async_session_factory() as session:
from db.dal import subscription_dal
sub = await subscription_dal.get_active_subscription_by_user_id(session, user_id)
logging.info(
"48h webhook check: user_id=%s sub_found=%s auto_renew=%s provider=%s",
user_id,
bool(sub),
getattr(sub, 'auto_renew_enabled', None) if sub else None,
getattr(sub, 'provider', None) if sub else None,
)
if sub and sub.auto_renew_enabled and sub.provider != 'tribute':
cancel_kb = get_autorenew_cancel_keyboard(lang, self.i18n)
await self._send_message(