Fix onboarding process not getting the subcription plan

This commit is contained in:
Urtzi Alfaro
2025-10-01 21:56:38 +02:00
parent b93fb850c3
commit c9d8d1d071
10 changed files with 312 additions and 15 deletions

View File

@@ -83,15 +83,39 @@ class EnhancedTenantService:
}
owner_membership = await member_repo.create_membership(membership_data)
# Create starter subscription
# Get subscription plan from user's registration using standardized auth client
selected_plan = "starter" # Default fallback
try:
from shared.clients.auth_client import AuthServiceClient
from app.core.config import settings
auth_client = AuthServiceClient(settings)
selected_plan = await auth_client.get_subscription_plan_from_registration(owner_id)
logger.info("Retrieved subscription plan from registration",
tenant_id=tenant.id,
owner_id=owner_id,
plan=selected_plan)
except Exception as e:
logger.warning("Could not retrieve subscription plan from auth service, using default",
error=str(e),
owner_id=owner_id,
default_plan=selected_plan)
# Create subscription with selected or default plan
subscription_data = {
"tenant_id": str(tenant.id),
"plan": "starter",
"plan": selected_plan,
"status": "active"
}
subscription = await subscription_repo.create_subscription(subscription_data)
logger.info("Subscription created",
tenant_id=tenant.id,
plan=selected_plan)
# Commit the transaction
await uow.commit()