#dyson
1 messages · Page 1 of 1 (latest)
When you say remove prorations from your subscription, do you mean you have a subscription with existing prorations or just that you are trying to avoid prorations when making future changes to your subscriptions?
Do you have a request ID (req_123) from a time you saw this behavior?
since it is a licensed subscription, proration is default whenever the user wants to change tiers, but i want to remove all proration discounts when they try to change, so I want to remove prorations on the subscription's creation
i am currently doing so during a "checkout.session.completed" event
a request id from when the user goes to the customer portal?
I was asking for an ID from when you are making that subscription modify call
I'm not quite wrapping my head around this. Can you give a quick simple example, like say a user starts $10 a month subscription and changes it in this way, what do you want to happen?
I have 3 tiers, $5, $10, and $50. So say the user has the $10/month subscription, if they want to change to the $50 a month, the prorated price is ~$40 right now, but i want it to be $50, the same with $5, the prorated price is $0, but i want it to be $5
That does sound like what proration_behavior='none' should do. Do you have the ID of a subscription that you modified this way that got prorations anyways (sub_123)?
i am new to this so i am not too sure how to get it. do you want something from the printout from this?
subscription = stripe.Subscription.modify(
customer['subscriptions']['data'][0]['id'],
proration_behavior='none',
)
print(subscription)
Or a request ID would be more direct
Yep one sec
can also check your dashboard logs if it is recent https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
To print from your code you can do this https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
req_y1KxnTHzfAVkyG
full code that is being used to make the modify call is
customer = stripe.Customer.retrieve(
"cus_1234",
expand=["subscriptions"],
)
subscription = stripe.Subscription.modify(
customer['subscriptions']['data'][0]['id'],
proration_behavior='none',
)
Gotcha, so that call isn't passing any actual modifications to our backend https://dashboard.stripe.com/test/logs/req_y1KxnTHzfAVkyG
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Oh I got it. One sec looking at that subscription
Actually, I don't see any prorations on that subscription that you made the call in in that request
Can you explain more about what that call was trying to do? I may have misunderstood what you were saying before
If you make that call and pass in an items array, it should make those modifications without any proration
Oh and the other thing to keep in mind is that your code with items would add all three items to the existing subscription
{'price': 'price_1234'},
{'price': 'price_1235'},
{'price': 'price_1236'},
]
subscription = stripe.Subscription.modify(
session['subscription'],
items=items,
proration_behavior='none'
)```
Basically any item is assumed to be something you want to add unless you give it the `id` of an existing subscription item, in which case we modify the existing subscription item to have that new price
so the correct way to remove proration would just be
subscription = stripe.Subscription.modify(
session['subscription'],
proration_behavior='none'
)
or do i need to pass in an items array of id price pairs
the exact work flow is on checkout, get the new subscription that has been made, and remove prorations entirely
to the test i make a stripe.billing_portal.Session and then in there is where i see
which should be $5 instead of 0
this is downgrading from the $10 account
upgrade is siimilar
Oh I think I get the mixup. This code wouldn't make any changes. proration_behavior is a setting per change, not a setting on the subscription itself. So you need to provide proration_behavior='none' when actually changing the subscription items
I am a bit confused by those two examples. Can you send me the checkout session from the first screenshot?
And Checkout can't do upgrades/downgrades as far as I know, where exactly did that second screenshot come from?
so when i go to modify the subscription is should have items = [{'id': subscription_id, 'price': priceForSubscriptionTier}]
Slightly different, not only does the subscription have an ID but all of the subscription's items have an ID https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So you need to retrieve the subscription's items and pass the ID of the item that you want to switch to the new price
so then
items = [{'id': subscription['items']['data'][0]['id'], 'price': priceForSubscriptionTier}]
``` is what i want
Yes, that looks like it should work on one item subscriptions. Are you seeing the results you want in test mode?
it is not, when running the testing code
customer = stripe.Customer.retrieve(
"cus_NEJ1PPglSFDcZf",
expand=["subscriptions"],
)
subscription = stripe.Subscription.modify(
customer['subscriptions']['data'][0]['id'],
items=[{
'id': subscription['items']['data'][0]['id'],
'price': 'price_1MMbKfJf6Tog4xNzy3LvHNwK',
}],
proration_behavior='none',
)
session = stripe.billing_portal.Session.create(
customer="cus_NEJ1PPglSFDcZf",
return_url='https://www.example.com'
)
print(session.url)
i get the same prices as the screenshot above
customer_subscription= sub_1MTqPUJf6Tog4xNz1ZrX30VI
subscription_item=si_NEJ1bj4W96EJ2r
billing session url = https://billing.stripe.com/p/session/test_YWNjdF8xTU1hcXZKZjZUb2c0eE56LF9ORWY4RlNtdzcwSUFCOWxRd2NaRmdQTVhNa1VOelFI0100D5gGShk9
Thanks for the info, checking in to that subscription
For that subscription I only see $10, no prorations
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Though that subscription is already on that price, so modifying it wouldn't change much here
They would be listed as things like "unused time on X plan"
also could the issue be with something other than prorations/ why is the billing portal still showing discounted prices
What the customer portal allows you to do is determined by your settings in the dashboard. You may have "prorate subscription updates" turned on under your settings for changing plans or quantities https://dashboard.stripe.com/settings/billing/portal
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
ah ok that fixed it, thank so you much for all of your patience and help!