#n0rlant1s-avoid-redirect-elements
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Can you edit your message to post the code in the thread here please ? It would help us keep the channel tidy ๐ Thanks
Yes, one sec
super appreciate it 
My code:
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
redirect: "if_required",
return_url: "http://localhost:3000",
},
});
The error I'm receiving is:
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: redirect",
"param": "redirect",
"payment_intent": {
"id": [redacted],
"object": "payment_intent",
"amount": 3000,
"amount_details": {
"tip": {
}
},
"automatic_payment_methods": {
"enabled": true
},
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"client_secret": [REDACTED],
"confirmation_method": "automatic",
"created": 1657724623,
"currency": "usd",
"description": null,
"last_payment_error": null,
"livemode": false,
"next_action": null,
"payment_method": null,
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"status": "requires_payment_method"
},
"type": "invalid_request_error"
}
}
I think you have redirect on the wrong object. It needs to be outside of confirmParams
https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-redirect
Oh, wow can't believe I didn't try that yet. Thank you! I think it worked.
NP! ๐ Happy to help
Another quick one for you -- it seems like avoiding redirection causes some additional issues:
Adding my code and error above -- in my previous case, it redirected without any issues, but now it's erroring out (error is undefined). Should I change the snippet to have ONLY if error: if {error.type == "card_error}....
huh yeah I believe the conditional needs to change
you could add another condition to check if error exists
if (error && error.type === "card_error || ....)
Got it -- just wanted to double check on that -- tysm!!