Persistent Payment Woes: The 'No Shop Context' Error with Stripe and ps_eventbus in PrestaShop
Persistent Payment Woes: The "No Shop Context" Error with Stripe and ps_eventbus in PrestaShop
In the dynamic world of e-commerce, a seamless checkout experience is paramount. However, PrestaShop merchants occasionally encounter cryptic errors that can disrupt crucial processes like payment validation and order creation. One such perplexing issue, highlighted in a recent PrestaShop forum thread, involves a "Webhook non-retryable error: No shop context" related to the stripe_official and ps_eventbus modules.
The Core Problem: A Persistent "No Shop Context" Error
The forum user, BlackCrow, reported a recurring error appearing in their PrestaShop logs after every successful Stripe payment. Despite payments being processed by Stripe, the PrestaShop backend struggled to finalize the order, leading to the following critical error trace:
stripe_official - mLpeRec0ac0fLsoff - /controllers/front/webhook.php:115 - Webhook non-retryable error: No shop context - #0 [internal function]: Ps_eventbus->__construct() #1 pfad-zum-shopsrc/Core/Foundation/IoC/Container.php(104): ReflectionClass->newInstance() #2 pfad-zum-shopsrc/Core/Foundation/IoC/Container.php(134): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->makeInstanceFromClassName() #3 pfad-zum-shopsrc/Core/Foundation/IoC/Container.php(147): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->doMake() #4 pfad-zum-shopsrc/Adapter/ServiceLocator.php(50): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->make() #5 pfad-zum-shopclasses/module/Module.php(1386): ModuleCore::coreLoadModule() #6 pfad-zum-shopclasses/module/Module.php(1365): ModuleCore::getInstanceByName() #7 pfad-zum-shopclasses/Hook.php(1105): HookCore::exec() #8 pfad-zum-shopclasses/ObjectModel.php(800): ObjectModelCore->update() #9 pfad-zum-shopclasses/Cart.php(309): CartCore->update() #10 pfad-zum-shopmodules/stripe_official/classes/services/PrestashopOrderService.php(80): PrestashopOrderService->validateAndCreatePsOrderCore() #11 pfad-zum-shopmodules/stripe_official/classes/services/PrestashopOrderService.php(173): StripePdoLockService->executeUnderLock() #12 pfad-zum-shopmodules/stripe_official/classes/services/StripePdoLockService.php(63): PrestashopOrderService->{closure:PrestashopOrderService::createPsOrder():171}() #13 pfad-zum-shopmodules/stripe_official/classes/services/PrestashopOrderService.php(171): PrestashopOrderService->createPsOrder() #14 pfad-zum-shopmodules/stripe_official/classes/services/PrestashopBuildOrderService.php(64): PrestashopBuildOrderService->buildAndCreatePrestashopOrder() #15 pfad-zum-shopmodules/stripe_official/classes/payment/WebhookEventHandler.php(393): WebhookEventHandler->syncStatusWithPs() #16 pfad-zum-shopmodules/stripe_official/classes/payment/WebhookEventHandler.php(291): WebhookEventHandler->paymentSucceededEvent() #17 pfad-zum-shopmodules/stripe_official/classes/payment/WebhookEventHandler.php(145): WebhookEventHandler->processEvent() #18 pfad-zum-shopmodules/stripe_official/classes/payment/WebhookEventHandler.php(101): WebhookEventHandler->handleRequest() #19 pfad-zum-shopmodules/stripe_official/controllers/front/webhook.php(105): stripe_officialWebhookModuleFrontController->postProcess() #20 pfad-zum-shopclasses/controller/Controller.php(297): ControllerCore->run() #21 pfad-zum-shopclasses/Dispatcher.php(500): DispatcherCore->dispatch() #22 pfad-zum-shopindex.php(66): DispatcherCore->dispatch() #23 {main}This error points to a fundamental issue within the PrestaShop environment: the absence of a "shop context." In PrestaShop, the shop context (Shop::getContext()) is crucial for identifying which shop a request belongs to, especially in multi-store setups, but also for single-store environments where modules and core functionalities rely on it for correct data retrieval and processing. The error occurs specifically within the Stripe module's webhook handler, which is responsible for receiving payment success notifications from Stripe and subsequently updating the PrestaShop order status and creating the order.
Troubleshooting Efforts and Unresolved Status
BlackCrow diligently attempted several common troubleshooting steps:
- Module Reinstallation: Both
ps_eventbusandstripe_officialmodules were completely uninstalled, their respective folders deleted, and then reinstalled with their latest versions. This is a robust method to rule out corrupted module files or incorrect installations. - Version Compatibility Checks: The issue was observed across multiple PrestaShop versions (from 7.x to the latest 9.1) and various PHP versions (8.x to 8.4). This suggests the problem is not tied to a specific PrestaShop or PHP version bug, but rather a more systemic configuration or environmental factor.
- Webhook URL Verification: The user confirmed that the webhook URLs configured in Stripe matched those in PrestaShop's
ps_configuration.
Despite these efforts, the error persisted, and as of the time of this insight, the forum thread had no replies providing a solution. The user's suspicion that a "parameter in the shop configuration is not correct" is a strong lead. The "No shop context" error often arises from issues related to multi-store configuration (even if not actively used), server environment specifics, or module conflicts that prevent PrestaShop from correctly initializing the shop context during background processes like webhook calls.
For merchants encountering this critical error, it highlights the importance of thorough debugging, including checking server logs, enabling PrestaShop's debug mode, and systematically investigating potential configuration discrepancies that could affect how PrestaShop establishes its operational context. This thread serves as a reminder that even with robust modules and updated platforms, intricate configuration details can lead to significant operational hurdles.