【问题标题】:Where to use add data-secret in Stripe React Elements在 Stripe React Elements 中使用 add data-secret 的位置
【发布时间】:2020-08-17 04:06:57
【问题描述】:

我正在关注这个文档:https://laravel.com/docs/5.8/billing#storing-payment-methods
它告诉我像这样使用数据秘密:

<input id="card-holder-name" type="text">

<!-- Stripe Elements Placeholder -->
<div id="card-element"></div>

<button id="card-button" data-secret="{{ $intent->client_secret }}">
    Update Payment Method
</button>

我在我的项目中使用 React 和 React Stripe Elements

我创建了一个路由:/api/clientsecret 来返回 client_secret。 但我不太确定我将在哪里使用带有 React Stripe Elements 的 client_secret。

【问题讨论】:

    标签: javascript reactjs laravel stripe-payments


    【解决方案1】:

    不推荐使用 React Stripe Elements,您应该改用 React Stripe JS

    Laravel 假设您在这里进行服务器端渲染,而 React 并非如此。当您准备好确认 SetupIntent 时,您应该只使用 fetch 从您创建的路由中获取 client_secret

    【讨论】:

      猜你喜欢
      • 2021-05-14
      • 2018-09-24
      • 2020-02-26
      • 2018-01-16
      • 2021-02-28
      • 2020-02-23
      • 2017-10-13
      • 2020-02-01
      • 2019-12-28
      相关资源
      最近更新 更多