#kenneth-paymentelement-redirect

1 messages · Page 1 of 1 (latest)

rotund harborBOT
cold grove
#

@forest surge the majority of payment methods require a redirect. For example Klarna or Afterpay want a redirect to their service where you pay as a customer, so by default a redirect will always handled and is quite important to grasp since it will be required for lots of payment methods

forest surge
#

im using card its required?

cold grove
#

kenneth-paymentelement-redirect

#

Not for cards, but if you don't handle the redirect, you'll hit real issues later for non card payments so it's best to handle the redirect upfront

forest surge
#

is this code valid? try {
const { error, paymentIntent } = await stripe.confirmPayment({
elements,
confirmParams: {
return_url: "https://google.com",
},
redirect: "if_required",
});

    if (error) {
      console.error(error);
      // handleError();
    } else if (paymentIntent && paymentIntent.status === "succeeded") {
      console.log("Payment succeeded");
      // handleSuccess();
    } else {
      console.log("Payment failed");
      // handleOther();
    }
  } catch (error) {
    console.error(error);
  }
cold grove
#

yes that should work

forest surge
#

Okay Thanks