PayPal redirects to the same popup window(贝宝重定向到同一个弹出窗口)
问题描述
我在我的网页中集成了 PayPal 的身份 API.像往常一样,当用户点击 login with paypal
(
请参阅将父页面重新加载到特定 URL"并将此脚本添加到返回和取消页面中.
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.
Note: I replaced my domain name as domain
App return URL (test): http://domain.esy.es/index.php/users/paypalidentity
View
//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());
Successful Login
Redirecting to the configured redirect 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/
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>
这篇关于贝宝重定向到同一个弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:贝宝重定向到同一个弹出窗口
基础教程推荐
- HTTP 与 FTP 上传 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01