Search code examples
phprestpaypalpaypal-sandbox

paypal sdk 'Class 'PayPal\Rest\ApiContext' not found'


I'm trying to implement paypal api sdk using this code

require('vendor/autoload.php');
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;

$api = new ApiContext(
 new OAuthTokenCredential(
    'client id',
    'secret'
 )
);

$api->setConfig([
 'mode'=>'sandbox',
 'http.ConnectionTimeOut'=>30,
 'log.LogEnabled'=>false,
 'log.FileName'=>'',
 'log.LogLevel'=>'FINE',
 'validation.level'=>'log'
]);

The Rest and Auth folders are subfolders of PayPal folder which exists inside the vendor folder. But I get this error "Class 'PayPal\Rest\ApiContext' not found"


Solution

  • I am not sure if you are still facing this issue, but I would recommend going through the documentation mentioned here. This should help you find the reason why you are getting this error.

    Also, making your first call documentation would really help get you started.