feat: platform-aware storefront routing and billing improvements
Overhaul storefront URL routing to be platform-aware:
- Dev: /platforms/{code}/storefront/{store_code}/
- Prod: subdomain.platform.lu/ (internally rewritten to /storefront/)
- Add subdomain detection in PlatformContextMiddleware
- Add /storefront/ path rewrite for prod mode (subdomain/custom domain)
- Remove all silent platform fallbacks (platform_id=1)
- Add require_platform dependency for clean endpoint validation
- Update route registration, templates, module definitions, base_url calc
- Update StoreContextMiddleware for /storefront/ path detection
- Remove /stores/ from FrontendDetector STOREFRONT_PATH_PREFIXES
Billing service improvements:
- Add store_platform_sync_service to keep store_platforms in sync
- Make tier lookups platform-aware across billing services
- Add tiers for all platforms in seed data
- Add demo subscriptions to seed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -603,7 +603,7 @@ class TestBillingServiceUpcomingInvoice:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bs_tier_essential(db):
|
||||
def bs_tier_essential(db, test_platform):
|
||||
"""Create essential subscription tier."""
|
||||
tier = SubscriptionTier(
|
||||
code="essential",
|
||||
@@ -614,6 +614,7 @@ def bs_tier_essential(db):
|
||||
display_order=1,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
)
|
||||
db.add(tier)
|
||||
db.commit()
|
||||
@@ -622,7 +623,7 @@ def bs_tier_essential(db):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bs_tiers(db):
|
||||
def bs_tiers(db, test_platform):
|
||||
"""Create three tiers without Stripe config."""
|
||||
tiers = [
|
||||
SubscriptionTier(
|
||||
@@ -633,6 +634,7 @@ def bs_tiers(db):
|
||||
display_order=1,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
),
|
||||
SubscriptionTier(
|
||||
code="professional",
|
||||
@@ -642,6 +644,7 @@ def bs_tiers(db):
|
||||
display_order=2,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
),
|
||||
SubscriptionTier(
|
||||
code="business",
|
||||
@@ -651,6 +654,7 @@ def bs_tiers(db):
|
||||
display_order=3,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
),
|
||||
]
|
||||
db.add_all(tiers)
|
||||
@@ -661,7 +665,7 @@ def bs_tiers(db):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bs_tiers_with_stripe(db):
|
||||
def bs_tiers_with_stripe(db, test_platform):
|
||||
"""Create tiers with Stripe price IDs configured."""
|
||||
tiers = [
|
||||
SubscriptionTier(
|
||||
@@ -672,6 +676,7 @@ def bs_tiers_with_stripe(db):
|
||||
display_order=1,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
stripe_product_id="prod_essential",
|
||||
stripe_price_monthly_id="price_ess_monthly",
|
||||
stripe_price_annual_id="price_ess_annual",
|
||||
@@ -684,6 +689,7 @@ def bs_tiers_with_stripe(db):
|
||||
display_order=2,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
stripe_product_id="prod_professional",
|
||||
stripe_price_monthly_id="price_pro_monthly",
|
||||
stripe_price_annual_id="price_pro_annual",
|
||||
@@ -696,6 +702,7 @@ def bs_tiers_with_stripe(db):
|
||||
display_order=3,
|
||||
is_active=True,
|
||||
is_public=True,
|
||||
platform_id=test_platform.id,
|
||||
stripe_product_id="prod_business",
|
||||
stripe_price_monthly_id="price_biz_monthly",
|
||||
stripe_price_annual_id="price_biz_annual",
|
||||
|
||||
Reference in New Issue
Block a user