#jasonkuhrt_api
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/1217806640200417342
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi @topaz oriole that wasn't my question though
I am canceling a subscription, but need to add some line items before doing so.
I need the user to get charged a final amount, with a calculated adjustment we make on our side.
oh sorry didn't see the word cancelled
then yes that is a seperate API call to first add the invoice item, and then do DELETE subscriptions/sub_xxx?invoice_now=true
And, can I do them in parallel or not? That's the thing I'm not sure about. What is the "state machine" here on Stripe's side.
Once a subscription is canceneld, may invoice items still be created immedaitely after?
no
Ok, so we must do this in order, not parallel, to avoid a race conditon, right?
no, you'd do it serially. Add the Invoice item, wait for the response, and then call the cancel subscription API
I'd actually recommend waiting a few seconds because there I've seen delays with this
Are you saying despite a 200 response for the line item add, there could be cases where canceling the subscription immediately AFTER that 200 could still lead to the line item not being present? ๐ค
shoudlnt happen but it's been a problem in the past
for example we changed how Invoice creation works so in current API versions you create an Invoice first and then add items to it, instead of the old way where you'd add items and then create the Invoice to "suck them in" , partially because that flow often had race conditions
So same idea. if you want to be sure, create the invoiceitem, maybe wait a second, and check with https://docs.stripe.com/api/invoiceitems/list#list_invoiceitems-customer that it's showing as pending before callin the delete Subscription API