# 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/store 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"]