stripe: Don't change plan tier before the plan becomes live.

For new plans that have not started, the tier change should only
happen when they become live.
This commit is contained in:
Aman Agrawal 2023-12-06 12:35:35 +00:00 committed by Tim Abbott
parent ec7fd94782
commit 860e4f6060
1 changed files with 4 additions and 1 deletions

View File

@ -1246,6 +1246,8 @@ class BillingSession(ABC):
) )
stripe.Invoice.finalize_invoice(stripe_invoice) stripe.Invoice.finalize_invoice(stripe_invoice)
if plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD:
# Tier and usage limit change will happen when plan becomes live.
self.do_change_plan_type(tier=plan_tier) self.do_change_plan_type(tier=plan_tier)
def do_upgrade(self, upgrade_request: UpgradeRequest) -> Dict[str, Any]: def do_upgrade(self, upgrade_request: UpgradeRequest) -> Dict[str, Any]:
@ -1457,6 +1459,7 @@ class BillingSession(ABC):
) )
new_plan.status = CustomerPlan.ACTIVE new_plan.status = CustomerPlan.ACTIVE
new_plan.save(update_fields=["status"]) new_plan.save(update_fields=["status"])
self.do_change_plan_type(tier=new_plan.tier)
return None, LicenseLedger.objects.create( return None, LicenseLedger.objects.create(
plan=new_plan, plan=new_plan,
is_renewal=True, is_renewal=True,