#_pablomn
1 messages · Page 1 of 1 (latest)
Hi 👋 that approach won't work as metadata is not automatically copied from one object to related objects. So the Charges you're looking for won't have the metadata you're trying to query for so you won't see any results.
I'm not quite sure yet. With the approach you're describing, it sounds like it will be possible to have Invoice Items on a single Invoice that have different metadata because their associated with different buildings. Is that a correct understanding?
yeah. something like that.
I mean, we want to have
1 complete invoice that we send at the end of each month where we specify:
- The Charge for the monthly subscription
- The Charge for each extra "Service" that customer have used
so that's for the Customer while we also need to be able that the Owners of the buildings to be able what charges their Residents have
this invoice for example
The reason I'm asking, is because an Invoice creates a single Charge object. There isn't a unique Charge for each Invoice Item. So if you can mingle building Invoice Items on a single Invoice, then the Charge for that Invoice will also be comingled and you won't be able to associate a Charge with a specific building.
ok well. Regarding the metadata: No, all invoice-items that I'm adding are always the same (buildingId: 1234), so I was hoping that somehow that metadata would be "copied" to the "Invoice" and with that also be copied to the "Charge"
Gotcha. That copying does not happen automatically, it is something you would need to build. My thought is that you can put the metadata that you want to reference on the Invoice object level. Then later when trying to find the related charge you can do a search for the Invoice you're looking for, and then follow the chain of objects to find the associated Charge for that Invoice.
Thanks, ok I think that's something I was going to endup doing.
Now, I think I can retrieve the Upcoming Invoice (so I can add the buildingID metadata as soon as I add the InvoiceItem).. but I am not sure if I can UPDATE the upcomingInvoice with metadata... is that possible?
No, retrieving an upcoming Invoice only generates a preview of the next Invoice that will be generated for the Customer. You can't pass metadata there as the Invoice isn't actually created and those details won't persist.
I see....
Interesting... and it makes much sense
so what would be a good approach if I want to somehow "flag" the invoice when it is ready to be "captured"
I meant to say: As soon as the invoice is ready / created
Are you making the requests to create the Invoices, or are they being automatically created for you by a Subscription?
they are created automatically
Gotcha, then you will likely want to listen for Invoice related Events, I think invoice.finalized sounds like a good fit based on what you're describing:
https://stripe.com/docs/api/events/types#event_types-invoice.finalized
But you can use Test Clocks to run a test Subscription through its entire lifecycle, so you can see exactly which Events are generated and when to make sure you find one that best suits your needs:
https://stripe.com/docs/billing/testing/test-clocks