Reputation: 1
I'm trying to integrate PayPal, for express checkout with their PHP SDK. Unfortunately though, I'm getting the following error:
"Fatal error: Uncaught Error: Class 'Paypal\Rest\ApiContext' not found"
However, I can't see anything at all wrong with my code:
require "vendor/autoload.php";
$paypal = new \Paypal\Rest\ApiContext(
new \Paypal\Auth\OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET)
);
I have been through the documentation on this, and it hasn't really been of any help to me. My code is identical to that within the PayPal documentation, and I downloaded and placed their SDK files exactly as advised within the documentation. Unfortunately, I can not see what the issue is.
Any assistance would be greatly appreciated, many thanks.
Upvotes: 0
Views: 1315
Reputation: 4117
PayPal
, not Paypal
(notice the capital P). So you want:
require "vendor/autoload.php";
$paypal = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET)
);
Upvotes: 1
Reputation: 548
Try to remove the first '\' before your Paypal class name.
Replace this :
$paypal = new \Paypal\Rest\ApiContext
By This:
$paypal = new Paypal\Rest\ApiContext
You also need to replace new \Paypal\Auth\OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET)
By new Paypal\Auth\OAuthTokenCredential(CLIENT_ID, CLIENT_SECRET)
Upvotes: 0