#cole-redfearn

1 messages · Page 1 of 1 (latest)

fathom badgerBOT
late raptor
#

Hey there

#

Really up to you, but I'd recommend using Payment Element so that you can easily add other payment method types later if you so desire

lusty tartan
#

Thanks! With regard to creating the Payment Intent, should it be created right when the page renders, possibly in a useEffect hook, or would it be better to create it when the form that holds the Payment Element is submitted?

late raptor
#

Payment Element requires a client secret to render, so you need to create the PaymentIntent when you are ready to render the Element. Many people do this on page load, but you could also do it on a button click for something like "add payment method".

lusty tartan
#

Ok makes sense. I'm thinking we'll do it on page load, but the payment amount may change between when page loads and when user submits payment (this is for restaurant ordering so user has to select tip amount). Would you recommend creating the payment intent on page load and then updating payment intent with the correct payment amount when user submits the form for the payment element?

late raptor
#

And yeah, you can call that on submission or when the amount updates. Mostly up to you as well on that front

lusty tartan
#

Awesome, thanks for the help!