Closed rafaelcapucho closed 2 months ago
@rafaelcapucho none of the option you're using are correct which is why it's failing. What you need is this:
checkout_session = client.checkout.sessions.retrieve(
'cs_test_123',
params={
'expand': ['line_items'],
},
)
Thank you so much for the reply @remi-stripe,
Changing your snippet to retireve_async
works, I'm closing the Issue
async def f3():
print(
await client.checkout.sessions.retrieve_async(
cs_id,
params={
'expand': ['line_items'],
},
)
)
loop = asyncio.new_event_loop()
loop.run_until_complete(f3())
Describe the bug
Requesting list-items isn't working when using async requests
To Reproduce
retrieve_async(id)
but it isn't supporting theexpand
option.http_client = stripe.AIOHTTPClient()
client = stripe.StripeClient("rk_test_51ItkJ1F0XZ..redacted", http_client=http_client)
cs_id = "cs_test_a1Ew12lsEH1c..redacted"
async def function_working(): return await client.checkout.sessions.retrieve_async(cs_id)
async def function_not_working():
None of the following works
loop = asyncio.new_event_loop() loop.run_until_complete(function_working())
loop = asyncio.new_event_loop() loop.run_until_complete(function_not_working())
Traceback (most recent call last): File "", line 1, in
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "", line 2, in f2
File "/usr/local/lib/python3.12/site-packages/stripe/checkout/_session_service.py", line 2378, in retrieve_async
await self._request_async(
File "/usr/local/lib/python3.12/site-packages/stripe/_stripe_service.py", line 52, in _request_async
return await self._requestor.request_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_api_requestor.py", line 217, in request_async
rbody, rcode, rheaders = await requestor.request_raw_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_api_requestor.py", line 683, in request_raw_async
) = await self._get_http_client().request_with_retries_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 434, in request_with_retries_async
return await self._request_with_retries_internal_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 549, in _request_with_retries_internal_as ync
raise connection_error
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 514, in _request_with_retries_internal_as ync
response = await self.request_async(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 1443, in request_async
) = await self.request_stream_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 1474, in request_stream_async
self._handle_request_error(e)
File "/usr/local/lib/python3.12/site-packages/stripe/_http_client.py", line 1458, in _handle_request_error
raise APIConnectionError(msg, should_retry=should_retry)
stripe._error.APIConnectionError: Unexpected error communicating with Stripe. If this problem persists,
let us know at support@stripe.com.
(Network error: A RuntimeError was raised)