#kenneth-paymentelement-redirect
1 messages · Page 1 of 1 (latest)
@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
im using card its required?
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
Now with that in mind we do have an option you can use to only redirect when required, see https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-redirect
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);
}
yes that should work
Okay Thanks