Jun 28 - Implement payment functions (Stripe)

This commit is contained in:
2026-06-28 12:01:25 -04:00
parent 61ede27093
commit f292c8fb7b
21 changed files with 1112 additions and 18 deletions
+30 -2
View File
@@ -226,8 +226,36 @@ def plan():
except Exception as exc:
logger.error('tenant_settings.plan: quota count failed: %s', exc)
return render_template('tenant_settings/plan.html',
plan_info=plan_info, quota_usage=quota_usage)
# MT-8: billing fields are already on g.tenant — no extra DB query needed.
billing_enabled = current_app.config.get('BILLING_ENABLED', False)
subscription_status = None
trial_ends_at = None
has_stripe_customer = False
if _mt_enabled():
tenant_ctx = getattr(g, 'tenant', None)
if tenant_ctx is not None:
subscription_status = tenant_ctx.subscription_status
trial_ends_at = tenant_ctx.trial_ends_at
# Check whether stripe_customer_id is set (for "Manage Billing" link).
if billing_enabled:
try:
from control.base import control_session
from control.models import Tenant as ControlTenant
with control_session() as s:
t = s.get(ControlTenant, tenant_ctx.id)
has_stripe_customer = bool(t and t.stripe_customer_id)
except Exception:
pass
return render_template(
'tenant_settings/plan.html',
plan_info=plan_info,
quota_usage=quota_usage,
billing_enabled=billing_enabled,
subscription_status=subscription_status,
trial_ends_at=trial_ends_at,
has_stripe_customer=has_stripe_customer,
)
# ── custom domains ────────────────────────────────────────────────────────────