Search "'/vendor/autoload.php" (0 hits in 0 files of 210 searched) [Normal]
That file is not in the non-Composer SDK.
So i’m going to try that again…
you went to the Paypal (PHP) SDK page in their Getting Started section.
You downloaded the non-Composer SDK library.
You read the README file inside it.
You put the code library into your site… and…?
I don’t want to derail this thread, but I’ll test something’s out when I get back home from work. I know when I was using PayPal’s SDK library, it worked for me and I was able to get sent to PayPal’s sandbox domain. Granted that was 7 months ago so I’ll see what’s wrong and get back to you.
I’ll try to explain my setups. I am testing on localhost, but the files will be moved to hosting, I will keep all testing relative to the root folder for now.
Hosting account
ROOT FOLDER/htaccess (force https and remove .php extension)
ROOT FOLDER/paypal/index.php
STORAGE/VENDOR/autoload.php (so test index file I assume needs …/…/storage/vendor/autoload.php)
Wampp
ALIAS ROOT FOLDER/htaccess (remove .php extension)
ALIAS ROOT FOLDER/paypal/index.php
STORAGE/VENDOR/autoload.php (so test index file I assume needs …/…/storage/vendor/autoload.php)
require DIR . ‘…/…/storage/vendor/autoload.php’;
require(D:\Web\arcadeoperator\paypal…/…/storage/vendor/autoload.php): Failed to open stream: No such file or directory in D:\Web\arcadeoperator\paypal\index.php
So looks like I might have given you just a slight bit of misinformation as the PayPal Checkout SDK uses a different namespace than the SDK that I was originally using.
The use statements you should be using are
use \PayPalCheckoutSdk\Core\PayPalHttpClient;
use \PayPalCheckoutSdk\Core\SandboxEnvironment;
use \PayPalCheckoutSdk\Core\ProductionEnvironment;
With using just this code snippet I gave you on the other thread, I was able to produce a working example. Only difference here is we’re using the correct namespace and we’re outputting the PayPalHttpClient object to make sure we’re actually getting what we are looking for. Reminder to change where the vendor/autoload.php is located.
<?php
require_once '/vendor/autoload.php';
use \PayPalCheckoutSdk\Core\PayPalHttpClient;
use \PayPalCheckoutSdk\Core\SandboxEnvironment;
use \PayPalCheckoutSdk\Core\ProductionEnvironment;
if(PAYPAL_MODE == 'sandbox') {
$environment = new SandboxEnvironment(PAYPAL_CLIENT_ID, PAYPAL_SECRET, PAYPAL_MODE);
} elseif(PAYPAL_MODE == 'live') {
$environment = new ProductionEnvironment(PAYPAL_CLIENT_ID, PAYPAL_SECRET, PAYPAL_MODE);
} else {
throw new Exception('Unknown Paypal mode');
}
// Instantiate PayPal's entrypoint
$client = new PayPalHttpClient($environment);
print_r($client);
Here’s the output I get when I run that PHP code snippet from above.
Here’s the Composer command I used to get download the PayPal Checkout SDK. All I did was since I’m using Linux, I just went to the base root of the system and then used that command. Composer then auto generates a vendor folder for me to use. Hence why I didn’t need to change much in the code snippet I gave you. / refers to the base root of the system and then the vendor folder is automatically created from Composer so for me, /vendor is a legitimate folder location.