Skip to content

Commit bd0d9f7

Browse files
committed
Add billing smoke checks for provider-agnostic support
- Check HostedBilling.create_portal_session method exists - Add BillingEvent model check with provider field - Verify billing webhook route exists (stripe or chargebee)
1 parent 2776e84 commit bd0d9f7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

checks.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,19 @@ def check_billing_service(app):
100100

101101
assert callable(requires_pro_plan)
102102
assert hasattr(HostedBilling, "create_upgrade_session")
103+
assert hasattr(HostedBilling, "create_portal_session")
103104
assert hasattr(HostedBilling, "handle_successful_payment")
104105

105106

107+
@check("BillingEvent model exists")
108+
def check_billing_event_model(app):
109+
from enferno.user.models import BillingEvent
110+
111+
with app.app_context():
112+
assert hasattr(BillingEvent, "provider")
113+
BillingEvent.query.limit(1).all()
114+
115+
106116
@check("Auth decorators work")
107117
def check_auth_decorators(app):
108118
from enferno.services.auth import require_superadmin, require_superadmin_api
@@ -127,11 +137,15 @@ def check_routes(app):
127137
"/",
128138
"/login",
129139
"/dashboard/",
130-
"/stripe/webhook",
131140
]
141+
132142
for route in critical_routes:
133143
assert route in rules, f"Missing route: {route}"
134144

145+
# Billing webhook - one of these must exist based on provider
146+
webhook_routes = ["/stripe/webhook", "/chargebee/webhook"]
147+
assert any(r in rules for r in webhook_routes), "Missing billing webhook route"
148+
135149

136150
@check("Security config is sane")
137151
def check_security_config(app):

0 commit comments

Comments
 (0)