#m.x.m_
1 messages · Page 1 of 1 (latest)
No because I need to display the current stats off the month
So top customers
Last 10 paid sessions
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 )).
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.
await stripe.checkout.sessions.list({ limit: 10 }).autoPagingEach(session => {
sessions.push(session)
})
that request lists literally every CheckoutSession on your account ever
Ah hahahha
so it will take a while/involve many pages
How can I filter the last month
hence why you probably want to filter it with created etc as mentioned earlier
Thanks, but where do I need to add the param?
await stripe.checkout.sessions.list({
limit: 10,
}).
in that object that also contains the limit param
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
}
})
maybe just @ts-ignore the line
https://github.com/stripe/stripe-node/blob/master/types/Checkout/SessionsResource.d.ts#L2227-L2268 we have the definitions in the types here. Maybe you're using something else.
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)
You probably just need to update your stripe dependency to get the latest types
created parameter was added fairly recently to that endpoint