PayPal REST API,PHP SDK,计费,我收到错误消息REQUIRED_SCOPE_MISSING。

4

在使用自己的clientId和secret执行PayPal的样例/billing/CreatePlan.php时,我遇到了REQUIRED_SCOPE_MISSING错误。使用提供的clientId和secret是可以工作的。

复现步骤:

下载PayPal-PHP-SDK v0.14.2

进入sample/billing目录

运行
php CreatePlan.php

该文件的第9行包含bootstrap.php程序,其中定义了clientId和secret。

如果我使用现有的clientId和secret,它将正常工作。如果我替换为自己的clientId和secret,则会出现此处显示的错误信息。

[myprompt]$ php CreatePlan.php
Warning: This sample may require a server to handle return URL. Cannot execute in  command line. Defaulting URL to http://localhost/sample/billing

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(1) CREATED PLAN
-------------------------------------------------------------

-------------------------------------------------------------
    REQUEST:
{"name":"T-Shirt of the Month Club Plan","description":"Template       creation.","type":"fixed",
"payment_definitions":[{"name":"Regular Payments","type":"REGULAR","frequency":"Month",
"frequency_interval":"2","cycles":"12","amount":{"value":"100.00","currency":"USD"},
"charge_models":[{"type":"SHIPPING","amount":{"value":"10.00","currency":"USD"}}]}],
"merchant_preferences":{"return_url":"http://localhost/sample/billing /ExecuteAgreement.php?success=true",
"cancel_url":"http://localhost/sample/billing/ExecuteAgreement.php?success=false","auto_bill_amount":"yes","initial_fail_amount_action":    "CONTINUE","max_fail_attempts":"0","setup_fee":{"value":"1.00","currency":"USD"}}}

    RESPONSE:
ERROR:Got Http response code 403 when 
accessing https://api.sandbox.paypal.com/v1/payments/billing-plans/.    {"name":"REQUIRED_SCOPE_MISSING",
"message":"Access token does not have required scope",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api  /#REQUIRED_SCOPE_MISSING","debug_id":"261257fb27891"}
-------------------------------------------------------------

我的clientId和secret在所有的支付示例中都可以很好地工作。


顺便提一下,如果你正在使用PHP5.4或更高版本,现在你可以通过运行一个命令在Web上使用PHP内置服务器来使示例工作:php -f samples/index.php只需确保你正在使用最新的代码。很快就会发布新版本。 - Jay Patel - PayPal
1个回答

4
为了解决这个错误,你需要确保在developer.paypal.com上创建的REST应用程序,在"APP CAPABILITIES" -->> "高级选项"下,"订阅"复选框被选中。
以下是截图参考:

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接