sdsd
This commit is contained in:
@@ -288,21 +288,14 @@ class RegisterSerializer(serializers.Serializer):
|
||||
from igny8_core.business.billing.models import CreditTransaction
|
||||
|
||||
with transaction.atomic():
|
||||
# ALWAYS assign Free Trial plan for simple signup
|
||||
# Ignore plan_id parameter - this is for free trial signups only
|
||||
# ALWAYS assign the existing free plan for simple signup
|
||||
# No fallbacks: if free plan is misconfigured, surface error immediately
|
||||
try:
|
||||
plan = Plan.objects.get(slug='free-trial', is_active=True)
|
||||
plan = Plan.objects.get(slug='free', is_active=True)
|
||||
except Plan.DoesNotExist:
|
||||
# Fallback to 'free' if free-trial doesn't exist
|
||||
try:
|
||||
plan = Plan.objects.get(slug='free', is_active=True)
|
||||
except Plan.DoesNotExist:
|
||||
# Last fallback: get cheapest active plan
|
||||
plan = Plan.objects.filter(is_active=True).order_by('price').first()
|
||||
if not plan:
|
||||
raise serializers.ValidationError({
|
||||
"plan": "Free trial plan not configured. Please contact support."
|
||||
})
|
||||
raise serializers.ValidationError({
|
||||
"plan": "Free plan not configured. Please contact support."
|
||||
})
|
||||
|
||||
# Generate account name if not provided
|
||||
account_name = validated_data.get('account_name')
|
||||
@@ -364,7 +357,7 @@ class RegisterSerializer(serializers.Serializer):
|
||||
transaction_type='subscription',
|
||||
amount=trial_credits,
|
||||
balance_after=trial_credits,
|
||||
description=f'Free trial credits from {plan.name}',
|
||||
description=f'Free plan credits from {plan.name}',
|
||||
metadata={
|
||||
'plan_slug': plan.slug,
|
||||
'registration': True,
|
||||
|
||||
Reference in New Issue
Block a user