Stripe 收集客户账单地址并动态计算税金

Stripe collect customer billing address and calculate tax dynamically

到目前为止,我设法创建了收集客户信用卡信息的表格,但是,我正在尝试找到如何添加还收集客户地址以进行验证和税收计算的表格,到目前为止我还无法做到如何添加地址和邮政编码,如下图所示:

这种形式是 Stripe 内置的还是地址形式与 Stripe 分开API?

到目前为止,我已经检查了这些链接但没有成功:

  1. https://stripe.com/docs/api/cards/object#card_object-address_line1
  2. https://stripe.com/docs/payments/accept-a-payment#web
  3. https://checkout.stripe.dev/preview
  4. https://stripe.com/docs/payments/checkout/taxes

Stripe 不提供地址或邮政编码字段。相反,您可以在页面上添加正常的 HTML 表单字段,并在您调用 Stripe.js 方法(如 stripe.confirmCardPayment.

时传入值)

例如,您可以像这样传入姓名、电子邮件、国家和邮政编码:

stripe.confirmCardPayment(clientSecret, {
    payment_method: {
        type: 'card',
        card: cardElement,
        billing_details: {
            name: 'Jane Doe',
            email: 'jane@example.com',
            address: {
                country: 'US',
                postal_code: '98765',
            },
        },
    },
});

您可以从页面上的各种 <input> 元素中提取信息,而不是那些硬编码值。

有关您可以在此处定义的所有属性,请参阅 Stripe's documentation for stripe.confirmCardPayment for more details, and Stripe's documentation on Payment Method billing_details