PayPal重定向到相同的弹出窗口 [英] PayPal redirects to the same popup window
问题描述
我在我的网页中集成了PayPal的Identity API.和往常一样,当用户点击login with paypal
( JavaScript按钮),它将打开一个用于登录目的的新窗口.但是在有效登录后,它将我重定向到相同的弹出窗口.
I integrated PayPal's Identity API in my webpage. As usual when user clicks login with paypal
(JavaScript button) it opens a new window for login purpose. But after a valid login it redirect me to the same popup window.
注意:我将域名替换为domain
Note: I replaced my domain name as 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>
控制器
//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());
成功登录
重定向到配置的重定向URL
推荐答案
我遇到了确切的问题,但是解决方案在此处的文档中:
I had the exact problem, but the solution is in the documentation here:
https://developer.paypal.com/docs /classic/express-checkout/digital-goods/ClosingWindow/
请参阅将父页面重新加载到特定URL",并将此脚本添加到返回和取消页面.
Refer to "Reloading Parent Page to a Specific URL" and add this script to the return and cancel pages.
<script>
top.window.opener.location ='http://your-url-here.html';
// if you want to close the window
// window.close();
</script>
这篇关于PayPal重定向到相同的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!