我在我的网页中集成了PayPal的Identity API.像往常一样,当用户点击使用paypal(
JavaScript button)登录时,它会打开一个用于登录目的的新窗口.但在有效登录后,它会将我重定向到同一个弹出窗口.
注意:我将域名替换为域名
应用返回网址(测试):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());
成功登录
解决方法
@H_404_21@ 我有确切的问题,但解决方案在这里的文档中:https://developer.paypal.com/docs/classic/express-checkout/digital-goods/ClosingWindow/
请参阅“将父页面重新加载到特定URL”并将此脚本添加到返回和取消页面.
<script> top.window.opener.location ='http://your-url-here.html'; // if you want to close the window // window.close(); </script>