这是我的 router.js 的一部分:
.state('app.thanks', {
url: "/thanks",
views: {
'menuContent': {
templateUrl: "templates/thanks.php"
}
}
})
在 payapl WEBSITE PAYMENT PREFERENCES -> return url address 我定义了这个: https://my-website-url.com/#/app/thanks ,
据我了解,为了从 Payapl 获取参数,我需要使用此代码获取交易 ID:
if(isset($_GET['tx']) && ($_GET['tx'])!=null && ($_GET['tx'])!= "") {
$tx = $_GET['tx'];
if($tx) doSometing();
}
else {
exitCode();
}
如何将它与我的 Angular 应用程序结合起来?只需将此代码放在我的 thanks.php 页面中即可?
谢谢!!
最佳答案
您不能使用 Angular 应用执行此步骤。 这必须非常清楚,因为您需要使用 Paypal 验证交易和付款。为了正确地做到这一点,代码必须在服务器上运行并验证支付过程实际上是成功的,否则你可以免费分发你的产品。您没有在此处添加任何代码来执行此操作,因此我希望您已准备好能够正确执行此操作的代码。
在服务器上验证交易后,您自己的脚本可以将用户重定向到 Angular 应用程序上的正确位置。 所以你的设置和脚本应该与此类似 -
网站支付首选项 -> 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();
关于javascript - 带有 Angular 应用程序的 Paypal 返回 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30920279/