diff --git a/services/billing.py b/services/billing.py index 3955c3ae13..55b36df569 100644 --- a/services/billing.py +++ b/services/billing.py @@ -367,6 +367,8 @@ def create_checkout_session(self, owner: Owner, desired_plan): customer = owner.stripe_customer_id customer_email = None + new_plan = settings.STRIPE_PLAN_IDS[desired_plan["value"]] + session = stripe.checkout.Session.create( billing_address_collection="required", payment_method_types=["card"], @@ -379,7 +381,7 @@ def create_checkout_session(self, owner: Owner, desired_plan): subscription_data={ "items": [ { - "plan": settings.STRIPE_PLAN_IDS[desired_plan["value"]], + "plan": self.format_plan_value(new_plan), "quantity": desired_plan["quantity"], } ], @@ -391,6 +393,9 @@ def create_checkout_session(self, owner: Owner, desired_plan): f"Stripe Checkout Session created successfully for owner {owner.ownerid} by user #{self.requesting_user.ownerid}" ) return session["id"] + + def format_plan_value(self, plan_value): + return plan_value[:-1] + '-' + plan_value[-1] @_log_stripe_error def update_payment_method(self, owner, payment_method):