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"
Same error here. Solved reading the documentation:
require('vendor/autoload.php');
$api = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
$client_ID,
$client_Secret
)
);
In my case of Laravel implementation, adding this solved my problem:
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Payer;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Payment;
use PayPal\Exception\PayPalConnectionException;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With