You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stripe confirmCardPayment调用报错:Received unknown element: billing_details

问题解决:Stripe confirmCardPayment 中 billing_details 位置错误

你遇到的错误是因为**billing_details 被放在了顶层参数中,而它应该嵌套在 payment_method 对象内部**。Stripe的confirmCardPayment方法要求账单信息属于支付方式的附属数据,而非独立的顶层配置项。

修正后的代码

stripe.confirmCardPayment(
    "<%=clientSecret %>",
    {
        receipt_email: "<%=customerEmail%>",
        payment_method: {
            card: cardElement,
            // 将 billing_details 移到 payment_method 内部
            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();
    }
});

说明

把billing_details放入payment_method对象后,Stripe就能正确识别并记录账单信息,既解决了当前的错误,也能在欺诈索赔时正确关联客户的账单地址数据。

内容的提问来源于stack exchange,提问作者TC_Guy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 00:05:21