#jasonkuhrt_api

1 messages ยท Page 1 of 1 (latest)

rapid basinBOT
#

๐Ÿ‘‹ 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.

rancid sphinxBOT
topaz oriole
#

hi! I think there's an add_invoice_items param for that on Subscription Create

warm pilot
#

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.

topaz oriole
#

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

warm pilot
#

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?

warm pilot
#

Ok, so we must do this in order, not parallel, to avoid a race conditon, right?

topaz oriole
warm pilot
#

Got it thanks

#

Appreciate the confirmation!

topaz oriole
#

I'd actually recommend waiting a few seconds because there I've seen delays with this

warm pilot
#

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? ๐Ÿค”

topaz oriole
#

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