gpt4 book ai didi

javascript - Paypal 重定向到同一个弹出窗口

转载 作者:可可西里 更新时间:2023-11-01 12:55:33 25 4
gpt4 key购买 nike

我在我的网页中集成了 PayPal 的 Identity API。与往常一样,当用户单击 login with paypal( JavaScript button ) 时,它会打开一个用于登录的新窗口。但在有效登录后,它会将我重定向到同一个弹出窗口。

注意:我将我的域名替换为 domain

应用返回 URL(测试): http://domain.esy.es/index.php/users/paypalidentity

查看

//url http://domain.esy.es/index.php
<span id="paypalButton"></span>
<script src="https://www.paypalobjects.com/js/external/api.js"></script>
<script>
paypal.use( ["login"], function(login) {
login.render ({
"appid": MYAPPID,
"authend": "sandbox",
"scopes": "openid email profile address phone https://uri.paypal.com/services/paypalattributes",
"containerid": "paypalButton",
"locale": "en-us",
"returnurl": "http://domain.esy.es/index.php/users/paypalidentity"
});
});
</script>

Controller

//url http://domain.esy.es/index.php/users/paypalidentity
require_once __DIR__ . '/../../vendor/autoload.php';
$apicontext = new PPApiContext(array('mode' => 'sandbox'));
$code = $_REQUEST['code'];
$apicontext = new PPApiContext(array('mode' => 'sandbox'));
$params = array(
'client_id' => MYCLIENTID,
'client_secret' => MYSECRET,
'code' => $code
);
$token = PPOpenIdTokeninfo::createFromAuthorizationCode($params,$apicontext);
$apicontext = new PPApiContext(array('mode' => 'sandbox'));
$params = array('access_token' => $token->getAccessToken());
$user = PPOpenIdUserinfo::getUserinfo($params,$apicontext);
$this->session->set_userdata(
array(
'name'=>$user->getName()
)
);
redirect(base_url());

登录成功 enter image description here

重定向到配置的重定向 URL enter image description here

最佳答案

我遇到了确切的问题,但解决方案在此处的文档中:

https://developer.paypal.com/docs/classic/express-checkout/digital-goods/ClosingWindow/

引用“Reloading Parent Page to a Specific URL”并将此脚本添加到返回和取消页面。

<script>
top.window.opener.location ='http://your-url-here.html';
// if you want to close the window
// window.close();
</script>

关于javascript - Paypal 重定向到同一个弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22846186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com