refactor: move billingWebhookHandler to serviceBilling layer

Business logic for Stripe webhooks belongs in serviceCenter/services/serviceBilling/, not in routes/. Updates 3 lazy imports in routeBilling.py accordingly.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ValueOn AG 2026-06-08 21:01:32 +02:00
parent e0caad0a75
commit c1655bdd0a
2 changed files with 4 additions and 4 deletions

View file

@ -332,7 +332,7 @@ def _getStripeClient():
def _creditStripeSessionIfNeeded(billingInterface, session: Dict[str, Any], eventId: Optional[str] = None) -> CheckoutConfirmResponse: def _creditStripeSessionIfNeeded(billingInterface, session: Dict[str, Any], eventId: Optional[str] = None) -> CheckoutConfirmResponse:
"""Credit balance from Stripe Checkout session if not already credited.""" """Credit balance from Stripe Checkout session if not already credited."""
from .billingWebhookHandler import creditStripeSessionIfNeeded from modules.serviceCenter.services.serviceBilling.billingWebhookHandler import creditStripeSessionIfNeeded
return creditStripeSessionIfNeeded(billingInterface, session, eventId, CheckoutConfirmResponse) return creditStripeSessionIfNeeded(billingInterface, session, eventId, CheckoutConfirmResponse)
@ -1079,13 +1079,13 @@ async def stripeWebhook(
def handleSubscriptionCheckoutCompleted(session, eventId: str) -> None: def handleSubscriptionCheckoutCompleted(session, eventId: str) -> None:
"""Handle checkout.session.completed for mode=subscription.""" """Handle checkout.session.completed for mode=subscription."""
from .billingWebhookHandler import handleSubscriptionCheckoutCompleted as _handler from modules.serviceCenter.services.serviceBilling.billingWebhookHandler import handleSubscriptionCheckoutCompleted as _handler
_handler(session, eventId, getRootInterface) _handler(session, eventId, getRootInterface)
def _handleSubscriptionWebhook(event) -> None: def _handleSubscriptionWebhook(event) -> None:
"""Process Stripe subscription webhook events.""" """Process Stripe subscription webhook events."""
from .billingWebhookHandler import handleSubscriptionWebhook as _handler from modules.serviceCenter.services.serviceBilling.billingWebhookHandler import handleSubscriptionWebhook as _handler
_handler(event, getRootInterface) _handler(event, getRootInterface)

View file

@ -2,7 +2,7 @@
# All rights reserved. # All rights reserved.
""" """
Stripe webhook and subscription business logic for billing. Stripe webhook and subscription business logic for billing.
Extracted from routeBilling.py for maintainability. Handles checkout credit, subscription lifecycle transitions, and invoice events.
""" """
import logging import logging