From 860e4f6060c6726e2c249d2bae71d29d469a1b95 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Wed, 6 Dec 2023 12:35:35 +0000 Subject: [PATCH] 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. --- corporate/lib/stripe.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 7110246646..3ba783cf44 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -1246,7 +1246,9 @@ class BillingSession(ABC): ) stripe.Invoice.finalize_invoice(stripe_invoice) - self.do_change_plan_type(tier=plan_tier) + 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) def do_upgrade(self, upgrade_request: UpgradeRequest) -> Dict[str, Any]: customer = self.get_customer() @@ -1457,6 +1459,7 @@ class BillingSession(ABC): ) new_plan.status = CustomerPlan.ACTIVE new_plan.save(update_fields=["status"]) + self.do_change_plan_type(tier=new_plan.tier) return None, LicenseLedger.objects.create( plan=new_plan, is_renewal=True,