#gruneth_invoice-lists

1 messages ¡ Page 1 of 1 (latest)

dense terraceBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288203757154340976

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

bleak minnow
#

Hello,

my current Code:

func (paymentHandler *PaymentHandler) CountTotalInvoices(subscriptionID string) (int64, error) {
stripe.Key = paymentHandler.StripeConnection.Key

params := &stripe.InvoiceListParams{
    Subscription: stripe.String(subscriptionID),
}
var totalResults int64
var iter *invoice.Iter
for {
    iter = invoice.List(params)
    if !iter.Next() {
        break
    }
    totalResults++
    params.StartingAfter = stripe.String(iter.Invoice().ID)
}
if err := iter.Err(); err != nil {
    return 0, err
}

return totalResults, nil

}

paper fractal
#

gruneth_invoice-lists

bleak minnow
#

Well I found there was a possiblility with expand and total_count but seems deprecated.

paper fractal
#

yeah total_count is deprecated on the List APIs and not something you should use. It exists but is broken in some cases and unreliable so don't use that. Been undocumented for like 8+ years

bleak minnow
#

What do you mean with not real time with the Search API?

paper fractal
bleak minnow
#

Trying currently to see how much faster this would be. Thank you very much for your awesome support.

#

You can close this. You made me happy.