Reputation: 1606
I am using Stripe to take payments, but on occasion the following error is logged:
Secure customer authentication failed. You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method.
The following JS is used to process, which works 90% of the time. I can't see why on occasion the PaymentIntent would be missing the payment method.
var card = elements.create('card', {
hidePostalCode: false
});
card.mount('#card-element');
card.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});
var cardButton = document.getElementById("checkout_complete");
cardButton.addEventListener('click', function(event) {
event.preventDefault();
var card_name = document.getElementById('card_name').value;
stripe.createPaymentMethod("card", card, {
billing_details: {
name: card_name
}
}).then(function(result) {
if (result.error) {
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "payment-method-id");
input.setAttribute("value", result.paymentMethod.id);
document.getElementById("checkout_payment_form").appendChild(input);
document.getElementById("checkout_payment_form").submit();
}
});
});
Can anyone point me in the right direction?
Upvotes: 1
Views: 2548
Reputation: 623
The main error here is “Secure customer authentication failed.”. For some of the card payments, issuer banks require Strong Customer Authentication (SCA), like 3DSecure. If you follow the recommended Stripe integration, card authentication will be handled for you.
However, I see that you are confirming the payment on the backend, in which case you will have to handle SCA yourself. Here’s a guide you can follow to manually trigger card authentication.
If this is not what is happening, please share more detail about the exact request that leads to this error.
Upvotes: 0