Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: Class "PaypalServerSDKLib\PaypalServerSDKClientBuilder" not found #4

Open
alisacorporation opened this issue Sep 9, 2024 · 8 comments

Comments

@alisacorporation
Copy link

hi all, wanted to try to run example and got error:

/bin/php /home/amg/PhpstormProjects/l2j_paypal_v2/main.php
PHP Fatal error: Uncaught Error: Class "PaypalServerSDKLib\PaypalServerSDKClientBuilder" not found in /home/amg/PhpstormProjects/l2j_paypal_v2/main.php:14
Stack trace:
#0 {main}
thrown in /home/amg/PhpstormProjects/l2j_paypal_v2/main.php on line 14

Process finished with exit code 255

Here is the code

<?php

require_once 'vendor/autoload.php';

use Psr\Log\LogLevel;
use PaypalServerSDKLib\Environment;
use PaypalServerSDKLib\PaypalServerSDKClientBuilder;
use PaypalServerSDKLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSDKLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSDKLib\Logging\ResponseLoggingConfigurationBuilder;
use PaypalServerSDKLib\Authentication\ClientCredentialsAuthCredentialsBuilder;


$client = PaypalServerSDKClientBuilder::init()
    ->clientCredentialsAuthCredentials(
        ClientCredentialsAuthCredentialsBuilder::init(
            'OAuthClientId',
            'OAuthClientSecret'
        )
    )
    ->environment(Environment::SANDBOX)
    ->loggingConfiguration(
        LoggingConfigurationBuilder::init()
        ->level(LogLevel::INFO)
        ->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
        ->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->body(true))
    )
    ->build();

var_dump($client);

php: PHP 8.3.11 / linux manjaro

@DPoplin
Copy link
Contributor

DPoplin commented Sep 10, 2024

Hey there, thanks for reaching out. It appears that this is being caused by the SDK not being properly installed as a dependency. Can you run composer require "paypal/paypal-server-sdk" and then try your testing again?

If you continue to run into errors, please let us know.

@alisacorporation
Copy link
Author

Hey there, thanks for reaching out. It appears that this is being caused by the SDK not being properly installed as a dependency. Can you run composer require "paypal/paypal-server-sdk" and then try your testing again?

If you continue to run into errors, please let us know.

Hi, same result :(

@LeonarthusMectus
Copy link

Hey @alisacorporation, apologies this went unanswered for a bit.

I believe this might be an edge case related to the case-sensitive nature of your filesystem and a change we made to the SDK.

Can you try adjusting your use statement for the client builder to PaypalServerSDKLib\PaypalServerSdkClientBuilder; Note the change in case on the SDK -> Sdk portion of the builder. Let's see if this has any impact.

@alisacorporation
Copy link
Author

Hey @alisacorporation, apologies this went unanswered for a bit.

I believe this might be an edge case related to the case-sensitive nature of your filesystem and a change we made to the SDK.

Can you try adjusting your use statement for the client builder to PaypalServerSDKLib\PaypalServerSdkClientBuilder; Note the change in case on the SDK -> Sdk portion of the builder. Let's see if this has any impact.

Hi, not problem. I have replaced all PaypalServerSDKClientBuilder to PaypalServerSdkClientBuilder and PaypalServerSDKClient to PaypalServerSdkClient and got it working, but those changes are in vendor directory, where return types was like that.. First error was about PaypalServerSDKClientBuilder and second was about PaypalServerSDKClient. When changed namespace to filename match case i got dd($client) response now.

Waiting for fix it for Linux users. Thank you!

@gabrielandrei
Copy link

Hello, "solved" modifing my composer.json:

"autoload": {
        "psr-4": {
           ....
        },
        "classmap": [
            "vendor/paypal/paypal-server-sdk/src"
        ]
    },

This way you have not to edit file under vendor folder waiting for the fix.
thank you!

@james-ingold
Copy link

james-ingold commented Oct 23, 2024

Hello,

I am also getting this issue: "Class "PaypalServerSDKLib\PaypalServerSdkClientBuilder" not found"
Changing to Sdk versus SDK and adding it under classmap does not work. PHP 8.2.24.

use PaypalServerSDKLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSDKLib\Environment;
use PaypalServerSDKLib\PaypalServerSdkClientBuilder;

EDIT

Gotta SDK to Sdk everything. Fixed now.

use PaypalServer**Sdk**Lib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServer**Sdk**Lib\Environment;
use PaypalServer**Sdk**Lib\PaypalServerSdkClientBuilder;

@LeonarthusMectus
Copy link

We recently released 0.6.0 which should fix this for Linux environments. It includes some small breaking changes around the namespace & class names, but avoids a situation where the name of the file & name of the class could differ, which would lead to issues like this on case-sensitive filesystems (such as ext4 is by default).

I'd definitely like to know if anyone here is able to test this version out, without the fixes and work arounds proposed here, and confirm if this resolves the problem.

@alisacorporation
Copy link
Author

We recently released 0.6.0 which should fix this for Linux environments. It includes some small breaking changes around the namespace & class names, but avoids a situation where the name of the file & name of the class could differ, which would lead to issues like this on case-sensitive filesystems (such as ext4 is by default).

I'd definitely like to know if anyone here is able to test this version out, without the fixes and work arounds proposed here, and confirm if this resolves the problem.

I have deleted vendor folder & package.json require, than require server-sdk package again so I get 0.6.0 version, updated composer, deleted all use namespaces in my code and reimported again with IDE and seems it works!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants