#yen6305

1 messages · Page 1 of 1 (latest)

tidal heathBOT
silk eagle
#

Doesn't PaymentElement automatically handles the submission of payment data to Stripe? Not sure why I should call elements.submit() before stripe.confirmPayment()

full spire
#

I believe you still have to submit the actual form with the information the customer typed into the form before you attempt to confirm the payment, otherwise the confirmation step will have no payment data to attempt confirmation with.

silk eagle
#

But even in this guide it does nothing with the actual form with the customer information before the stripe.confirmPayment:

  const handleSubmit = async (e) => {
    e.preventDefault();

    if (!stripe || !elements) {
      // Stripe.js hasn't yet loaded.
      // Make sure to disable form submission until Stripe.js has loaded.
      return;
    }

    setIsLoading(true);

    const { error } = await stripe.confirmPayment({
      elements,
      confirmParams: {
        // Make sure to change this to your payment completion page
        return_url: "http://localhost:3000",
      },
    });` 

Is that correct? I am a tad confused

primal cliff
#

elements.submit() is required if you're using the deferred intent flow

#

Based on that error message, it seems like you are

#

The deferred intent flow simply means you initialize elements without a client secret and wait to create the payment intent until after collecting payment details