我正在尝试将 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>
您可以通过传递此属性来指定要显示的账单字段: https://stripe.com/docs/js/elements_object/create_ payment_element# payment_element_create-options-fields-billingDetails
您特别查看此字段是为了显示邮政编码:
const paymentElement = elements.create("payment", {
fields: {
billingDetails: {
name: 'auto',
email: 'auto',
address: {
postalCode: 'auto'
}
},
}
});