如何使用 Stripe (stripe.js) 和 react-native [英] how to use Stripe (stripe.js) and react-native

查看:50
本文介绍了如何使用 Stripe (stripe.js) 和 react-native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种将 Stripe 与 react-native 结合使用的好方法.最好是不涉及将信用卡详细信息发送到我自己的后端或在应用程序中存储我的条带私钥的.欢迎任何想法!谢谢

解决方案

我个人还没有在 React Native 中实现这个.在我正在处理的应用程序中,这将在接下来的几天内移植,但这里是我们在当前应用程序中如何在不依赖第三方库的情况下执行此操作,以及我们将如何在 React Native 中实现.这显然只是一个概念,可以在任何可以进行 HTTP 调用的地方使用.

https://api.stripe.com/v1/tokens 发出 POST 调用带有值为 Bearer {PUBLISHABLE_AUTH_TOKEN} 的授权"标头.在正文 (x-www-form-urlencoded) 中输入:

card[name]={NAME_ON_CARD}&card[number]={CARD_NUMBER}&card[exp_month]={CARD_EXP_MONTH}&card[exp_year]={CARD_EXP_YEAR}&card[cvc]={CARD_CVC}

响应将是一个 JSON 对象,其中包含(除其他外)一个 id 字段.此 id 字段是您在进行交易时将引用的卡,因此需要将此 ID 发送到您的服务器并存储.可以存储此 ID,而无需担心 PCI 合规性.

更多信息:https://stripe.com/docs/api#tokens>

I'm trying to find a good approach to using stripe with react-native. Preferably one that doesn't involve sending credit card details to my own backend or storing my stripe private key in the application. Any ideas welcome! thanks

解决方案

I have not implemented this in React Native personally yet. In the app I am working on this will be ported over in the next few days but here is how we do it in the current app without any dependency on third party libraries and how we will implement in React Native as well. This is obviously just a concept that can be used anywhere you can make a HTTP call.

Make a POST call to https://api.stripe.com/v1/tokens with a 'Authorization' header with the value Bearer {PUBLISHABLE_AUTH_TOKEN}. In the body (x-www-form-urlencoded) put:

card[name]={NAME_ON_CARD}&card[number]={CARD_NUMBER}&card[exp_month]={CARD_EXP_MONTH}&card[exp_year]={CARD_EXP_YEAR}&card[cvc]={CARD_CVC}

The response will be a JSON object that contains (among other things) an id field. This id field is what you will reference the card when making transactions so this ID needs sent to your server and stored. This ID can be stored without worry of PCI compliance.

More Info: https://stripe.com/docs/api#tokens

这篇关于如何使用 Stripe (stripe.js) 和 react-native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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