#codeninja-proration
1 messages · Page 1 of 1 (latest)
Hi thanks for your response, we did try that but unfortunately still happening
Here is our sample code
$subscription = \Stripe\Subscription::create([
'customer' => $stripe_customer_id,
'items' => [
[
'plan' => $planID
],
],
'proration_behavior' => 'none',
'cancel_at_period_end' => true,
'expand' => ['latest_invoice.payment_intent'],
'payment_behavior' => 'error_if_incomplete',
'metadata' => []
]);
This is a Subscription create. Where do you see it's still prorated?
I would be happy to look at some example Subscription Id
Sure let me just check
Hey sorry for the late response I was checking the logs. Here is the Id
sub_1KJC9nFf1GyfQkaKHwpl7uTk
I think thats manual cancellation requested by customer
by customer portal? maybe?
Yeah I can see it's prorated. Still don't have an idea why. My colleague will be here soon to continue assisting you
Hi! I'm taking over this thread.
I think this is expected because proration isn't a mode or setting. Instead it's an option that you choose on each API call that you make, and the default value is on.
Hi @tranquil yarrow , have you seen our code? Is there something we need to change or add?
$subscription = \Stripe\Subscription::create([
'customer' => $stripe_customer_id,
'items' => [
[
'plan' => $planID
],
],
'proration_behavior' => 'none',
'cancel_at_period_end' => true,
'expand' => ['latest_invoice.payment_intent'],
'payment_behavior' => 'error_if_incomplete',
'metadata' => []
]);
Btw thanks @short moss
Sorry if I wasn't clear! This code is correct. But every time you make an update to the subscription, you would need to pass proration_behavior: none to not have any proration.
If you want to proration when cancelling a subscription with the billing portal, the only option is to use this setting in the dashbaord, to cancel the subscription at the end of the period https://dashboard.stripe.com/test/settings/billing/portal
But every time you make an update to the subscription, you would need to pass proration_behavior: none to not have any proration.
We are not doing any Subscription update using API so all of our Subscription proration_behavior is set to none
Let me try to explain this differently: proration_behavior isn't a mode that you set once and is automatically applied to all subscription udpates.** It's an option** that needs to be passed every time the subscription is updated, and if not set the default value is on. When using the customer portal you cannot change how the API call is made, so by default it will have proration_behavior: on.
If you want to cancel the subscription you have two choice:
- Cancel the subscription immediately, which will generate proration no matter what
- Cancel the subscription at the end of the period, which will never generate proration
So proration only generates when cancelling a subscription?
Or updating subscription as you have mentioned, just to make it clear
..but some of our subscription cancelled at the end of the period, and still generates proration
..but some of our subscription cancelled at the end of the period, and still generates proration
Can you share the subscription IDs? Also did you use the setting "cancel at the end of the billing period" (or used thecancel_at_period_endparameter when using the API)
Yup we used cancel_at_period_end = true
Can you share the subscription IDs where you saw proration with cancel_at_period_end = true?
sub_1K6IZMFf1GyfQkaKQInskyXg
sub_1KJC9nFf1GyfQkaKHwpl7uTk
sub_1Jst6cFf1GyfQkaKjRX1ElT8
Thanks!
I checked one subscription, and I see in the request: cancel_at: "1658102400" https://dashboard.stripe.com/logs/req_wFde6pZP2djsdG
So you are not using cancel_at_period_end
To not get proration we recommend using cancel_at_period_end.
Otherwise, if you have to use cancel_at, then you need to compute the exact timestamp of when the subscription's billing cycle for that period would end. Even being off by a few seconds would cause proration
You mean we can just replace cancel_at with cancel_at_period_end is that correct ?
Yes, cancel_at_period_end: true means the subscription will automatically cancel at the end of the period with no proration.