#KarlS-retrieving-invoice-line-items

1 messages ยท Page 1 of 1 (latest)

ashen abyss
#

Hi there!

#

Can you share how you are retrieving these line items currently?

#

And then how you are looping

slender delta
#

yes,

#

copy/paste code here?

ashen abyss
#

Yep, put it between three ` to format

#

Like test

slender delta
#

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); }

#

๐Ÿ‘‹

ashen abyss
#

One sec

slender delta
#

k!

jagged hill
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

slender delta
#

thx

#

the issue is, how to iterate over StripeList<InvoiceLineItem>

jagged hill
#

I'm on it

slender delta
#

no. i was looking for auto-pagination, but didn't find it. my loop is working thought, I've stepped through it.

jagged hill
#

I know that the example is for CustomerList but it applies to all listing

jagged hill
slender delta
#

ok, I can revisit that.

#

what, my do while loop?

jagged hill
#

and I would strongly recommend asynchronous pagination

slender delta
#

ok, I will recode that. do you think that is why I can't iterate over the list though?

jagged hill
#

please try this and get back to us if that doesn't work out for you

slender delta
#

ok. thx. Leave this thread alive?

jagged hill
#

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

slender delta
#

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.

feral basalt
#

Hi there ๐Ÿ‘‹ taking over

Can you summarize the issue you're having now after implementing auto-pagination?

slender delta
#

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

feral basalt
#

Ah okay, so you're good to go?