#djbigpeach
1 messages · Page 1 of 1 (latest)
Yeah so right now to use elements you either need to provide a client secret or a payment amount (if you're in payment mode) - we do have some changes planned to make amount optional, but they're not public yet
If it's a hard requirement for you, then I'd recommend writing in (https://support.stripe.com/contact) to see if you can get added to the beta
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.
you either need to provide a client secret or a payment amount (if you're in payment mode)
Which basically means you need to provide apaymentAmount, since aclientSecretcomes from aPaymentIntentwhich also requires apaymentAmount
I'm not sure what "payment mode" means
Yeah let me back up - the React docs are a bit outdated. Previously, we had a hard requirement of needing a clientSEcret to use payment element, but since then we've launched newer flows that no longer require you to create the payment intent up-front and allow you to pass in a set of options (see https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=payment&client=react#add-and-configure-the-elements-provider-to-your-checkout-page)
Ok, so a couple follow up questions:
- Is the guidance no longer to render the Elements provider at the root of the app, but instead at the root of one's "CheckoutPage"? tbh, I think I would prefer the former, as then the checkout page can immediately load without waiting for the Stripe SDK to load.
- If I don't create a payment intent up-front, when would I add it to the
Elementsprovider? the docs say that once you setoptions, you can not change it's value.
I think my friction is more so around having to provide the paymentAmount up front, be it to the Elements provider or to a PaymentIntent. If that weren't the case, it would be simple for me to create a PaymentIntent when the user first lands on my app, and then update that PaymentIntent as they change their purchase selection.
btw, I really appreciate ya'll being quick to respond.
Generally our guidance is still to render it at the root of the app, but it's up to you (if you're sure you only need it in the one place, then you're welcome to load it at the root of your checkout page)
For your second question I'd recommend reading the rest of the doc I sent over - it goes into detail about how that whole flow works (if you don't create the payment intent up front then you'll pass the client-secret upon confirmation https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=payment&client=react#submit-the-payment)
and yeah, totally understand that the friction is still there even if you have to provide payment amount generally (doesn't matter if it's for an intent or not) - that's why we do have those upcoming changes planned
I see, ok so is paymentAmount still required when passing it in the options prop of the Elements provider? The docs here for it actually doesn't even specify amount as a valid property: https://stripe.com/docs/js/elements_object/create
But perhaps this is just related to the React docs being a bit out of date?
You want to be looking at this one instead: https://stripe.com/docs/js/elements_object/create_without_intent
I don't know why we split it up in our docs like that, but that first one is specifcally meant for the clientSecret flow
Got it, so my two options are:
-
Initialize
Elementsusingoptionswithamountandcurrencyinstead of aclientSecret(i.e. noPaymentIntent). Create thePaymentIntenton my server once the user has confirmed purchase, and use it to facilitate payment completion. -
Initialize
Elementsusingoptionswith aclientSecret(i.e. creating aPaymentIntentup front). Update the payment intent as necessary and use it to facilitate payment completion.
In both cases, for the time being, I effectively need to provide an amount at time of initialization.
yup! those would be the options
ok, and I can reach out to support to see about getting added to the beta version which would allow me to omit amount at the start. Do ya'll have clients that are using this beta version in production? I wouldn't want to pursue that if I can't rely on it being relatively stable.
I don't have any information about that unfortuantely (but support would be able to connect you to the right folks)
ok sounds good. Really appreciate your help, this was super insightful! Take it easy 🙏