REACT NATIVE 的 PayPal 支付集成与最新的 lib android + ios [英] PayPal payment integration for REACT NATIVE with latest lib android + ios

查看:18
本文介绍了REACT NATIVE 的 PayPal 支付集成与最新的 lib android + ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何机构都可以使用最新的 react-native PayPal 库提供刷卡解决方案吗?

Can any body provide a swipe solution with latest react-native PayPal library ?

我花了一个星期但没有得到合适的解决方案.

I have spent a week but not getting a proper solution.

网上有很多旧的不完整的解决方案,但没有一个合适的和适合新开发者的完整解决方案.

There are many old and incomplete solution on net but not a proper and complete solution for new developers.

资源:

https://www.npmjs.com/package/react-native-paypal

https://github.com/MattFoley/react-native-paypal

https://github.com/sharafat/sample-code-php

推荐答案

不幸的是,据我所知,没有一个由社区维护的最新存储库.这就是您的选择有限的原因.

Unfortunately, there isn't a single repo that is up to date and maintains by the community as far as I know. That's why your options are limited.

利用 PayPal API

PayPal 为不同的用例提供了各种 API,您可以选择这些 API,而无需担心 SDK 本身.它们为您提供了许多这些功能,当然它可能不像 SDK 本身那样流畅,但它可以很好地解决您的问题.

PayPal has various APIs for different use cases that you can pick up without worrying about the SDK itself. They give you lots of those functionalities, sure it might not be smooth as the SDK itself, but it can solve your problem, nicely.

如果您同时针对移动设备和网络进行开发,则可以将您的 API 用于两者.因为它们不依赖于特定的平台.

In case you are developing for both mobile and the web, you can use your APIs for both of them. Becuase they do not depend on the specific platform.

解决方案

我对此的解决方案非常简单.如果您不想弄乱本机功能并且不确定为什么需要它,请不要使用 PayPal SDK.PayPal 有一组不同的 API,您可以在服务器端或 客户端 上使用而无需接触本机代码.这里我给你一个简单的场景,使用 ExpressCheckout APIs 并在服务器端处理.

My solution for this is pretty straightforward. Do not use the PayPal SDK if you don't want to mess with Native functionality and not exactly sure why you need it. PayPal has a various set of APIs that you can use on your server side or client side without touching the native code. Here I give you a simple scenario that using ExpressCheckout APIs and handle on the server side.

对于以下所有步骤,您可以使用 PHP、Node 或任何其他服务器端语言.我只简单的告诉你步骤,剩下的就靠你了!

For all below steps, you can use PHP, Node or any other server-side languages. I only briefly tell you the steps and the rest are on you!

1.为您的交易创建访问令牌.点击以下链接了解详情.

1. Create an access token for your transaction. Follow below link for details.

https://developer.paypal.com/docs/整合/直接/拨打您的第一个电话

2.创建付款交易.您需要传递您的付款详细信息,例如货币和总金额.在这一步中,您也可以传递您的 'return_url' 和 cancel_url.请务必将您的订单 ID 或订单代码附加到它们两者上,以便您可以在其中任何一个触发时跟踪订单并相应地更改您的订单状态.

2. Create a payment transaction. You need to pass your payment details such as currency and total amount. In this step, you can pass your 'return_url' and cancel_url too. Make sure to attach your order id or order code to both of them, so you can track the orders when either of them triggered and change your order status accordingly.

https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/advanced-payments-api/create-express-checkout-payments/

3.将支付 URL 发送到 React Native 并通过 WebView 加载.这一步可以使用 React Native 中的 WebView 组件,加载里面的 PayPal URL.稍后检查付款是否完成,您可以使用限制功能或使用其他替代方案,例如 WebSocket.这里的目标是知道交易是完成还是取消.

3. Send the payment URL to React Native and load it by WebView. In this Step, you can use the WebView component in React Native and load the PayPal URL inside. Later for checking whether the payment is done, you can either use a throttling function or use other alternatives such as WebSocket. The goal here is to know whether the transaction is done or canceled.

付款完成后.摆脱 WebView 并将用户重定向到感谢页面以及完成用户付款后您需要做的任何其他事情.

When the payment is done. get rid of the WebView and redirect the user to thank you page and any other things you need to do after the user payment is done.

可能有更优雅的方法来做到这一点,但我相信对于简单的场景(甚至更多!)这已经足够了.

There might be more elegant ways to do this, but I believe for simple scenarios (or even more!) this is sufficient.

这篇关于REACT NATIVE 的 PayPal 支付集成与最新的 lib android + ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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