#harolold
1 messages ยท Page 1 of 1 (latest)
Hello! What happens instead of the redirect?
it reloads the page with a ? at the end of the url
Can you share the code that sets the return_url?
Just under //redirect_url = "/landing"; can you add console.log(redirect_url) and confirm the correct/expected value is logged just prior to calling stripe.confirmSetup?
No, localhost should work. It's more likely because you have redirect : "if_required" set and no redirect is required for the transaction in question. if you remove that does it work as expected?
ok let me try
also I tried with https://www.gooogle.com and it did not redirect
I will try what you said
yeah same issue
What's the error in the console?
Looks like there's an error somewhere, but it's not visible in your screenshot.
Oh, is that all there is? No warnings or errors appear when stripe.confirmSetup is called?
no like I said it works
it updates stripe.com too
I just need it to redirect when it's succesful
Can you share the current version of your code?
Can you add a console.log(error) after you call stripe.confirmSetup and see what's logged?
ok'
it's not triggered
async function handleSubmit(e) {
/e.preventDefault();/
setLoading(true);
// //Send email to next page in queryparameters
// //email is a route
redirect_url = "https://www.google.com";
console.log(redirect_url);
//setTimeout(function () {
// window.location.href = redirect_url;
//}, 1000000);
const { error } = await stripe.confirmSetup({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: redirect_url
}
});
console.log("error=" + error);
//response.then((data) => { console.log("response=" + data) });
// This point will only be reached if there is an immediate error when
// confirming the payment. Otherwise, your customer will be redirected to
// your `return_url`. For some payment methods like iDEAL, your customer will
// be redirected to an intermediate site first to authorize the payment, then
// redirected to the `return_url`.
if (error.type === "card_error" || error.type === "validation_error") {
showMessage(error.message);
} else if (error.type == "") {
//doesn't get triggered
window.location.href = redirect_url;
}
else{
showMessage("An unexpected error occurred.");
}
//setLoading(false);
}
the browser console doesn't even have "error="
It's not triggered? Meaning console.log("error=" + error); never runs?
yeah never
That's very strange. What if you change return_url: redirect_url to return_url: 'https://stripe.com'?
um I can get error to trigger if I submit with bad details
like card number 1111 1111 1111 1111
ok I will try that
That's expected. stripe.confirmSetup should redirect unless an error happens. It seems like it's redirecting, just to the wrong place, which I'm trying to figure out.
same thing with that syntax
I don't understand what could be preventing it from redirecting to the correct place.
Do you have any polyfills or unusual overrides to global objects? Anything like that?