fix(autopay): exclude daily subscriptions from global autopay

- Skip daily tariff subscriptions in monitoring autopay cycle
- Filter daily subscriptions in get_subscriptions_for_autopay CRUD
- Block autopay menu and toggle for daily tariffs in bot handler
- Reject autopay enable for daily subscriptions in Cabinet API (HTTP 400)
- Reject autopay enable for daily subscriptions in MiniApp API (HTTP 400)
This commit is contained in:
Fringg
2026-02-05 07:10:52 +03:00
parent e8a413c3c3
commit b9352a5bd5
5 changed files with 79 additions and 2 deletions
+15
View File
@@ -3698,7 +3698,22 @@ async def update_subscription_autopay_endpoint(
subscription = _ensure_paid_subscription(user)
_validate_subscription_id(payload.subscription_id, subscription)
# Суточные подписки имеют свой механизм продления (DailySubscriptionService),
# глобальный autopay для них запрещён
target_enabled = bool(payload.enabled) if payload.enabled is not None else bool(subscription.autopay_enabled)
if target_enabled:
try:
await db.refresh(subscription, ['tariff'])
except Exception:
pass
if subscription.tariff and getattr(subscription.tariff, 'is_daily', False):
raise HTTPException(
status.HTTP_400_BAD_REQUEST,
detail={
'code': 'autopay_not_available_for_daily',
'message': 'Autopay is not available for daily subscriptions',
},
)
requested_days = payload.days_before
normalized_days = _normalize_autopay_days(requested_days)