简体   繁体   English

在单页结账时使用 Stripe Payment 元素改变客户详细信息

[英]Vary Customer Details with Stripe Payment Element on Single Page Checkout

I'm migrating an application from Stripe's 'card' element to the newer 'payment' element.我正在将应用程序从 Stripe 的“card”元素迁移到较新的“payment”元素。

If I understand correctly, the client secret from the PaymentIntent is now required to create and mount the payment element.如果我理解正确,现在需要来自 PaymentIntent 的客户端密钥来创建和安装支付元素。 In order to create the PaymentIntent, we need the customer to have been created and the amount.为了创建 PaymentIntent,我们需要已经创建的客户和金额。

From the docs:从文档:

Previously:之前:

const stripe = Stripe('pk_test_qblFNYngBkEdjEZ16jxxoWSM');
const elements = stripe.elements();

Now:现在:

const stripe = Stripe('pk_test_qblFNYngBkEdjEZ16jxxoWSM');
const options = {
  clientSecret: '{{CLIENT_SECRET}}',
};
const elements = stripe.elements(options);

My question - the application is a single page on which customers enter details, select quantities (tickets) and enter card details.我的问题 - 该应用程序是一个页面,客户可以在该页面上输入详细信息、选择数量(票证)并输入卡详细信息。 I'm assuming that this is not feasible with the new payment element, since the customer would not be able to modify their details or change quantity after the payment element has been created.我假设这对于新的付款元素是不可行的,因为在创建付款元素后,客户将无法修改其详细信息或更改数量。

Am I wrong?我错了吗?

Thank you so much.非常感谢。

Image of existing form for context:用于上下文的现有表单的图像:

用于上下文的现有表单的图像

Correct, in this flow you should collect the card details last once the customer is ready to finalize their payment.正确,在此流程中,您应该在客户准备好完成付款后最后收集卡详细信息。 This would be the recommended approach where you don't let them change the quantity at that point and charge their card as you collect the card details这将是推荐的方法,您不要让他们在那时更改数量并在您收集卡详细信息时从他们的卡中收取费用

Otherwise, the best option is to stay on the Card Element so that you collect their card details upfront and only confirm at the next step once they are ready to finalize.否则,最好的选择是留在卡片元素上,以便您预先收集他们的卡片详细信息,并在他们准备好完成后才在下一步进行确认。

Just wondering if you ever found a solution?只是想知道您是否找到了解决方案? I am in the same boat, and this thread is the only thing I found on google for this scenario.我在同一条船上,这个线程是我在谷歌上找到的唯一关于这个场景的东西。

Is it maybe possible to fake a paymentIntent on page load and then create new one/update with info from the form?是否有可能在页面加载时伪造paymentIntent ,然后使用表单中的信息创建新的/更新?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM