#haris-subscriptions
1 messages · Page 1 of 1 (latest)
Hi there!
You can use the Upcoming Invoice to preview changes to a subscription
https://stripe.com/docs/api/invoices/upcoming?lang=node
but when i add subscription items to it
it actually add to the current subscription means it adds the new amount to the previous ones
You can add additional invoice items, or you can update existing ones with the Upcoming Invoice endpoint. For this to work you need to pass the subscription item ID with https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items-id
now i have 2 prices
new_price_id_1 and new_price_id_2
which i want to update in a current subscription and want to swap or substitute with the prices old_price_id_1 and old_price_id_2 in the current subscription
now before subscription_update i want to show an estimated invoice (prorated) to the customer
can you specifically tell what to do
$stripe->invoices->upcoming([
'customer' => 'cus_LmaGSLEiHV8W3G',
'subscription_item'=>[[
'price'=>'new_price_id_1'
],[
'price'=>'new_price_id_2'
]]
]);
im doing this right now
how can i tell this api to substitute the price_ids or swap the price_ids and not to just add to the previous ones
@stable niche and also its recurring as it is the subscription not a one time charge
This code is adding new prices, not editing existing prices. To edit existing prices, you should do someting like this:
$stripe->invoices->upcoming([
'customer' => 'cus_LmaGSLEiHV8W3G',
'subscription_item'=>[[
'price'=>'new_price_id_1',
'id'=>'si_xxx' // the subscription item ID of the price you want to update
],[
'price'=>'new_price_id_2',
'id'=>'si_yyy' // the subscription item ID of the price you want to update
]]
]);
okay now that make some sense
let me try
if get any issue will ping you back in the same thread
thanks
You cannot update a subscription item without a subscription.
its giving this error
@stable niche
it is already subscribed customer
You cannot update a subscription item without a subscription.
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_BOHbR5s0CKZmWA
Response body
{ "error": { "message": "You cannot update a subscription item without a subscription.", "type": "invalid_request_error" } }
Request query parameters
{ "subscription_items": { "0": { "id": "si_LvfU9EQJKjyI4f", "price": "price_1L7dUVJOIuKIWiW6CO9hlV3a" }, "1": { "quantity": "1", "price": "price_1L7dUyJOIuKIWiW6YQaZ876U" } }, "customer": "cus_LvfPjrCBqO7zC4" }
here i have only 1 old price that i have to substitute or swap with.(first one)
and second im adding a new price with quantity
@stable niche
Yes, because you need to set the subscription ID in the subscription parameter (sorry I missed that earlier) https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription