-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing subscription's plan ignores quantity #388
Comments
@alanhamlett Thanks a lot for the report! I think that the issue here is that We'll likely need to special-case this in the library. Assigning to @ob-stripe who was looking into it! |
This issue is caused by the fact that the Python library will only register an attribute as an unsaved value when it is updated with a different value: >>> s = stripe.Subscription.retrieve('sub_...')
>>> s.quantity
1
>>> s.quantity = 1
>>> s._unsaved_values
set([])
>>> s.quantity = 2
set(['quantity']) This behavior is different from most of our other libraries, where attributes are registered as unsaved on assignment, regardless of the new value. E.g. in Ruby: [1] pry(main)> s = Stripe::Subscription.retrieve('sub_BqStq3lplpOQKs')
[2] pry(main)> s.quantity
=> 1
[3] pry(main)> s.quantity = 1
[4] pry(main)> s.instance_variable_get(:@unsaved_values)
=> #<Set: {:quantity}> I'll push a fix, but in the meantime a simple workaround is to set a different value, then immediately set it back. E.g. in your case: subscription.plan = 'plan2'
subscription.quantity = 42
subscription.quantity = 2
subscription.save() |
Pushed a fix with @ob-stripe's patch in 1.77.1. Thanks @ob-stripe / @remi-stripe! |
Thanks! |
Description
When a customer has an existing subscription with quantity 2 and plan
plan1
, updating the subscription's plan always uses quantity 1.Example
Stripe logging shows only
plan_id
is sent to the api when callingsubscription.save()
.The text was updated successfully, but these errors were encountered: