InvoiceItem.api_retrieve() always fails
See original GitHub issueInvoiceItem is … weird, to say the least.
There’s this whole thing going on:
@classmethod
def _stripe_object_to_invoice_items(cls, target_cls, data, invoice):
lines = data.get("lines")
if not lines:
return []
invoiceitems = []
for line in lines.get("data", []):
if invoice.stripe_id:
save = True
line.setdefault("invoice", invoice.stripe_id)
if line.get("type") == "subscription":
# Lines for subscriptions need to be keyed based on invoice and
# subscription, because their id is *just* the subscription
# when received from Stripe. This means that future updates to
# a subscription will change previously saved invoices - Doing
# the composite key avoids this.
if not line["id"].startswith(invoice.stripe_id):
line["id"] = "{invoice_id}-{subscription_id}".format(
invoice_id=invoice.stripe_id,
subscription_id=line["id"])
else:
# Don't save invoice items for ephemeral invoices
save = False
line.setdefault("customer", invoice.customer.stripe_id)
line.setdefault("date", int(dateformat.format(invoice.date, 'U')))
item, _ = target_cls._get_or_create_from_stripe_object(
line, refetch=False, save=save)
invoiceitems.append(item)
return invoiceitems
So, the stripe_id
of InvoiceItem is, for subscriptions at least, never correct.
I don’t even know what’s happening here. Stripe doesn’t seem to be using InvoiceItem by itself. The only InvoiceItem I get when doing InvoiceItem.list() is Unused time on $plan (with 100% off) after 09 Apr 2017
, which is an item which begins with ii_
.
I think dj-stripe might be mistaking InvoiceItem for SubscriptionItem. Or, well, I’m not sure. I don’t know what’s going on. Anyone more familiar with the system?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Stripe API reference – Invoice Items – curl
Each entry in the array is a separate invoice item object. If no more invoice items are available, the resulting array will be...
Read more >Stripe invoice items not always being sent together in one ...
I think the expected behaviour is that invoice items are added to the customer's upcoming invoice not the current.
Read more >Models - Dj-Stripe
When left blank, the invoice item will be added to the next upcoming ... are still accessible by the Stripe API and sync...
Read more >Invoice Item don't appear always - WordPress.org
Hi, I am trying to write an invoice using the existing invoice items. But the invoice items don't appear every time. Sometimes i...
Read more >Type-Directed Program Synthesis for RESTful APIs - arXiv
(e.g. programs that always return an empty array), re- ... second program always fails at run time, because a successful.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In db7c7dd30a8853aec3477c3064fb5cf3c887fdde, a new management command has been implemented to migrate the old InvoiceItem IDs to the new format.
Why isn’t this part of database migrations?
Possibly… Stripe changed a lot about the II interface.