#Blitoka33

1 messages ยท Page 1 of 1 (latest)

worldly lotusBOT
arctic venture
#

Hello ๐Ÿ‘‹
With PaymentElement, you would create a PaymentIntent server-side and send the clientSecret to client-side which then is used to render the element.

Then you'd use PaymentElement to collect the payment method information (your customer would put this information in) and once they're done, you'd confirm the PaymentIntent client-side

We have docs on this flow here
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements

If you have any specific questions around it, I'm happy to help ๐Ÿ™‚

potent wren
#

I got to this point, but for some reason the client just doesnt pass the informations.

#

I can share the code if you need.

arctic venture
#

Sure thing!

potent wren
#
async function handleSubmit(e) {
    e.preventDefault();
    setLoading(true);

    const { error } = await stripe.confirmPayment({
        elements,
        confirmParams: {
            return_url: "http://localhost:3000/checkout.html",
            receipt_email: emailAddress,
        },
    });

    if (error.type === "card_error" || error.type === "validation_error") {
        showMessage(error.message);
    } else {
        showMessage("An unexpected error occurred.");
    }

    setLoading(false);
}
arctic venture
#

Can you move setLoading(true) a little further down? Preferably after confirmPayment(...)

potent wren
#

sure

#

I did it, didn't help.

arctic venture
#

Do you see any error messages in your console?

Instead of

        showMessage(error.message);
    } else {
        showMessage("An unexpected error occurred.");
    }```

Can you just do `showMessage(error)` and see if you find anything?
potent wren
#

Nothing happened.

#

Weird, it seems like the function doesn't get executed.

#

let me check

#

Nope it doesn't run, I need to check my code then

arctic venture
#

๐Ÿ‘

potent wren
#

SetLoading isn't defined

#

I skipped something in the docs

#

wait

#

Now it works, awesome. My code was a bit messed up, but I managed to get it fixed, thanks for the help!

arctic venture
#

NP! ๐Ÿ™‚ Happy to help