用于PayPal RESTful API的PHP SDK正在运行错误


PHP SDK for PayPal RESTful APIs going live error

我目前正在尝试从沙盒模式切换到我创建的支付系统。这是我第一次使用贝宝sdk,所以我不太熟悉它。一旦我到达系统的点,你应该重定向到贝宝,我就会不断收到以下错误。我知道这个问题在我浏览所有这些,尝试它们的更改之前就已经被问过了,但它仍然不适用于我

尝试访问贝宝时出错

当在沙箱模式下运行时,我将凭据更改为实时凭据。

这是我的系统的开始,它应该授权系统

require __DIR__  . '/vendor/autoload.php';
define('SITE_URL', 'url name');
$paypal = new 'PayPal'Rest'ApiContext(
 new 'PayPal'Auth'OAuthTokenCredential(
 'Client ID',
 'Secret Code'
 )
);

这是我的sdk_config.ini文件,它与我的代码位于同一文件夹中:

;Account credentials from developer portal
[Account]
acct1.ClientId = 
acct1.ClientSecret =
;acct2.ClientId = TestClientId
;acct2.ClientSecret = TestClientSecret
;Connection Information
[Http]
http.ConnectionTimeOut = 60
http.Retry = 1
;http.Proxy=http://[username:password]@hostname[:port][/path]
mode=live
;Service Configuration
[Service]
;service.EndPoint="https://api.sandbox.paypal.com"
; Uncomment this line for integrating with the live endpoint 
 service.EndPoint="https://api.paypal.com"

;Logging Information
[Log]
log.LogEnabled=true
; When using a relative path, the log file is created
; relative to the .php file that is the entry point
; for this request. You can also provide an absolute
; path here
log.FileName=PayPal.log
; Logging level can be one of FINE, INFO, WARN or ERROR
; Logging is most verbose in the 'FINE' level and
; decreases as you proceed towards ERROR
log.LogLevel=FINE
;Validation Configuration
[validation]
; If validation is set to strict, the PayPalModel would make sure that
; there are proper accessors (Getters and Setters) for each model
; objects. Accepted value is
; 'log'     : logs the error message to logger only (default)
; 'strict'  : throws a php notice message
; 'disable' : disable the validation
validation.level=strict

我不确定遗漏了什么,有人能给我指明正确的方向来解决这个问题吗。此外,在贝宝的开发者网站中,在你点击实时按钮的实际应用程序下,我点击实时按钮,我有使用这些凭据的代码。当它显示"直播"时,我会单击"保存",但当我返回时,它会返回到沙盒。如果您需要提供额外的代码来找到错误的来源,请告诉我。

根据错误消息"invalid_client",您似乎仍然使用了错误的客户端id和机密,或者可能在沙箱环境中使用了实时凭据。正如您所提到的,在沙箱环境中,它工作得很好,所以您的代码中没有问题。如果您正确复制了实时客户端id和机密,请仔细检查您的代码,可能其他文件中有设置需要配置为实时环境。