#driveroval
1 messages ยท Page 1 of 1 (latest)
Can you point to the specific parameters/endpoints in our API reference? Or show me in the docs where you're seeing both?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I assume the definition of Invoice Item here answers this, no?
Invoice Items represent the component lines of an invoice. An invoice item is added to an invoice by creating or updating it with an invoice field, at which point it will be included as an invoice line item within invoice.lines
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I'm asking because I see that the invoice can have lines, but no items. The problem is that in the API isn't the other definition, just one.
it doesn't make sense for me
They're the same thing
So, what about this?
Let me explain you my use case. I need to keep synched invoices and items, so I see there is a webhook for invoiceItems (and not for lines), but when I start testing around, I see that the invoice items could be empty while the line items have elements.
You have to associate the Invoice Item with an Invoice when you create it in order for it to show up on the Invoice
Sometimes a line item will be added automatically to the invoice too, so that's worth noting
I'm working with subscriptions, so I assume Stripe does it right for me
Correct
so, how this happened?
It's created when the Subscription is created
but, how do you explain the line item is there and the item is not?
I need to understand if I can trust in teh webhook invoiceItem.created for synching
Ahhhhh, okay. I see what you're saying now. Give me a second to summarize
I see that the thing may be related with this
So the Subscription will create Invoices automatically. You can add additional Invoice Items by explicitly creating them and associating them with an Invoice. Subscription Items are the objects that generate line items.
Circling back a little bit, what are you trying to sync and why?
I'm trying to reflect invoices and items in my system
Right, but for what purpose? Why not listen for invoice.updated and update your database when that webhook comes in?
so invoices could have both, items, and line items at the same time? The first ones generated by subscriptions and the second ones added manually
Do you recommend just using the invoice updated and update both objects from my side? In that case which kind of item I should save in the DB, line_item or invoice_item? Or both?
I would should just use an ORM to store the whole Invoice object, including both line items and Invoice Items
Do you mean, just save the JSON in a field there?
You could do that, but it really depends on why you want this info stored in the first place. Like, the logic you perform on stuff in your database sort of dictates the best organization of the storage
?
For example: if you just need the ID of an Invoice Item so that you can make a GET request to retrieve it's info once and a while, then you could just store the ID of the Invoice Item in it's own column next to the Invoice object and it's data. But if you need to access the amount of the Invoice Item all the time, it might make sense to give Invoice Items their own table in the database
yes, the UI needs the info from the items, like description, quantity, etc
so I need the objects
That makes sense. So you want a separate table for the Invoice Items I would assume. You can get that from invoice.updated and/or invoiceitem.created
yes, my problem is that if I use invoice's events, I need to recalculate if items has been deleted or not, so I would prefer using a webhook, but invoiceitem.created and invoiceitem.deleted is just for invoice items while I use the line items because I'm working with subscriptions
Is there any webhook for the line items?
Unfortunately not. You would have to compare the diff on invoice.updated in that case to see if they changed.
ok, thanks for your help ๐