Invoice assignmet for IIs missing
patroqueeet opened this issue · comments
Describe the bug
Create pending line item for invoice manually in stripe in advance for upcoming subscription invoice ( inv not created yet)). Once Stripe sends the Invoice.created
event, the LineItem().invoice_item.invoice
stays empty. As we are creating the invoice pdf based on invoice.subscription.line_items
plus invoice.invoice_items
the latter ones are missing in our invoice pdf.
To Reproduce
I tried to reproduce it. But doing an api_retrieve() and then sync_from_stripe_data() fixes this issue for the objects. Cannot replay the web hook call.
Software versions
- Dj-Stripe version: 2.8.2
- Python version: 3.11
- Django version: 4.2
- Stripe API version: 2017 and 2020
- Database type and version: psql 11
@patroqueeet Finally was able to reproduce this in the following scenario:
- Create a subscription with 1 or more recurring Price objects
- After the upcoming invoice is created (and the
invoice.created
event is fired), update the subscription to also include aone time
price object. - The invoice now will not have the
invoice_item
object associated with it.
Please note that in case the subscription is created with a recurring and a one time price, everything works as expected. It is only when the subscription gets updated with a one time object that this issue is observed. I'm just curious about the following:
- Why are you updating subscriptions? This might be indicative of a deeper issue in the way the code is structured.
- Why are you not using the hosted Invoices? I think they can also be whitelisted but I am not sure about that.
re 1) customers buy a SaaS service but then they are requesting some manual additional service. instead of creating a fresh invoice we add a pending invoice item in the stripe UI to be charged along the next subscription based invoice.
re 2) our system was created, when stripe did not have this feature and as of now we don't want stripe to appear in our customer communication. so all forms, emails, pdfs are managed and created on our side.