【发布时间】:2020-08-26 19:11:08
【问题描述】:
我正在使用https://stripe.com/docs/payments/checkout中所述的条带结帐
在服务器端,我创建了一个新的条带客户(如果还没有的话),并使用该客户 ID 创建一个结帐会话。然后使用 stripe api 重定向到结帐
stripe.redirectToCheckout({
// Make the id field from the Checkout Session creation API response
// available to this file, so you can provide it as parameter here
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
sessionId: '{{CHECKOUT_SESSION_ID}}'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
在结帐页面(由条带托管)中,有一个预先填充但可编辑的电子邮件字段。我让客户更改了该电子邮件地址。有没有办法让我在条带结帐字段中设置电子邮件地址为只读字段?
【问题讨论】:
-
不幸的是,这目前是不可能的。提供客户 ID 允许 Stripe 使客户和 PaymentMethods 尽可能保持最新。这包括允许客户更改他们的电子邮件地址。虽然不完美,但您可以使用 webhook 检测代码中的这些更改,并让用户协调或验证客户对象上应该包含的内容。 stripe.com/docs/api/customers/update#update_customer-email
-
@v3nkman 您知道 Stripe 是否在允许付款之前验证新电子邮件?在将电子邮件传递给 Stripe 结帐表单之前,我经历了自己验证的麻烦,如果 Stripe 允许他们在未经验证的情况下更改电子邮件,这将破坏所有工作。同时,我不想按照 MatiasG 的解决方案传递
customer_email,因为这会产生重复的客户。我正在尝试遵循最佳实践,这几乎就像 Stripe 的 API 不允许我这样做。 -
@cazort 现在可以通过条带解决。请参阅下面的答案
标签: stripe-payments