1

I set up simple paypal check out with Rest Api (not credit card payment).

Everything works perfectly in Sandbox mode, but when I switch to Live mode and use Live mode clientID with Secret key. I get this error:

PHP Fatal error:  Uncaught exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 401 when accessing https://api.sandbox.paypal.com/v1/oauth2/token.' in /vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:154
Stack trace:
#0 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php(241): PayPal\Core\PayPalHttpConnection->execute('grant_type=clie...')
#1 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php(266): PayPal\Auth\OAuthTokenCredential->getToken(Array, '***', '***...', 'grant_type=clie...')
#2 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php(210): PayPal\Auth\OAuthTokenCredential->generateAccessToken(Array, NULL)
#3 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php(160 in /vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php on line 154

It happens only in Live mode... I checked all keys and everything is set up correctly, from my point of view. Please, let me know how this can be fixed?

1 Answer 1

1

The issue is solved!

I needed to add the folowing code to configure Live mode manually:

$paypal->setConfig(
      array(
        'mode' => 'live',
        'log.LogEnabled' => true,
        'log.FileName' => 'PayPal.log',
        'log.LogLevel' => 'FINE'
      )
    );
Sign up to request clarification or add additional context in comments.

1 Comment

For laravel : $apiContext->setConfig need to be set. github.com/paypal/PayPal-PHP-SDK/wiki/Adding-Configurations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.