Invoice: Add support for Create Preview Invoice API#249
Invoice: Add support for Create Preview Invoice API#249bravier merged 1 commit intoadrienverge:masterfrom
Conversation
| # Do not store this invoice | ||
| del store[cls.object + ':' + invoice.id] | ||
|
|
||
| invoice.id = f'upcoming_{invoice.id}' |
There was a problem hiding this comment.
The Create Preview Invoice API adds an ID to the returned invoice whereas the Upcoming Invoice API didn't do that.
| subscription_trial_end=trial_end) | ||
|
|
||
| # Do not store this invoice | ||
| del store[cls.object + ':' + invoice.id] |
There was a problem hiding this comment.
The Stripe docs says that an upcoming invoice can be retrieved via the /v1/invoices/id for 72 hours (cf https://docs.stripe.com/invoicing/preview), so maybe it would make more sense to keep these upcoming invoice in the store ?
There was a problem hiding this comment.
You're right, thanks for pointing this out.
I was misguided by the API doc that says:
Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice.
https://docs.stripe.com/api/invoices/create_preview
I don't want to implement such "temporary" store in localstripe that would complicate things.
Also, please note that the /v1/invoices/:id route is not supported in localstripe right now so storing the invoice would not be useful.
Maybe I can change the comment to says that real Stripe servers keep these invoices for a limited amount of time? What do you think?
There was a problem hiding this comment.
It would work for me. I'm curious about what @feliixx thinks!
There was a problem hiding this comment.
I don't want to implement such "temporary" store in localstripe that would complicate things.
+1 not to implement a "temporary" store: we don't need to access the preview invoices via the /v1/invoices/:id route right now so it's not worth the extra complexity
Also, please note that the /v1/invoices/:id route is not supported in localstripe right now so storing the invoice would not be useful.
Ok interesting, I wasn't aware of that !
Maybe I can change the comment to says that real Stripe servers keep these invoices for a limited amount of time? What do you think?
Seems like the best solution 👍
590adb3 to
019a82f
Compare
adrienverge
left a comment
There was a problem hiding this comment.
Thanks for taking care of that!
| -d subscription_details[default_tax_rates][0]=$txr1 \ | ||
| -d subscription_details[items][0][id]=si_RBrVStcKDimMnp \ | ||
| -d subscription_details[items][0][plan]=basique-annuel \ | ||
| -d subscription_details[proration_date]=1504182686 |
There was a problem hiding this comment.
I read that this is an old timestamp (from 2017), so I guess that if it works today, it will keep working in a month or a year 👍
The Upcoming Invoice API is deprecated and removed since API version 2025-03-31: https://docs.stripe.com/changelog/basil/2025-03-31/invoice-preview-api-deprecations The new Create Preview Invoice API is almost the same and only the parameters structure changed. Reference: https://docs.stripe.com/api/invoices/create_preview
019a82f to
9e0c094
Compare
|
Thanks! |
The Upcoming Invoice API is deprecated and removed since API version 2025-03-31:
https://docs.stripe.com/changelog/basil/2025-03-31/invoice-preview-api-deprecations
The new Create Preview Invoice API is almost the same and only the parameters structure changed.
Reference: https://docs.stripe.com/api/invoices/create_preview