简体   繁体   English

PayPal REST Api错误:响应401 PPConnectionException

[英]PayPal REST Api error: response 401 PPConnectionException

I'm using the PHP PayPal REST API sandbox and getting errors when I do my $payment->create( $apiContext ); 我正在使用PHP PayPal REST API沙箱,并且在执行$payment->create( $apiContext );时遇到错误$payment->create( $apiContext );

My Error log reads as: 我的错误日志显示为:

    PHP Fatal error:  Uncaught exception 'PayPal\\Exception\\PPConnectionException' with message 

'Got Http response code 401 when accessing https://api.paypal.com/v1/oauth2/token. 
    Retried 0 times.' in /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:99\nStack trace:\n

#0 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(96): 
    PayPal\\Core\\PPHttpConnection->execute('grant_type=clie...')\n

#1 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(76): 
    PayPal\\Auth\\OAuthTokenCredential->_generateAccessToken(Array)\n

#2 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Rest/RestHandler.php(56): PayPal\\Auth\\OAuthTokenCredential->getAccessToken(Array)\n

#3 /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(41): 
    PayPal\\Rest\\RestHandler->handle(Object(PayPal\\Core\\PPHttpConfig), '{"intent":"sale...', Array)\n

#4 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/A in 
    /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 99, 
    referer: http://domain.com/products/basket/verify/

my PayPal.log file shows: 我的PayPal.log文件显示:

PayPal\Core\PPHttpConnection: Connecting to https://api.paypal.com/v1/oauth2/token
PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.18-348.6.1.el5;machine=x86_64;openssl=0.9.8e-fips-rhel5;curl=7.15.5)
PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QVpteVVCQ3VfdDhlb3QxcGx0UksyUG56Y3NhcXpOeXNIMlNDLXBDbTlUNGVGNDE3OFd1cFBFRmhkTVpnOkVGZ3g4UkNCZUppSkw3NW1JV1FDRFROTVVsanFOLW1fdlFuM3owMzZOZ3EwTUp3RVFwRkNlV0Z0dWhaag==
PayPal\Core\PPHttpConnection: Adding header Accept: */*

I've tried test cc numbers, cc numbers set up on paypal's sandbox site. 我试过测试cc编号,该cc编号在paypal的沙盒网站上设置。 I've tried using the credentials in the demo app provided in rest-api-skd-php-master (the demo works btw). 我尝试使用rest-api-skd-php-master中提供的演示应用程序中的凭据(演示有效)。

I can show you my code though it pretty precisely emulates the test case. 我可以向您展示我的代码,尽管它可以精确地模拟测试用例。

The only thing I can think of is that the processing files are buried below www access levels? 我唯一想到的是处理文件埋在www访问级别以下吗?

If you can clean any info from the error logs I'm all ears. 如果您可以从错误日志中清除任何信息,我将不胜枚举。 If there's more info you need from me I can provide it. 如果您需要我的更多信息,我可以提供。

If you are intending to use sandbox as stated in the first line, then the error is happening because you are calling production PayPal servers. 如果您打算如第一行所述使用沙箱,则由于正在调用生产PayPal服务器,因此发生了错误。

Change https://api.paypal.com/v1/oauth2/token 更改https://api.paypal.com/v1/oauth2/token

To https://api.sandbox.paypal.com/v1/oauth2/token https://api.sandbox.paypal.com/v1/oauth2/token

I had same issue due to being a new in laravel 5.1, for paypal you need to set it to sandbox in /app/Http/controllers/paypalcontroller.php and also your paypal details in /app/Ecommerce/Billing/paypal.php. 由于是laravel 5.1中的新功能,我遇到了同样的问题,对于paypal,您需要将其设置为/app/Http/controllers/paypalcontroller.php中的沙箱,还需要将您的paypal详细信息设置为/app/Ecommerce/Billing/paypal.php中。 hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM