#m.x.m_

1 messages · Page 1 of 1 (latest)

unborn fossilBOT
sturdy estuary
#

hi, you would use pagination instead.

plain tangle
#

No because I need to display the current stats off the month

#

So top customers

#

Last 10 paid sessions

sturdy estuary
#

makes sense. Not sure what you mean by "no". Listing all CheckoutSessions, implementing pagination, is how you would build a list of all the CheckoutSessions(and you can add filters like created to limit it to certain time periods (see the parameters on https://stripe.com/docs/api/checkout/sessions/list )).

plain tangle
#

Ah

#

So using .autoPagingEach

#

The request takes a lot of time

sturdy estuary
#

which request? how do you quantify "a lot"?

#

it's also not a request in the critical path(a customer payment journey) and is more for async backend reporting purposes so being a couple of seconds shouldn't be a huge problem.

plain tangle
#
await stripe.checkout.sessions.list({ limit: 10 }).autoPagingEach(session => {
     sessions.push(session)
})
sturdy estuary
plain tangle
#

Ah hahahha

sturdy estuary
#

so it will take a while/involve many pages

plain tangle
#

How can I filter the last month

sturdy estuary
#

hence why you probably want to filter it with created etc as mentioned earlier

plain tangle
sturdy estuary
#

in that object that also contains the limit param

plain tangle
#

I can only pass these params

sturdy estuary
#

there's definitely a created param, not sure why your IDE doesn't show it.

#
await stripe.checkout.sessions.list({
  limit:10,
  created:{
    gt: 1704067200
  }
})
plain tangle
#

Yeah get this

sturdy estuary
#

maybe just @ts-ignore the line

plain tangle
#

Thanks, fixed it using:

await stripe.checkout.sessions.list({
        limit: 10,
        created: { gt: Math.floor(monthTimestamp / 1000) },
        status: "complete"
    } as any).autoPagingEach(async (session: any)
signal obsidian
#

You probably just need to update your stripe dependency to get the latest types

#

created parameter was added fairly recently to that endpoint

unborn fossilBOT