Home  »     »     »  How to fix paypal SDK error "Fatal error: Class 'OAuthTokenCredential' not found"

How to fix paypal SDK error "Fatal error: Class 'OAuthTokenCredential' not found"

Thursday, February 27, 2014



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.



How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
How to fix paypal SDK error "Fatal error: Class 'OAuthTokenCredential' not found".




Share this!




comments powered by Disqus

This Weeks 7 Popular Posts


Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   



Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »