首页 > 解决方案 > EXPO REACT-NATIVE STRIPE PAYMENT 'expo-payments-stripe': How to use a token created?

问题描述

I can generate a token with the createTokenWithCardAsync function, but then I don't know how to use the token to go through with the payment process.

Would anyone know which functions are in the 'expo-payments-stripe'? The actual stripe functions like stripe.customers.create() or stripe.charges.create() do not work. So far I just know of 2 functions compatible with that package, the one I mentioned above and createTokenWithCardFormAsync...

Ultimately I would like to attach the token to a customer so that they don't need to put their card details everytime they want to purchase something.

Also at the moment of token creation I do not charge any money, just want to 'keep' their info just like uber does.

thanks!

标签: react-nativestripe-payments

解决方案


在 Stripe 上创建客户和创建费用是一个仅限密钥的功能,因此无法在您的客户端(您的移动应用程序只能使用您的可发布密钥)上完成。

因此,这里的流程是:

  1. 在您的应用程序上创建一个令牌(如您所愿)

  2. 将令牌发布到您的后端端点

  3. 您的后端端点(用 Token ID 编写的节点stripe-node)调用stripe.customers.create(),将 Token 附加到 Customer

  4. 稍后的费用创建也必须发生在服务器端,而不是客户端。


推荐阅读