#ogun

1 messages ยท Page 1 of 1 (latest)

solid vectorBOT
sage marlin
#

Hello

keen horizon
#

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

sage marlin
#

Is that possible to charge it immediatly instead of next invoice ?

#

proration_behavior => always_invoice

keen horizon
#

Yup, always_invoice sounds like it may be what you're looking for.

sage marlin
#

When i did that, it creates invoice like that. second package is already $199.99. it must charge ($199.99 - $149.99)

keen horizon
#

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?

sage marlin
#

Subscription ID: sub_1MriDwErkdUQDVMofc3NJIWK

#

I removed to customer and tried again. Now it charged like that

keen horizon
#

Were you trying to update the Price the Subscription was currently subscribed to, or add another Price to the Subscription?

sage marlin
#

update it

#

PHP Subscription::update method

#
 $payload = [
            'payment_behavior' => 'allow_incomplete',
            'proration_behavior' => 'always_invoice',
            'items' => [
                ['price' => $price_id,]
            ],
            'metadata' => $metadata,
        ];
keen horizon
#

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.

sage marlin
#

Oh okay i got it. I think i fixed it just like you said. Thank you very much

keen horizon
#

Any time!