简体   繁体   English

使用Angular应用程序的Paypal返回URL

[英]Paypal return url with Angular app

This is part of my router.js: 这是我的router.js的一部分:

  .state('app.thanks', {
        url: "/thanks",
        views: {
          'menuContent': {
            templateUrl: "templates/thanks.php"
          }
        }
      })

and in payapl WEBSITE PAYMENT PREFERENCES -> return url address I define this: https://my-website-url.com/#/app/thanks , 并在payapl网站付款首选项->返回URL地址中定义: https ://my-website-url.com/#/app/thanks,

as I understand, in order to get the params from Payapl I need to use this code to get transaction id: 据我了解,为了从Payapl获取参数,我需要使用以下代码来获取交易ID:

if(isset($_GET['tx']) && ($_GET['tx'])!=null && ($_GET['tx'])!= "") {
    $tx = $_GET['tx'];
    if($tx) doSometing();
}
else {
    exitCode();
}

How can I combine it with my angular app? 如何将其与我的角度应用程序结合? only need to put this code in my thanks.php page? 只需要将此代码放在我的thank.php页面中?

thanks!! 谢谢!!

You cannot do this step with your angular App. 您无法使用角度应用程序执行此步骤。 This has to be very clear since you need to verify the Transaction and payment with Paypal. 这必须非常清楚,因为您需要通过Paypal验证交易和付款。 to do that properly, the code has to run on the server and validated the payment process was actually successful, otherwise you can just hand out your products for free. 为了正确执行此操作,该代码必须在服务器上运行并验证付款过程是否成功,否则,您可以免费分发产品。 You did not add any code here to do that so I hope you have one ready that does it properly. 您没有在此处添加任何代码来执行此操作,因此希望您已经准备好正确执行此操作。

After verifying the Transaction on the server your own script can redirect the user to the right location on the angular app. 在服务器上验证交易后,您自己的脚本可以将用户重定向到angular应用程序上的正确位置。 So your setup and script should be similar to this - 因此,您的设置和脚本应与此类似-

WEBSITE PAYMENT PREFERENCES -> https://my-website-url.com/paypalVerify.php 网站付款首选项-> https://my-website-url.com/paypalVerify.php

if ( isset($_GET['tx']) && $_GET['tx'] ) {
    $tx = $_GET['tx'];
    if(verifyTx($tx)) {
        //do some stuff
        header('Location: https://my-website-url.com/#/app/thanks');
        die();
    }   
}
header('Location: https://my-website-url.com/#/app/wheresMyMoney');
die();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM