stripe update subscription python

Viewed 274

I have three stripe plans (free, normal, premium) defined. When a user wants to upgrade (e.g. from normal to premium user), then the user should get a new subscription with the premium plan. This is my code so far:

subscription = stripe.Subscription.modify(
                    id=stripe_subscription_id,
                    items=[
                        {
                            'plan': stripe_plan_id,
                        }
                    ],
                )

In the docu there is no need for another required argument. But I get this error:

modify() missing 1 required positional argument: 'sid'

Does somebody know what this parameter means and where do I place it in the code?

2 Answers

Try the below code. You were specifying id as keyword argument and that's why it was failing

subscription = stripe.Subscription.modify(
                    stripe_subscription_id,
                    items=[
                        {
                            'plan': stripe_plan_id,
                        }
                    ],
                )

I think you may want to try removing the id=, because that changes the parameter from a "positional argument" to a "keyword argument".

Related