#harolold

1 messages ยท Page 1 of 1 (latest)

little hollowBOT
uncut sorrel
#

Hello! What happens instead of the redirect?

distant helm
#

it reloads the page with a ? at the end of the url

uncut sorrel
#

Can you share the code that sets the return_url?

distant helm
#

ok

uncut sorrel
#

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?

distant helm
#

ok

#

yeah confirmed

#

is it because it's localhost?

uncut sorrel
#

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?

distant helm
#

ok let me try

#

I will try what you said

#

yeah same issue

uncut sorrel
#

What's the error in the console?

#

Looks like there's an error somewhere, but it's not visible in your screenshot.

distant helm
#

the css notr found error?

#

no error server side

uncut sorrel
#

Oh, is that all there is? No warnings or errors appear when stripe.confirmSetup is called?

distant helm
#

no like I said it works

#

I just need it to redirect when it's succesful

uncut sorrel
#

Can you share the current version of your code?

distant helm
#

just the code?

uncut sorrel
#

Can you add a console.log(error) after you call stripe.confirmSetup and see what's logged?

distant helm
#

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="

uncut sorrel
#

It's not triggered? Meaning console.log("error=" + error); never runs?

distant helm
#

yeah never

uncut sorrel
#

That's very strange. What if you change return_url: redirect_url to return_url: 'https://stripe.com'?

distant helm
#

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

uncut sorrel
#

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.

distant helm
#

same thing with that syntax

uncut sorrel
#

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?

distant helm
#

I honestly don't know

#

ok I got to log off for the day. I guess I will ask tomorrow

uncut sorrel
#

Okay. A minimal test case we can view online would be helpful.

#

If you could host something somewhere and share the URL with us tomorrow that would be ideal.