#driveroval

1 messages ยท Page 1 of 1 (latest)

dark inletBOT
dawn sage
#

Can you point to the specific parameters/endpoints in our API reference? Or show me in the docs where you're seeing both?

candid copper
dawn sage
#

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

https://stripe.com/docs/api/invoiceitems

candid copper
#

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

dawn sage
#

They're the same thing

candid copper
#

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.

dawn sage
#

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

candid copper
#

I'm working with subscriptions, so I assume Stripe does it right for me

dawn sage
#

Correct

candid copper
dawn sage
#

It's created when the Subscription is created

candid copper
#

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

dawn sage
#

Ahhhhh, okay. I see what you're saying now. Give me a second to summarize

candid copper
#

I see that the thing may be related with this

dawn sage
#

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?

candid copper
#

I'm trying to reflect invoices and items in my system

dawn sage
#

Right, but for what purpose? Why not listen for invoice.updated and update your database when that webhook comes in?

candid copper
#

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

candid copper
dawn sage
#

I would should just use an ORM to store the whole Invoice object, including both line items and Invoice Items

candid copper
#

Do you mean, just save the JSON in a field there?

dawn sage
#

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

dawn sage
#

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

candid copper
#

yes, the UI needs the info from the items, like description, quantity, etc

#

so I need the objects

dawn sage
#

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

candid copper
#

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?

dawn sage
#

Unfortunately not. You would have to compare the diff on invoice.updated in that case to see if they changed.

candid copper
#

ok, thanks for your help ๐Ÿ™‚