条纹结帐自动填充或禁用客户名称
Stripe checkout autofill or disable customer name
我正在使用条纹结账。我已经收集了一些用户数据,我不希望客户填写他们的名字两次。如何自动填充或禁用名称字段?
const session = await stripe.checkout.sessions.create({
customer_email: !customerFound ? data.email : undefined,
customer: customerFound ? customer.id : undefined,
customer_update: customerFound
? {
address: 'auto',
name: 'auto',
}
: undefined,
line_items: lineItems,
client_reference_id: data.userId,
payment_method_types: ['card', 'bancontact'],
mode: 'payment',
success_url: `${domain}/betaling-gelukt?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${domain}/betaling-mislukt`,
locale: 'nl',
billing_address_collection: 'auto',
metadata: {
reservation: data.reservatieId,
},
});
请注意,结帐会话的 name
字段不一定是您客户的姓名,而是他们使用的付款方式上的名称。
无法预填此 name
字段,除非 customer
已经附加了可与 setup_future_usage
重复使用的付款方式。
- 对于 bancontact 付款方式,这是不可能的,因为它仅用于一次性付款。
- 对于卡付款方式,可以。这将预先填写 Stripe documentation.
中提到的电子邮件、姓名、银行卡详细信息和账单地址。
一般来说,我建议让 Stripe Checkout 收集所有信息,然后从中更新您的系统,而不是相反。
In payment mode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page.
In subscription mode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
这可能适合也可能不适合您的情况。
或者,您可以完全删除 Stripe Checkout 并在 Stripe 提供的后端 API 旁边使用 Stripe.js。此方法有其 pros/cons:
优点:
- 对元素和元素流的完全控制
- Customise/style 个元素由您自己选择
缺点:
- 您必须创建后端并手动处理
PaymentIntent
和 Subscription
我们遇到了与您类似的问题,虽然从 Stripe Checkout 到 Stripe.js 的最初更改有点学习曲线,但它给了我们更多的控制权,并允许我们进行付款而无需重定向到外部网站。
注意: 我故意省略了代码,因为 Stripe.js 的实现可能会根据您的需要而有所不同,但如果需要,我可以提供一些示例。
我正在使用条纹结账。我已经收集了一些用户数据,我不希望客户填写他们的名字两次。如何自动填充或禁用名称字段?
const session = await stripe.checkout.sessions.create({
customer_email: !customerFound ? data.email : undefined,
customer: customerFound ? customer.id : undefined,
customer_update: customerFound
? {
address: 'auto',
name: 'auto',
}
: undefined,
line_items: lineItems,
client_reference_id: data.userId,
payment_method_types: ['card', 'bancontact'],
mode: 'payment',
success_url: `${domain}/betaling-gelukt?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${domain}/betaling-mislukt`,
locale: 'nl',
billing_address_collection: 'auto',
metadata: {
reservation: data.reservatieId,
},
});
请注意,结帐会话的 name
字段不一定是您客户的姓名,而是他们使用的付款方式上的名称。
无法预填此 name
字段,除非 customer
已经附加了可与 setup_future_usage
重复使用的付款方式。
- 对于 bancontact 付款方式,这是不可能的,因为它仅用于一次性付款。
- 对于卡付款方式,可以。这将预先填写 Stripe documentation. 中提到的电子邮件、姓名、银行卡详细信息和账单地址。
一般来说,我建议让 Stripe Checkout 收集所有信息,然后从中更新您的系统,而不是相反。
In payment mode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page.
In subscription mode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
这可能适合也可能不适合您的情况。
或者,您可以完全删除 Stripe Checkout 并在 Stripe 提供的后端 API 旁边使用 Stripe.js。此方法有其 pros/cons:
优点:
- 对元素和元素流的完全控制
- Customise/style 个元素由您自己选择
缺点:
- 您必须创建后端并手动处理
PaymentIntent
和Subscription
我们遇到了与您类似的问题,虽然从 Stripe Checkout 到 Stripe.js 的最初更改有点学习曲线,但它给了我们更多的控制权,并允许我们进行付款而无需重定向到外部网站。
注意: 我故意省略了代码,因为 Stripe.js 的实现可能会根据您的需要而有所不同,但如果需要,我可以提供一些示例。