Uncaught Error: Interface "Http\Client\HttpClient" not found (when clicking on APC payment link)

Hello,

I’m running OJS 3.4.0.4 on a shared hosting service. I’ve got everything set up for my journal (https://jbai.ai). I turned on the PayPal payment plugin and added my client ID and secret. I was testing the submission workflow to make sure everything was working properly. After I accepted the article for publication, the OJS sent an email to the author asking them to pay the Article Processing Charge. The email contained a link to make the payment https://jbai.ai/index.php/jbai/payment/pay/1.

When I clicked on this link and logged in as the author, the web browser returned a 500 error. The error_log file contained the error “PHP Fatal error: Uncaught Error: Interface “Http\Client\HttpClient” not found in /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/guzzle7-adapter/src/Client.php:22”. Full stack trace is below.

Has anyone else encountered this and is there a way to fix it?

[07-Dec-2023 17:36:49 America/New_York] PHP Fatal error:  Uncaught Error: Interface "Http\Client\HttpClient" not found in /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/guzzle7-adapter/src/Client.php:22
Stack trace:
#0 /home/jbaiiykr/public_html/lib/pkp/lib/vendor/composer/ClassLoader.php(571): include()
#1 /home/jbaiiykr/public_html/lib/pkp/lib/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/discovery/src/ClassDiscovery.php(247): class_exists()
#4 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/discovery/src/ClassDiscovery.php(184): Http\Discovery\ClassDiscovery::safeClassExists()
#5 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/discovery/src/ClassDiscovery.php(71): Http\Discovery\ClassDiscovery::evaluateCondition()
#6 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/discovery/src/HttpClientDiscovery.php(25): Http\Discovery\ClassDiscovery::findOneByType()
#7 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/omnipay/common/src/Common/Http/Client.php(34): Http\Discovery\HttpClientDiscovery::find()
#8 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/omnipay/common/src/Common/AbstractGateway.php(332): Omnipay\Common\Http\Client->__construct()
#9 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/omnipay/common/src/Common/AbstractGateway.php(69): Omnipay\Common\AbstractGateway->getDefaultHttpClient()
#10 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/omnipay/common/src/Common/GatewayFactory.php(88): Omnipay\Common\AbstractGateway->__construct()
#11 [internal function]: Omnipay\Common\GatewayFactory->create()
#12 /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/omnipay/common/src/Omnipay.php(116): call_user_func_array()
#13 /home/jbaiiykr/public_html/plugins/paymethod/paypal/PaypalPaymentForm.php(55): Omnipay\Omnipay::__callStatic()
#14 /home/jbaiiykr/public_html/pages/payment/PaymentHandler.php(77): APP\plugins\paymethod\paypal\PaypalPaymentForm->display()
#15 [internal function]: APP\pages\payment\PaymentHandler->pay()
#16 /home/jbaiiykr/public_html/lib/pkp/classes/core/PKPRouter.php(334): call_user_func()
#17 /home/jbaiiykr/public_html/lib/pkp/classes/core/PKPPageRouter.php(277): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest()
#18 /home/jbaiiykr/public_html/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPPageRouter->route()
#19 /home/jbaiiykr/public_html/lib/pkp/classes/core/PKPApplication.php(388): PKP\core\Dispatcher->dispatch()
#20 /home/jbaiiykr/public_html/index.php(21): PKP\core\PKPApplication->execute()
#21 {main}
  thrown in /home/jbaiiykr/public_html/plugins/paymethod/paypal/vendor/php-http/guzzle7-adapter/src/Client.php on line 22

Hi @jimbo,

I’ve filed and hopefully fixed this issue here:

Can you try the fix described there and report back on whether it corrects the issue for you?

Thanks,
Alec Smecher
Public Knowledge Project Team

Thank you! I’ll give it a try now.

The patch solved the 500 error. Thank you for the quick response.

BTW, on my first test, I ran into a PayPal transaction error. I was using my PayPal Sandbox ClientID and Secret, but I hadn’t checked the “Enable” check box under the “Test Mode” section in Distribution > Payments. It’s a bit confusing because PayPal calls it “Sandbox” and not “Test Mode”. I suggest for better UX you change “Enable” to say “Using PayPal Sandbox Credentials”. This will make it clear what “Test Mode” actually means. It’s a very minor issue, but I think would help avoid confusion.

Thanks!
Jim