#Julien
1 messages · Page 1 of 1 (latest)
Are you referring to this thread? https://discord.com/channels/841573134531821608/1083079628089991219
exactly!
Can you share the event ID (evt_xxx) that you're comparing it with and the response that you tried to retrieve the invoice?
If you're comparing the response with an old event, the values are likely to be different
yes!
this is the event from 7th of september
{
"object": {
"id": "in_1LeSlxC8pVNfXauyLsNvTCKv",
"object": "invoice",
"amount_due": 434,
"charge": "py_3LeTlbC8pVNfXauy1qz8RcCw",
"currency": "eur",
"customer": "cus_LhuRgBn0xlT0Da",
"default_payment_method": null,
"default_source": null,
"number": "5E35DC6C-0020",
"payment_intent": "pi_3LeTlbC8pVNfXauy1Xdq0eJU",
"period_end": 1662336000,
"period_start": 1662336000,
"status": "paid",
"subscription": "sub_1LeSlxC8pVNfXauySjnnMgOc",
"total": 434,
...
}
}
evt_1LfIYVC8pVNfXauy8oh113ru
basically, the information i need is the line item's subscription period, which is from septembre 5th (1662336000) to october 5th. How can I retrieve this?
In the invoice object there is a property lines
https://stripe.com/docs/api/invoices/object#invoice_object-lines
For each line_item there is period attribut
https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-period
ok great i will check that out, thank you!
Also, while I am at it, how could I avoid N+1 queries when iterating over invoices ? My sithation is, I need to iterate over all payments & refunds for a specific product in order to generate an accountability CSV file
Some information is in the invoice, some in the payment_intent, and some in the subscription and/or invoice line item
Is there a way to batch all my requests in one single request, and if so would you suggest to nest this request rather on the subscription api, on the invoice api or on the payment_intent api ?
There is no batch request in Stripe APIs,
but you can expand
https://stripe.com/docs/api/expanding_objects
Try check also Stripe API if you can get a summarized report
https://stripe.com/docs/reports/api
Yes, I was thinking of the expand parameter. And can you nest an expanded object ? And can you expand objects within a collection ?
Never heard of the Reporting API before! I will have a look at it, thank you!
And can you nest an expanded object ?
Yes
And can you expand objects within a collection ?
Yes
You can check some the use cases of expand:
https://stripe.com/docs/expand/use-cases