#Sen-subscription-update

1 messages · Page 1 of 1 (latest)

rapid basalt
#

Hey there 👋 please bear with me a moment.

#

Apologies, but I don't readily recognize that syntax, which of our libraries are you using?

covert anvil
#

It's PHP

outer flower
#

Yes that is PHP

covert anvil
#

@outer flower you're missing a set of brackets, it's an array of object

#
'items' => [
   [ 
    'price' => price_1XXXXXXXXXXXMAqAyO 
   ]
] 

is more like what you want

#

note though if you do it that way you are adding a new price to the subscription, which might not be what you wanted.

if you want to change the existing price you have to pass an ID as well :

'items' => [
    [
      'id' => $subscription->items->data[0]->id,
      'price' => 'price_CBb6IXqvTLXp3f',
    ],
  ],

(https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing)

outer flower
#

Thanks. It works fine.
Set 'proration_behavior' => 'none', But immediatly invoice not generated.

#

I have seen inside API docs where proration_behavior as create_prorations But i think it will count proration

covert anvil
#

if you use none then yes, you're telling us to not create any proration , so there's no invoice for the update.

#

if use create_prorations proration is calculated and is part of the next invoice, whenever that is

outer flower
#

But if I want to immediately payment without proration value then??
Like if the switch plan value is $50 then need to immediately payment

covert anvil
#

payment of what, $50(the price of the new plan), with no prorated discount or debit for the switch?

#

in that case the easiest way is to pass proration_behavior=>"none" and also billing_cycle_anchor=>"now" to reset the cycle and issue a new invoice, I think that works

outer flower
#

I have tried the above parameters with a subscription update.
It works as wanted.
Thank you!!