I am using a Stripe cardElement in a payment page, and I have run into an issue with the call to ".confirmCardPayment". Here is the Javascript code invoking it:
stripe.confirmCardPayment(
"<%=clientSecret %>",
{
receipt_email: "<%=customerEmail%>",
payment_method: {
card: cardElement,
},
billing_details: {
name: "me",
address: {
country: "US",
line1: "123 main street",
line2: null,
city: "pueblo",
state: "co",
postal_code: "81003",
},
},
}
).then(function (result) {
loading(false);
if (result.error) {
showError(result.error.message);
} else {
$("#hdData").val(JSON.stringify(result.paymentIntent));
frmBuy.submit();
}
});
Everything works, except I get an error message back from Stripe saying:
Received unknown element: billing_details
I have looked through all the documentation I can find, and everything says this is the correct way to invoke the call. I want to be sure to include client billing address info so that the PaymentIntent reflects the customer's info in the event of a claim of fraudulent activity. I removed the code that adds in the actual customer info for the sake of testing AND for simplicity with this question.
Can anyone tell me how I'm structuring this call incorrectly? The Stripe docs don't provide any help with this.
It looks like the issue is due to the billing_details
parameter not nested within the payment_method
parameter on your Card Payment confirmation. Instead, your code should look something like this:
stripe.confirmCardPayment(
"<%=clientSecret %>",
{
receipt_email: "<%=customerEmail%>",
payment_method: {
card: cardElement,
billing_details: {
name: "me",
address: {
country: "US",
line1: "123 main street",
line2: null,
city: "pueblo",
state: "co",
postal_code: "81003",
},
},
},
}
)