#thiefmaster_best-practices
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/1371837830690771126
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I guess I can just call stripe.Account.retrieve(api_key=...) and see if it succeeds, but i wonder if there's a better API endpoint for this since i don't really care about the data it returns
There's no API specifically for this, but you can achieve the goal by calling any no-op endpoint. Without an object ID, the simplest way to do this is any List endpoint. eg, call List Customers with limit=1.
thanks. another question, is there an endpoint that includes information whether the key belongs to a sandbox or production environment? that would actually be useful to show to my users ๐
(i know i can just use string operations to see if it starts with sk_test_..., but getting it from an API feels cleaner)
Yep, in that same List request you can peek at the 1 customer returned (assuming they have customers) and inspect whether livemode is true or false.
https://docs.stripe.com/api/customers/object#customer_object-livemode
(you could also list payment intents similarly to check)
If the account has no customer or payments, you'd only be able to tel with a write operation like creating a customer to check livemode in the result.
what if it should work on a completely clean stripe account that has no PIs, customers, etc. yet?
ah too bad :/
Let me check something hang on
i guess i'll just check locally for the key format and show a warning based on that
ok, thx!
I think you can probably do this my listing payment method configurations: https://docs.stripe.com/api/payment_method_configurations/list
Beucase even a brand new account should have at least one created by default
and you can check livemode on that
thanks, will have a look