#DeputyCheese
1 messages · Page 1 of 1 (latest)
Hi there!
Yes you can update the price interval (for example from month to year), you can learn more about this here https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
And a subscription is not directly tied to a product. Instead the subscription is tied to a price, and the price is tied to a product.
So when you change the subscription price, if the price is tied to a different product, it will also change the product.
Thanks, got it.
\Stripe\Subscription::update('sub_49ty4767H20z6a', [
'cancel_at_period_end' => false,
'proration_behavior' => 'create_prorations',
'items' => [
[
'id' => $subscription->items->data[0]->id,
'price' => 'price_CBb6IXqvTLXp3f',
],
],
]);
If I pass the 'items' like here, will the previous item/price be removed and replaced with the new one or will it be added?
This code is only adding a new price. To delete a price, you have to pass deleted: true https://stripe.com/docs/api/subscriptions/update#update_subscription-items-deleted
Ah okay thanks
So I need 2 request, 1 to delete the previous product/price and 1 to add the new one, right?
Ah wait or can I add both items at the same time?
Both can be done at the same time yes. Keep your existing code above, and just add a new [] to the items with the existing price ID and deleted: true
Okay thank you very much for your help