- Rename module definition variables to follow naming convention: - catalog/definition.py: module → catalog_module - checkout/definition.py: module → checkout_module - cart/definition.py: module → cart_module - Add router attachment functions for lazy loading: - get_catalog_module_with_routers() - get_checkout_module_with_routers() - get_cart_module_with_routers() - Move billing exceptions to exceptions.py: - Add backwards-compatible aliases (BillingServiceError, etc.) - Update billing_service.py to import from exceptions.py - Standardize VendorEmailSettingsService DI pattern: - Change from db in __init__ to db as method parameter - Create singleton vendor_email_settings_service instance - Update routes and tests to use new pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
# app/modules/checkout/definition.py
|
|
"""
|
|
Checkout module definition.
|
|
|
|
This module handles the checkout flow, converting cart contents into orders.
|
|
Orchestrates payment processing and order creation.
|
|
"""
|
|
|
|
from app.modules.base import ModuleDefinition, PermissionDefinition
|
|
|
|
|
|
# =============================================================================
|
|
# Router Lazy Imports
|
|
# =============================================================================
|
|
|
|
|
|
def _get_storefront_router():
|
|
"""Lazy import of storefront router to avoid circular imports."""
|
|
from app.modules.checkout.routes.api.storefront import router
|
|
|
|
return router
|
|
|
|
|
|
# Checkout module definition
|
|
checkout_module = ModuleDefinition(
|
|
code="checkout",
|
|
name="Checkout",
|
|
description="Checkout and order creation for storefronts",
|
|
version="1.0.0",
|
|
is_self_contained=True,
|
|
requires=["cart", "orders", "payments", "customers"],
|
|
features=[
|
|
"checkout_flow", # Multi-step checkout process
|
|
"order_creation", # Create orders from cart
|
|
"payment_processing", # Payment integration during checkout
|
|
"checkout_validation", # Address, inventory, payment validation
|
|
"guest_checkout", # Allow checkout without account
|
|
],
|
|
# Note: Checkout is primarily storefront functionality.
|
|
# These permissions are for admin access to checkout settings.
|
|
permissions=[
|
|
PermissionDefinition(
|
|
id="checkout.view_settings",
|
|
label_key="checkout.permissions.view_settings",
|
|
description_key="checkout.permissions.view_settings_desc",
|
|
category="checkout",
|
|
),
|
|
PermissionDefinition(
|
|
id="checkout.manage_settings",
|
|
label_key="checkout.permissions.manage_settings",
|
|
description_key="checkout.permissions.manage_settings_desc",
|
|
category="checkout",
|
|
),
|
|
],
|
|
# Checkout is storefront-only - no admin/vendor menus needed
|
|
menu_items={},
|
|
)
|
|
|
|
|
|
def get_checkout_module_with_routers() -> ModuleDefinition:
|
|
"""
|
|
Get checkout module with routers attached.
|
|
|
|
This function attaches the routers lazily to avoid circular imports
|
|
during module initialization.
|
|
"""
|
|
checkout_module.storefront_router = _get_storefront_router()
|
|
return checkout_module
|
|
|
|
|
|
__all__ = ["checkout_module", "get_checkout_module_with_routers"]
|