如何在Stripe元素中显示邮政编码字段

问题描述 投票:0回答:1

我正在尝试将 Stripe 付款集成到我的项目中,但 Stripe 的付款元素似乎不显示邮政编码字段。有没有办法显示该字段?

这是我的代码

<script src="https://js.stripe.com/v3/"></script>

<script>
const stripe = Stripe('PUBLIC_KEY');

const elements = stripe.elements({
                     clientSecret: clientSecret,
                     theme: 'stripe',
                 });

const element = elements.create("payment");

element.mount('#card-stripe');
</script>
stripe-payments postal-code stripes
1个回答
0
投票

您可以通过传递此属性来指定要显示的账单字段: https://stripe.com/docs/js/elements_object/create_ payment_element# payment_element_create-options-fields-billingDetails

您特别查看此字段是为了显示邮政编码:

https://stripe.com/docs/js/elements_object/create_ payment_element# payment_element_create-options-fields-billingDetails-address-postalCode

const paymentElement = elements.create("payment", {
        fields: {
            billingDetails: {
                name: 'auto',
                email: 'auto',
                address: {
                    postalCode: 'auto'
                }
            },
        }
    });
© www.soinside.com 2019 - 2024. All rights reserved.