#djbigpeach

1 messages · Page 1 of 1 (latest)

merry adderBOT
icy geyser
#

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

runic pollen
#

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 a paymentAmount, since a clientSecret comes from a PaymentIntent which also requires a paymentAmount

#

I'm not sure what "payment mode" means

icy geyser
#

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)

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

runic pollen
#

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 Elements provider? the docs say that once you set options, 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.

icy geyser
#

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)

#

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

runic pollen
#

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?

icy geyser
#

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

runic pollen
#

Got it, so my two options are:

  • Initialize Elements using options with amount and currency instead of a clientSecret (i.e. no PaymentIntent). Create the PaymentIntent on my server once the user has confirmed purchase, and use it to facilitate payment completion.

  • Initialize Elements using options with a clientSecret (i.e. creating a PaymentIntent up 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.

icy geyser
#

yup! those would be the options

runic pollen
#

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.

icy geyser
#

I don't have any information about that unfortuantely (but support would be able to connect you to the right folks)

runic pollen
#

ok sounds good. Really appreciate your help, this was super insightful! Take it easy 🙏