Payment providers as classes (Strategy + factory); 10342 = monthly; health logs a failed Bazaar check

- payment/providers.py: ZarinpalProvider / BazaarProvider with one interface (check_plan, sku_for, payment_url,
  purchase_extras, discount_blocker, reconcile_user); provider_for / provider_for_method pick one; unknown fails.
  create_order, purchase view, discount redeem and reconcile_user_orders use it instead of scattered ifs.
- subscription.0015: Bazaar SKU 10342 on the one-month plan (owner: "probably the monthly one").
- config/health: the Bazaar check no longer swallows its exception without a log.
982 tests green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 18:21:45 +03:30
parent 76b0ef976e
commit c0fa46be44
11 changed files with 246 additions and 66 deletions

View File

@@ -41,8 +41,10 @@ def has_subscription_access(user_id: int) -> bool:
"""
if has_active_subscription(user_id):
return True
from payment.services import sync_bazaar_renewals
return bool(sync_bazaar_renewals(user_id)) and has_active_subscription(user_id)
# فقط بازار، نه همه‌ی روش‌ها: بازسنجیِ زرین‌پال در این مسیرِ پرترافیک برای هر بی‌اشتراکی با سفارشِ نیمه‌کاره
# یک فراخوانیِ شبکه می‌شد؛ آن را صفحه‌ی وضعیت و کال‌بک می‌کنند.
from payment.providers import provider_for
return bool(provider_for('bazaar').reconcile_user(user_id)) and has_active_subscription(user_id)
def hearts_pass_until(user_id: int):