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

查看:1053
本文介绍了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

< a href =https://github.com/sharafat/sample-code-php =nofollow noreferrer> 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可以拿起而不用担心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.

解决方案

我的解决方案因为这非常简单。如果您不想使用Native功能并且不确定为什么需要它,请不要使用PayPal SDK。 PayPal有一组各种API,您可以在服务器端或客户端使用,而无需触及本机代码。在这里,我给出一个简单的场景,使用ExpressCheckout API并在服务器端处理。

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/integration/direct/make-your-first-call

2。创建付款交易。您需要传递付款详细信息,例如货币和总金额。在此步骤中,您也可以传递'return_url'和cancel_url。请务必将订单ID或订单代码附加到这两个订单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天全站免登陆