#Ali Raza
1 messages · Page 1 of 1 (latest)
Hi there!
Hi
I guess this is:
my question is i want to save all invoices of specific subscription with start and end date of invoices
@mellow laurel both dates looks same
Is this the first invoice of a subscription? If so, it's expected that both will be equal (and correspond to the date the subscription was created)
sub_1LnWDTLyP1jWY3OLaiqzWvHj
the invoices of this subscription should return these dates
29 Sep - 29 OCT
29 OCT - 29 NOV
how i can get this
@mellow laurel
i have 2 invoices against this subscription
Yes, have you checked period_start and period_end? Execept for the first invoice of the subscription, it should match the dates you are looking for.
in_1LnWDTLyP1jWY3OLYHMVqbQ4
why it's showing same for this subcription
@mellow laurel
I explained that earlier:
Is this the first invoice of a subscription? If so, it's expected that both will be equal (and correspond to the date the subscription was created)
29 Sep - 29 OCT
29 OCT - 29 NOV
how i can get this
for saving in database
@mellow laurel in_1LyOWULyP1jWY3OLqQvWkUTW this invoice number is showing november in stripe dashbaord
Okay I found a way to always get the start and end date of an invoice, event if it's the first one:
- retreive the invoice with
expand: ["lines"] - then look at
invoice.line.data[].periodand it contains bothstartandend.
https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-period
expand with invoice id?
You retrieve the invoice with https://stripe.com/docs/api/invoices/retrieve and add expand: ["lines"] so that it returns the lines of the invoice.
$invoie=$stripe->invoices->retrieve(
$value->id,
['expand' => 'lines']
);
like that?
in php
@mellow laurel
That looks correct to me. Have you tried this code?
invalid array returned
Oh wait, expand is itself a array. So it should be something like this I think:
$invoice = $stripe->invoices->retrieve(
$value->id,
[
'expand' => [ 'lines' ]
]
);
Happy to help 🙂