#cristiancalara_best-practices
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/1318139449963446302
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐ happy to help
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hey, yes, I already tested this and it works - but this actually sets the number only when the invoice is draft. So if the user then leaves the invoice as draft and then deletes, a number will be skipped (if another invoice is created at the same time)
So we have Invoice 1 that's created as draft. And then we have Invoice 2 created as draft. Then because the Invoice 1 was still a draft, the user can delete, and we are left with Invoice 2 (basically skipping 1). So that's why I was trying to set the number after it's open (or basically not draft) when deletion is no longer possible
I think in your case you could benefit from https://docs.stripe.com/quotes
once a quote is accepted it gets transformed into an invoice
so you wouldn't have the issue of invoices being deleted
Okay so if any one off invoices need to be created, we can use this approach (basically notifying all the users that they should not manually create an invoice). And for subscriptions, would this approach work? I tested a bit now and it seems that in some cases (when creating the subscription, the invoice.created and finalized are called one after the other - not sure if this means that it could be that the invoice is finalized before the webhook is actually called?) and then on renewal, we have a period where the invoice is draft)
And for subscriptions, would this approach work?
yes
I'm thinking of a workaround for the invoice numbers when converting quotes to subscriptions
Okay I see. I'll try this out - thanks for the quick help
I'm asking my colleagues for solutions
Okay, thanks! I think we might have found another solution (as we mainly care about Romania customers). So we might actually just use Stripe sequential numbers for RO clients, and then for all others we just set random unique number (we don't need sequential for other countries). So our situation might be fixed (still waiting to confirm if this will work). But yeah for the general case where we want more flexibility for the invoice number (i think the use case of country dependent numbers might be a valid one) this will not really work.
do you want to avoid using quotes?
I think in your case it's a good candidate because as you said like customers might accept or not the invoice
which is the reason we introduced the quotes API
i'm not super familiar with quotes and it seems like it will be a bit more effort to implement. i'll try to look a bit over docs for quotes to see how things work (both for subscriptions and as one off use cases)
for subscriptions the invoice would be in a draft for 1h
so you can update the invoice number within this window
yes but if it's in draft, wouldn't users be able to delete it?
or are subscriptions invoices special and even if they are draft they can't be deleted?
yes that's correct
you can void them
but that's something you control
and not your customers
got it I see. in that case this might be an option. I'll see if we do actually need to have sequential numbers for all countries, or we only care about Romania and the others I can just set randomly
if you offer your customers the ability to accept or refuse an invoice today
I think it's worth it to move to quotes
it's not going to be a big effort in my opinion
got it, will consider that, thanks a lot for the help
sure let me know if you need any more help