我已经在 React Native 项目中安装了包 React-Native-Payments,并且我从该响应中获得了 token ,使用该 token 我想使用 Stripe 进行付款,有可用的 API 吗?使用带 Stripe 的苹果支付 token 。
基本上我们必须检查从Apple Pay获得的 token ,然后才能传入剥离支付API方法,API端有什么可用的吗?
最佳答案
react-native- payment 库有一个 Stripe 特定的插件,您可以使用:
如文档所述,此插件将允许您接收 Stripe 收费代币,作为 PaymentResponse 的一部分。 .
获得 Stripe token 后,您需要将其发送到您的服务器,您可以将其保存给 Stripe 客户以用于收费。如果您从库取回的 token 具有 tok_
前缀,则意味着它是旧 token ,因此您可能希望将其转换为较新的 PaymentMethods API。为此,您需要创建一个新的 PaymentMethod 并传入 card: { token: "tok_xyz"}
。从那里,您可以将新创建的 PaymentMethod(将具有 pm_
前缀)保存到 Stripe 客户:
- 创建 Stripe 客户:https://stripe.com/docs/api/customers/create
- 保存付款方式:https://stripe.com/docs/api/payment_methods/attach
然后,您可以使用 Customer/PaymentMethod 组合来使用 Stripe 的所有 API 来处理付款。
关于react-native - 使用 React Native 使用 Apple Pay token 进行 Stripe 支付,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63035815/