#hexiaolong
1 messages ยท Page 1 of 1 (latest)
Sure, could you elaborate?
thanks, The current problem with our business is that Elements are reloaded every time we make a payment, because clientSecret changes every time, which results in a long loading time and poor experience. Today, when I tried to change clientSecret without recreating Elements, I found that the first clientSecret was still used in the real payment reply when clientSecret was changed. How to deal with the change? I did see the instructions that clientSecret cannot be changed in the documentation,https://stripe.com/docs/stripe-js/react#elements-provider
It takes more than 1s for Elements to be loaded for the first time, and about 800ms for elements to be loaded again. How can I solve the problem of slow loading
It takes more than 1s for Elements to be loaded for the first time, and about 800ms for elements to be loaded again. How can I solve the problem of slow loading
The best approach would be trying to not recreating client Secret that many time. Isn't it creating a lot of unconfirmed PaymentIntent?
Alternatively you can consider displaying PaymentElement without creating PaymentIntent like this flow: https://stripe.com/docs/payments/accept-a-payment-deferred
Do you mean that you don't pass in the clientSecret when you create the Elements, so you only need to create the Elements once, and pass in the clientSecret when you actually make a payment, removing the elements in Figure 1 and adding them in Figure 2?
No, not exactly. Please take a look at the Doc link provided, choose React on all frontend code and you will see
It completely doesn't take client_secret at all.
i see this in the Doc link
Ah yes, sorry! Yes it is talking both elements and client secret
okay, i will try ,thanks
Hi! I'm taking over from my colleague. Please, let me know if you have any other questions.
ok, i see the Doc link,the method provided by your colleague needs to pass in mode, currency and amount, but these three values are different for different goods. How to ensure that they can be updated when switching? thanks
Are you creating a new PI on every change?
The way I'm using it so far is clientSecret changes, recreating Elements
My question was whether you create a new PaymentIntent or update an existing one
You mean clientSecret returned by the back end ? create a new !
Try updating it instead with: https://stripe.com/docs/api/payment_intents/update
By updating PaymentIntent on the BE, the clientSecret required by the FE remains unchanged, or is it the same? So no need to reload the payment component? Is that right? I'm a front-end engineer. I may not know some apis very well. Sorry
I believe it should update automatically, but it't best to check.
sorry,I don't see what you mean. I don't think my problem has been solved
So, if you change the selected items, you can send a request to your backend to update a PaymentIntent with the new total amount.
Then, your Payment Element will update automatically, you don't need to change the client secret.
You don't need to create a new PI when you change your shopping cart.
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
Can you help me with some solutions to shave my teeth through the above chat, thank you
have you had a look at this https://stripe.com/docs/payments/accept-a-payment-deferred
ok, i see the Doc link,the method provided by your colleague needs to pass in mode, currency and amount, but these three values are different for different goods. How to ensure that they can be updated when switching? What's the use of passing mode,amount, and currency into Elements? I assume the clientSecret returned by the back end already contains this information
this method suits your use-case better, please consider playing around a bit with the guide, build a small integration and see how it works
How long is clientSecret valid
there's no expiry for a valid PaymentIntent
okay, thank u ,i will try it
let me know if you need any more help
One more question, however, is how does the load time when Elements is first created decrease, observed to be about 1.5s
I'm not sure I follow the question
can you speak Chinese?
no sorry, if you prefer to communicate in Chinese you can reach out to https://support.stripe.com/?contact=true they will be more than happy to assist you in Chinese
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
okay,one more question, however, is how does the load time when Elements is first created decrease, observed to be about 1.5s . Chinese does not support online chat,We're going to have to ask you more
I'm not sure I fully understand, please leverage https://support.stripe.com/contact/email to send your question in your native tongue, and someone from our team will respond to you
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.