#pbj
1 messages ยท Page 1 of 1 (latest)
Hello ๐
- Know when it's been successful vs not
You can retrieve the SetupIntent using the API in order to check its status manually
https://stripe.com/docs/api/setup_intents/retrieve
Is succeeded the only state that lets me know its been used?
This status shows that the setup wassuccessful. It may have other statuses such as the ones mentioned here which might show that usage of this SetupIntent has been attempted previously
https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status
- Generate a new one if necessary?
Catching up on your previous thread for more context.. hold on..
Ah okay you're simply just using the API, so yeah you can look at the status and decide if you want to create a new SetupIntent by calling the Create API
https://stripe.com/docs/api/setup_intents/create
Oh easy!
@willow socket to clarify:
- I can retrieve an existing Setup Intent
- Check if its been used already.
- If it has been used, create a new one.
- If it hasn't been used, good to go.
Separately, will users ever have more than one unused setup intents?
- I can retrieve an existing Setup Intent
- Check if its been used already.
- If it has been used, create a new one.
- If it hasn't been used, good to go.
Yup!
Separately, will users ever have more than one unused setup intents?
They could if they leave the flow in the middle, but it really depends on your integration.
Ah okay. So for us that could be the case. Basically we create the customer and as soon as we have relevant info we create a setup intent.
Is there any risk to having multiple?
No risks ๐
You can also just have a script that runs and fetches old SetupIntents & then use the API to cancel them if they're past certain time (i.e. 48 hours or so)
https://stripe.com/docs/api/setup_intents/cancel
oh you can cancel them!!! amainzg
Last question (hopefully)
@willow socket is it preferred to use the list or retrieval API for setup intents? Mostly asking as the list API doesn't require a publishable key
is it preferred to use the list or retrieval API for setup intents? Mostly asking as the list API doesn't require a publishable key
It depends on where (client-side or server-side) you need access to this information really. Additionally, Retrieve API will only return one object as a result vs List API is equipped to return multiple objects
ahh okay. Does the Retrieve API make any "smart" decision on which Intent to return if there are many? Sorry for all the extra questions!
Retrieve API requires you to pass in a SetupIntent ID
https://stripe.com/docs/api/setup_intents/retrieve
It retrieves the object based on the ID that you pass in
Versus List API where you can search for SetupIntents with more parameters such as a customer ID or by a Payment Method etc
https://stripe.com/docs/api/setup_intents/list
you're the thank you!