0

I first installed the PayPal API using Composer and managed to get the PHP code working:

<?php

$paypal = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
    'xxx', 
    'xxx')
);

?>

And I added this to the Index.php page

require_once __DIR__ . '/vendor/autoload.php';

As I said this used to work. Then I installed the FB API using the following Composer Json file:

{
    "require": {
        "paypal/rest-api-sdk-php": "1.10.0",
        "facebook/graph-sdk" : "~5.0"
    }
}

The FB is working but I can't seem to use the PayPal API anymore. I deleted the entire Vendor dir and uploaded it again on the server. The vendor/autload.php file looks likes this:

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit303a6e73ffa85ad916995f78100e5117::getLoader();

First I don't know why the file doesn't end with a ?>? Is this normal?

When I try to call my paypal.php file I get the infamous error:

 Uncaught Error: Class 'PayPal\Rest\ApiContext' not found in ...
user18490
  • 3,546
  • 4
  • 33
  • 52
  • I don't know what's wrong here, but PHP files lacking a closing `?>` are perfectly fine. In fact, this is considered a best practice on PHP-only files by many developers. See [PSR-2](http://www.php-fig.org/psr/psr-2/#2-2-files), for example. – ChrisGPT was on strike Nov 08 '16 at 20:59
  • There is a working solution described in https://stackoverflow.com/questions/39400764/fatal-error-class-paypal-api-payer-not-found-en-sdk-paypal/47776518#47776518 by Olga. – olga Dec 12 '17 at 15:50

1 Answers1

0

Be sure to add:

require_once __DIR__ . '/vendor/autoload.php';

To the files. Adding to index.php is not enough apparently. It needs to be inserted within the paypal.php file from which the API functions are used.

user18490
  • 3,546
  • 4
  • 33
  • 52