#madwifi_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1283411666536632322
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- madwifi_best-practices, 2 days ago, 10 messages
hi there!
Hi
But when I call with this, the existing line items are not removed from the invoice, instead new line item with the given plan is added.
I'm not sure what you mean. can you clarify why you want existing line items to be removed?
I am trying to show the customer how the subscription would look like before they accept the update. For example, the customer might have balance, and the plan may be different, they might have coupon. So the customer should be aware on what their updated subscription should look like. So it is important to remove the existing line items from the upcoming invoice as well as this is what would be done to their existing subscription.
Currently because of this, an update to a monthly subscription into yearly, would yield in the period_end to show as next month, instead of next year. hope this makes sense @chilly dust
Upcoming invoice endpoint automatically appends line items when you set prices/plans to items array
You need to explicitly specify what line items you want to remove and pass deleted parameter for that item: https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-subscription_details-items-deleted
let me try
{
subscription: sub_id,
subscription_details: {
proration_behavior: 'create_prorations',
items: [
{
id: sub_item_id,
deleted: true,
},
{
discounts: next_discount,
plan: plan_id,
}
]
}
}
)```
Tried with this updated code, but still the `lines` are coming back as 2. FWIW, I tried to provide the `quantity: 0` but it didn't work either. I think the `sub_item_id` -- which is subscription's item ID, is not getting selected in the above code.
Can you share a request ID for the example request? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Additionally, the response you're getting back..
Ah the other item is due to proration
oh!
look at
"description": "Unused time on Alo Moves Membership (with $29.00 off) after 11 Sep 2024",
let me try and remove this.
@barren forum I removed the proration. and it is still showing the same (req_GYirE2uG1EtVDO) and the descriptions in the line items are:
[{:id=>"ii_1PxqZh2L3GhbnQDbkX7BOEt6", :desc=>"Unused time on ... (with $29.00 off) after 11 Sep 2024"}, {:id=>"sli_156a192L3GhbnQDb3a27d658", :desc=>"1 ร ... (at $129.99 / year)"}]
How are you removing proration? I suspect your settings not getting applied
In the request I'm not sending the proration_behavior
should I use proration_behavior=none
yes
OK
we prorate by default
hmm, looks like without proration, I would not get the remaining amount, but with proration, the date needs to be taken from the lines of "type": "subscription", . I was taking it earlier from the period_end of the invoice. which was not correct here.
This is the mapping of the relevant values from the lines of invoice.
[{:id=>"ii_1PxqlJ2L3GhbnQDbRIQd9A0h", :type=>"invoiceitem", :end=>2024-10-03 15:47:08 +0530}, {:id=>"sli_14a0fc2L3GhbnQDbfbbbe780", :type=>"subscription", :end=>2025-09-11 19:09:13 +0530}]
@barren forum Thanks for the help.