php - PayPal Rest API gives 401 error when switched to Live Credentials -
i creating small website in implemented paypal rest api process credit card checkouts.
now problem is working fine using sandbox credentials... gives following error when switch live credentials:
fatal error: uncaught exception 'paypal\exception\ppconnectionexception' message 'got http response code 401 when accessing https://api.paypal.com/v1/payments/payment. retried 0 times.' in c:\xampp\htdocs\rest_api_sdk_php\sample\vendor\paypal\sdk-core-php\lib\paypal\core\pphttpconnection.php:99 stack trace: #0 c:\xampp\htdocs\rest_api_sdk_php\sample\vendor\paypal\sdk-core-php\lib\paypal\transport\pprestcall.php(44): paypal\core\pphttpconnection->execute('{"intent":"sale...') #1 c:\xampp\htdocs\rest_api_sdk_php\sample\vendor\paypal\rest-api-sdk-php\lib\paypal\api\payment.php(246): paypal\transport\pprestcall->execute(array, '/v1/payments/pa...', 'post', '{"intent":"sale...') #2 c:\xampp\htdocs\rest_api_sdk_php\sample\payments\createpayment.php(89): paypal\api\payment->create(object(paypal\rest\apicontext)) #3 {main} thrown in c:\xampp\htdocs\rest_api_sdk_php\sample\vendor\paypal\sdk-core-php\lib\paypal\core\pphttpconnection.php on line 99
quite frankly have no idea causing error. made changes in 2 places when switching paypal live. i.e.
1st in "bootstrap.php":
$apicontext = new apicontext(new oauthtokencredential( '<live client id>', '<live secret>'));
gave live client-id , secret. , other file in made change "sdk_config.ini":
;service configuration [service] mode=live ; can set sandbox / live
changed "mode" "sandbox" "live"
is there other file in have make changes?
i facing same issue got solution.
you have change mode sandbox
live
, log.loglevel
debug
fine
:
/* sandbox */ $apicontext->setconfig( array( 'mode' => 'sandbox', 'log.logenabled' => true, 'log.filename' => '../paypal.log', 'log.loglevel' => 'debug', // please use fine level logging in live environments 'cache.enabled' => true, // 'http.curlopt_connecttimeout' => 30 // 'http.headers.paypal-partner-attribution-id' => '123123123' ) ); /* live */ $apicontext->setconfig( array( 'mode' => 'live', 'log.logenabled' => true, 'log.filename' => '../paypal.log', 'log.loglevel' => 'fine', // please use fine level logging in live environments 'cache.enabled' => true, // 'http.curlopt_connecttimeout' => 30 // 'http.headers.paypal-partner-attribution-id' => '123123123' ) );
Comments
Post a Comment