无法创建条带令牌 [英] Unable to create stripe token

查看:77
本文介绍了无法创建条带令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建卡片的令牌,但我不知道该怎么做.假设我的状态中有这样的数据

I am trying to create token of Card but I don't know how to do it. let say I have Data like this in my state

this.state = {
paymentInfo : {
cardNumber : '4242424242424242',
expiry_month : 12,
expiry_year : 22,
cardCvc : 123
} 
}

createToken = () => {
  const {stripe} = this.props;
  const element = stripe.elements();

//From here I don't know how to use data in my State to generate a token 
}

您的帮助将不胜感激.

推荐答案

推荐的方法是不要在 React 状态中维护信用卡信息.如果您以这种方式处理信用卡信息,您的业务就会面临复杂的监管要求 [1].避免这种情况是使用 Stripe,特别是 Stripe Elements [2] 的主要好处之一.

The recommended approach is to not maintain credit card information in your React state. If you handle credit card information in this way, it opens up your business to complex regulatory requirements [1]. Avoiding this is one of the main benefits of using Stripe, and specifically, Stripe Elements [2].

对于 React,此处的以下文档将指导您完成使用我们最新的 API 接受付款的过程:

For React, the following docs here will guide you through the process of accepting a payment using our latest APIs:

https://stripe.com/docs/payments/accept-a-payment#web

上述指南中的每个客户端代码示例都有一个React"选项卡,您可以根据需要切换到该选项卡.

Each client-side code example in the above guide has a "React" tab that you can switch over to if necessary.

我还建议您观看 Stripe 的开发人员办公时间视频以开始使用 React:

I would also recommend watching Stripe's Developer Office Hours video for getting started with React:

如果您绝对必须以这种方式处理信用卡信息,那么当然,Stripe 可以适应这种情况.方法是将信用卡信息安全地发送到您的服务器,并在此处使用以下 API 标记详细信息:

If you absolutely must handle credit card information in this way, then of course, Stripe can accommodate that. The approach would be to securely send the credit card information to your server, and tokenize the details using the following API here:

https://stripe.com/docs/api/payment_methods/create

请注意,PaymentMethods API 是 Stripe 用于标记卡详细信息的新 API(取代了 Tokens API).

Note that the PaymentMethods API is Stripe's new API for tokenizing card details (replacing the Tokens API).

[1] https://stripe.com/en-dk/guides/pci 合规性[2] https://stripe.com/docs/stripe-js

这篇关于无法创建条带令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆