#thiefmaster_best-practices

1 messages ยท Page 1 of 1 (latest)

nova cipherBOT
#

๐Ÿ‘‹ 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.

neon fiber
#

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

terse spade
#

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.

neon fiber
#

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)

terse spade
#

(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.

neon fiber
#

what if it should work on a completely clean stripe account that has no PIs, customers, etc. yet?

#

ah too bad :/

terse spade
#

Let me check something hang on

neon fiber
#

i guess i'll just check locally for the key format and show a warning based on that

#

ok, thx!

terse spade
#

Beucase even a brand new account should have at least one created by default

#

and you can check livemode on that

neon fiber
#

thanks, will have a look

terse spade
#

Yea i just created a new account in my dashboard and queried that with the new sandbox SK, it has a PMC with livemode=false

#

so that should work

#

This could potentially change in future, since its not a strict API contract