#akos_error
1 messages ยท Page 1 of 1 (latest)
๐ 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/1478010388003164282
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
import stripe
from asyncio import run
client = stripe.StripeClient(os.getenv("STRIPE"))
async def main():
session = await client.v1.checkout.sessions.retrieve_async("cs_live_b12KiG98jLY02eGdokZpW9y4yWCA79iC8VY4ib2nmjEPhoNZFOYxdML9yi")
run(main())
stripe._error.InvalidRequestError: Request req_I1MJB6cfywN6zu: No such checkout.session: cs_live_b12KiG98jLY02eGdokZpW9y4yWCA79iC8VY4ib2nmjEPhoNZFOYxdML9yi
๐ Hi there! Let me take a look
It looks like the Checkout Session belongs to the account acct_1PgCVlEWE0J4C6cm, but you made this request using a key that belongs to the account acct_1RqEsXI9q63ANwis
Uhh, yeah that might be it. Thanks!
Quick question regarding sessions
Whats the best way to find an expired checkout session based on its client_reference_id?
There isn't an API search method for Checkout Sessions, so you would need to list them with status: expired and check the client_reference_id field: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-status
Thats my current implementation, however the python SDK limits the returned results to 100. I've had an issue with prod where it failed to find a checkout session due to this.
Is this an SDK limitation or an API one?
The limit is 100 results at a time, but you can iterate through all results
The simplest way to do this is auto-pagination: https://docs.stripe.com/pagination?lang=python#auto-pagination
If you know the date range, you can also limit further by creation time when listing Checkout Sessions: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-created
This is what I was looking for, thanks!