dqqpf32897
2013-08-02 18:36
浏览 274
已采纳

PayPal REST Api错误:响应401 PPConnectionException

I'm using the PHP PayPal REST API sandbox and getting errors when I do my $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
Stack trace:


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


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


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


#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)


#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\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. I've tried using the credentials in the demo app provided in rest-api-skd-php-master (the demo works btw).

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?

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.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpy15285 2013-08-05 15:43
    已采纳

    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.

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

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

    已采纳该答案
    打赏 评论
  • douju1928 2016-02-17 06:35

    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. hope that helps

    打赏 评论

相关推荐 更多相似问题