#ogun
1 messages ยท Page 1 of 1 (latest)
Hello
Hi ๐ yes, updating a Subscription can trigger the calculation of a prorated amount to be charged on the next Invoice, and creating prorations is the default behavior of the API.
Are you currently passing a value for proration_behavior in your update requests?
https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Is that possible to charge it immediatly instead of next invoice ?
proration_behavior => always_invoice
Yup, always_invoice sounds like it may be what you're looking for.
When i did that, it creates invoice like that. second package is already $199.99. it must charge ($199.99 - $149.99)
That is showing an upcoming Invoice, and neither of the lines on it appear to be one of our proration lines. Can you share the ID of the Subscription that you're using for your testing?
Subscription ID: sub_1MriDwErkdUQDVMofc3NJIWK
I removed to customer and tried again. Now it charged like that
Were you trying to update the Price the Subscription was currently subscribed to, or add another Price to the Subscription?
update it
PHP Subscription::update method
$payload = [
'payment_behavior' => 'allow_incomplete',
'proration_behavior' => 'always_invoice',
'items' => [
['price' => $price_id,]
],
'metadata' => $metadata,
];
Gotcha, in that case you need to pass the ID of the Subscription Item on the Subscription that you want to update in the items.id field, otherwise it will add a new item to the Subscription:
https://stripe.com/docs/api/subscriptions/update#update_subscription-items-id
Additionally it looks like you aren't progressing the test clock's time before creating the update request, so there won't really be any prorations to calculate since the time of the test clock is the same for the creation and update requests.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Oh okay i got it. I think i fixed it just like you said. Thank you very much
Any time!