从Paypal支付成功后,返回Ionic应用程序 [英] Go back to Ionic application after payment success from Paypal

查看:88
本文介绍了从Paypal支付成功后,返回Ionic应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Ionic应用程序。我有一些要订购的物品。付款使用Paypal完成。我使用window.open(url)调用了一个web url,它将我重定向到Paypal。

I have created an Ionic app. I have some items to order. Payment is done using Paypal. I have called a web url using window.open(url) which is redirecting me to the Paypal.

我能够成功付款,但任何人都可以请让我知道如何在成功付款后回到我的离子应用程序。

I'm able to do the payment successfully, but Can anyone please let me know how I can come back to my ionic app after successful payment.

注意:我没有使用Paypal插件,因为它不是为Windows开发

Note: I have not used Paypal plugin as it is not developed for windows

推荐答案

在付款完成后加载页面时,使用InAppBrowser的loadsart事件来捕获网址。然后,您可以根据需要根据这些网址及其参数处理您的任务。例如,当您拥有付款成功网址后,您可以在关闭打开的浏览器后导航回您的应用。此外,您可以使用这种方式将付款成功或失败时的数据传回您的应用程序。希望这对你有所帮助。

Use loadsart event of the InAppBrowser to catch the urls when load pages after payment was done. Then you can process your tasks according to those urls and their parameters as you prefer. As an example, when you have the payment successful url you can navigate back to your app after closing the open browser. Also you can have the data passing back when the payment is success or fail, into your application using this way. Hope this will help to you.

addEventListener('loadstart',function(event){var currentUrl = event.url / *做其余的事情根据您申请中的网址* /});

我只需在下面添加一个伪代码。

I just add a pseudo-code below.

browserRef.addEventListener('loadstart', function(event) {

  var param = getParameters(event.url); //Read the parameters from the url


  if (isCorrectParameters(param)) { //Check parameters agaist the payment gateway response url
    browserRef.close(); // colse the browser

    //Handle the success and failed scenarios
    if(success){
      $state.go('test');
    }else{
      // handle fail scenario
    }
  }
});

这篇关于从Paypal支付成功后,返回Ionic应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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