#Fahim

1 messages · Page 1 of 1 (latest)

tough scarabBOT
sullen marsh
#

Hi there!

wide wagon
#

req_DiQaf2dIyeRXTg

sullen marsh
#

You used test card 4000000000009995 (Insufficient funds decline), so what were you expecting?

wide wagon
#

so will it return a 402? shouldn't request be success and return value should say it's Insufficient funds decline?

#

Anyways what I want to do is redirect to a page, if payment fail.

sullen marsh
wide wagon
#

But in local setup it's not redirecting

#

const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: window.location.origin+"/admin/system/stripe/testing/connected-accounts/take-a-payment/return-url",
},
});

if (error.type === "card_error" || error.type === "validation_error") {
  showMessage(error.message);
} else {
  showMessage("An unexpected error occurred.");
}

var paymentIntentid = $("#payment_intent_id").val();
var payment_id = get_payment_id(paymentIntentid);
if(payment_id != '' && payment_id != undefined && payment_id != 0){
redirect_url = "/admin/system/stripe/payment/"+payment_id;
window.location.href = redirect_url;
}

#

this is the code block I'm talking about

sullen marsh
#

Yes that's expected with the Payment Element. By default, when there is an error, the page stays the same so that the user can fix the issue by entering a different card.

#

But you might be able to tweak your code to force a redirection if there is an error.