
Those who are working with Paypal SDk might have come across the error Fatal error: Class 'OAuthTokenCredential' not found"
This type of Class not found error occur mainly because of missing on Namespace in the file.
Error generating code is given below
=====================
require('vendor/autoload.php');
$sdkConfig = array(
"mode" => "sandbox"
);
$cred = new OAuthTokenCredential("RtUIouduouaTTdkahkVhueUEMvXO_-MCI4FGQQ4-LWvkMY5N2fGsd", "EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX",$sdkConfig);
var_dump($cred);
=====================
To fix such errors You have to specify the Namespace just before the creation of the Class object.
like given below:
====================
namespace PayPal\Auth ;
require('vendor/autoload.php');
$sdkConfig = array(
"mode" => "sandbox"
);
$cred = new OAuthTokenCredential("RtUIouduouaTTdkahkVhueUEMvXO_-MCI4FGQQ4-LWvkMY5N2fGsd", "EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX",$sdkConfig);
var_dump($cred);
====================
Paypal SDF libraries are in following location:
vendor/paypal/rest-api-sdk-php/lib/PayPal/
so the autoload class tries to load the class files with respect to the "lib" folder in the above folder path.