#kelly_java-list

1 messages ¡ Page 1 of 1 (latest)

next crownBOT
#

👋 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/1384675510738747513

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

static gazelle
#

Hi

#

what do we need to provide for you to look into this issue

#

do you need any code that we sent to your api from our end?

lament apex
#

What's the exact problem you have? This looks like a call to the List Charges API for a given Customer object cus_123. What exactly isn't working?

static gazelle
#

they made 8 transactinos in total

#

but we are only able to retrieve the most recent one transaction

lament apex
#

Looking at our logs it says we returned 10 objects. Can you share your exact code?

static gazelle
#

ChargeListParams params = ChargeListParams.builder()
.setCustomer(customer.getId())
.build();

    ChargeCollection result = Charge.list(params);

if(result != null) {
return result.getData().stream().filter(item-> item.getStatus().equals("succeeded")).toList();
}

lament apex
#

Okay so why are you doing that complex filter? Can you loop overt the list of results and print each one? I assume your Customer has a lot of failed Charges so you only end up with a successful one since there are only 10 results returned by default

#

kelly_java-list

static gazelle
#

wait do you mean that we need to go through the transaction list one by one and filter out transaction that has succeeded

#

and print that result one by one?

#

could you elaborate what you meant by printing each one?

lament apex
#

Yes and no. You said "you only return one Charge" which you seem to have discussed with colleagues of mine who were worried it was a bug.
Reading your code, I think the bug is in your own code.
Right now you call the List Charges API and didn't realize it only returns up to 10 objects. If your Customer has more than 10 you have to paginate and get the next page and next page, see https://docs.stripe.com/api/pagination

So right now you get the 10 most recent Charges but you wrote code to only look at successful ones in that list, client-side in your own code. So you think "why do I not get all the Charges" because you misunderstood how the API works

At least that's my current understanding. So to prove this, what I am asking is that you explicitly loop over result.getData() and confirm that you do get 10 objects as expected

static gazelle
#

ok thanks the clarification

#

we will reach out if we have any further questions after implementation