这是我问题的部分答案:我尝试使用键“redirect_uri”而不是“returnurl”,因为我在其他人的东西中看到过它。事实证明“returnurl”是正确的。
<div id="proceed-to-confirmation-page-link" class="text-right">
<span id="lippButton"></span>
</div>
<script src='https://www.paypalobjects.com/js/external/api.js'></script>
<script>
paypal.use(['login'], function (login) {
login.render({
"appid": "<MY APP ID>",
"authend": "sandbox",
"scopes": "openid profile address",
"containerid": "lippButton",
"locale": "en-us",
"text": "Login to PayPal to order",
"redirect_uri": "<MyRedirectURI>"
});
});
</script>
但是,我仍然不知道 PayPal 如何返回确认用户已登录的授权代码。我在会话中没有看到任何内容。
我也有同样的问题。 您可能使用了错误的应用程序 ID。在 https://api.sandbox.paypal.com/v1/oauth2/token 上发布会返回以下内容:
{
"scope": "scopes",
"nonce": "something",
"access_token": "something",
"token_type": "Bearer",
"app_id": "some id",
"expires_in": 32400
}
这不是您想要的appid。使用开发人员仪表板中的客户端 ID。
您好,以下代码对我有用!
<span id='lippButton'></span>
<script src='https://www.paypalobjects.com/js/external/api.js'></script>
<script>
paypal.use( ['login'], function (login) {
login.render ({
"appid":"<MY APP ID>",
"authend": "sandbox",
"scopes":"openid",
"containerid":"lippButton",
"responseType":"code",
"locale":"en-us",
"buttonType":"LWP",
"buttonShape":"pill",
"buttonSize":"lg",
"fullPage":"true",
"returnurl":"http://127.0.0.1/CyFlying/public/"
});
});
</script>
为我解决这个问题的是在沙盒帐户中启用“使用 PayPal 登录”。附参考资料: https://developer.paypal.com/docs/log-in-with-paypal/integrate/#link-enableloginwithpaypal