在使用自己的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在所有的支付示例中都可以很好地工作。
php -f samples/index.php
只需确保你正在使用最新的代码。很快就会发布新版本。 - Jay Patel - PayPal