#KarlS-retrieving-invoice-line-items
1 messages ยท Page 1 of 1 (latest)
Hi there!
Can you share how you are retrieving these line items currently?
And then how you are looping
k
`
public StripeInvoiceLines(string key, string InvoiceID, string LastLineID = null)
{
_key = key;
Lines = new StripeList<InvoiceLineItem>();
StripeClient client = new StripeClient(_key);
InvoiceService invoiceService = new InvoiceService(client);
InvoiceListLineItemsOptions invoiceListLineItemsOptions = new InvoiceListLineItemsOptions
{
Limit = 50L
};
if (LastLineID != null)
{
invoiceListLineItemsOptions.StartingAfter = LastLineID;
}
StripeList<InvoiceLineItem> stripeList;
do
{
stripeList = invoiceService.ListLineItems(InvoiceID, invoiceListLineItemsOptions);
foreach (InvoiceLineItem item in stripeList)
{
Lines.Append(item);
}
}
while (stripeList.HasMore);
}
`
After instantiating the class, I try to iterate over the public Getter defined like this
public StripeList<InvoiceLineItem> Lines { get; set; }
Iterate like this, and the code fails on the stripe.Lines reference.
if(stripe != null) foreach(var line in stripe.Lines) { items.Add(line); }
๐
One sec
k!
๐ taking over for my colleague. Let me catch up.
I'm on it
first did you take a look at this https://stripe.com/docs/api/pagination/auto ?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
no. i was looking for auto-pagination, but didn't find it. my loop is working thought, I've stepped through it.
I know that the example is for CustomerList but it applies to all listing
I would strongly recommend not using that
yes
and I would strongly recommend asynchronous pagination
ok, I will recode that. do you think that is why I can't iterate over the list though?
yes I think so
please try this and get back to us if that doesn't work out for you
ok. thx. Leave this thread alive?
yeah it will be waiting for you
maybe I won't though, I have to step away in a bit
a colleague will take over
ok, still an issue over here.
I thought that is was my compiled class that was the issue, but triple checked that and it is not the issue.
Hi there ๐ taking over
Can you summarize the issue you're having now after implementing auto-pagination?
Yes.
I'm pushing the Lines that I get back into a List<InvloiceLineItem>
exactly this:
public StripeList<InvoiceLineItem> Lines { get; set; }
when I iterate over this list I get the following error
figured it out
Ah okay, so you're good to go?