#gab-gab_api
1 messages ยท Page 1 of 1 (latest)
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.
- gabgab_paymentelement-setupfutureusage-paymentmethods, 3 days ago, 29 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1253660655651651605
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
HI
setupFutureUsage is a PaymenIntent property, you should make the update on the PaymentIntent using the backend.
I'm creating the intent after
Ah I see that makes sense.
Then you need to pass off_session if you don't want on_session:
https://docs.stripe.com/js/elements_object/update#elements_update-options-setupFutureUsage
In my case I don't want at all setupFutureUsage in the case of Twint, and I want on_session for credit card for instance
toggling 'on_session'/'off_session' works but not removing setupFutureUsage
Ok, thanks for the explanation! have you had the chance to try elements.update({setupFutureUsage: undefined}) ?
Both nothing working
To unset a parameter you need to pass an empty string to the API
from available types ("on_session" | "off_session" | null | undefined) I cannot.
I anyway tried with an empty string but it doesn't work
What do you mean by 'doesn't work'?
I mean doing elements.update({setupFutureUsage:...}).
Doesnt do any call to https://api.stripe.com/v1/elements/sessions to update the current session.
The payment element is not updated.
For instance, In case the current element is "card", it doesn't remove the text indicating the card will be saved.
Also in my use case, it doesn't allow me to pick Twint because the payment element is still in 'on_session'
Can you share the exact code you're using?
elements.update({ setupFutureUsage: null })
also I try to do this:
elements.update({
setupFutureUsage: null,
paymentMethodTypes: ['twint']
})
Did you try setupFutureUsage: ""? That is how you unset fields in the API โ nullish parameters are removed from the payload. I realise it's untyped, but you can ts-ignore that part and let's just see if it works
yes i tried to ignore the type and to use "". But it won't apply.
with the following code, it will apply the new paymentMethodTypes but 'on_session' will be kept.
elements.update({
setupFutureUsage: ''",
paymentMethodTypes: ['twint']
})
Are there any logs in the console?
In case i do this code:
setupFutureUsage: '',
paymentMethodTypes: ['twint']
})```
I will have an error because twint is not supported with 'on_session'.
In case i just update setupFutureUsage trying to removing it, it won't do anyhting (no element update, no trigger to the stripe api, no error).
```elements.update({
setupFutureUsage: '',
})```
Seems like this isn't supported in the deferred flow then
3 days I try to add Twint without losing the ability to save credits cards..
Ok.. cannot explain where in my code analyse I miss it.
Using the latest stripe api '2024-04-10' is working removing the parameter with null
Hmm, API version shouldn't matter
you right it doesn't change anything switching the api
So, setupFutureUsage: null works all along?
it is working but I cannot understand why.. I didn't do changes before I start the support chat ๐
Great!