#ya-yang_api
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/1313224711194284114
đ 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.
- ya-yang_api, 5 days ago, 7 messages
- ya-yang_api, 5 days ago, 37 messages
- ya-yang_api, 5 days ago, 3 messages
Hello, what line of Stripe code is throwing this error?
And what language is this v8.11.0 library?
in python
when doing this import from stripe.error import InvalidRequestError
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Gotcha, looking in to this and will get back to you
Thanks! The documentation is showing that stripe.error.* is available
Hmm that same import is working for me albeit on a 10.X version. What version did you upgrade from? And are you having any issues importing anything else from Stripe?
I upgraded from v5
Seeing the error when running this command pipenv run mypy hyke
Saw this changelog so wondering if we should only import from stripe
i'm also getting these two errors with the checkout.Session object...error: Item "None" of "Union[Price, None, Any]" has no attribute "id" error: Item "None" of "Optional[ListObject[LineItem]]" has no attribute "data"
and this is the code ``` session: stripe.checkout.Session = stripe.checkout.Session.retrieve(
session_id, expand=["line_items", "subscription"]
)
charged_price_ids = [line.price.id for line in session.line_items.data]```
I tested it in a shell, and it's working...
Interesting, so it is working in your shell but not your IDE basically?
yeah works in the shell, but fails when checking types
Apologies still having trouble finding what this may be
What is your IDE? Or the specific thing that is checking types here?
Hi, stepping in and catching up.
thanks
When you saw that error, did you get a request id? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
You're saying that when you run this code using PHP, it throws the above errors?
session: stripe.checkout.Session = stripe.checkout.Session.retrieve(
session_id, expand=["line_items", "subscription"]
)charged_price_ids = [line.price.id for line in session.line_items.data]
What does I don't have a request id but the request still works mean?
I didn't have errors with making the request. The error shows up when checking types using mypy package.
Ah, I'm on the same page now. Further looking here.
HI taking over here
I think this is an issue with your environment/type checker
Not an issue with the sdk
The code should still work
I'm not familiar with mypy, so don't have specific advice on how to resolve
But this isn't an issue with the sdk
Oh I wonder if this is due to the change in 7.8.0
Try from stripe import InvalidRequestError instead
Maybe the type checker is enforcing this deprecation
Yeah i think it's enforcing the deprecation. But is Stripe still supporting those modules even though the changelog said they are deprecated? stripe.error, stripe.stripe_object, stripe.api_requestor, stripe.stripe_response, stripe.request_options, stripe.api_resources., stripe.api_resources.abstract.
For now
They're deprecated those references still work for now
Not sure in what version they'll be strictly removed in
Got it. Most of them are straight forward to fix. I just have a question about the checkout.Session object
session_id, expand=["line_items", "subscription"]
)
charged_price_ids = [line.price.id for line in session.line_items.data]```
Im getting these two errors, but i do see the data and id properties in the Session payload.
error: Item "None" of "Union[Price, None, Any]" has no attribute "id"
error: Item "None" of "Optional[ListObject[LineItem]]" has no attribute "data"
Is there a problem with how they are accessed?
That code looks fine
Does it work?
I'm not sure what your type checker is complaining about
I think maybe it's because your code isn't handling the case that line_items could be of length 0 and that a line item might not have a price id
(but depending on what you do in your code it may not matter that you're not handling those cases)
Just the type checker catching potential issues