From 4a6c387db076ba2ad26de46927b394e340cbe4af Mon Sep 17 00:00:00 2001 From: bogdan202 Date: Wed, 4 Dec 2024 11:03:39 +0100 Subject: [PATCH] refs #49258 logging errors in webhook listener --- controllers/front/abstract.php | 3 +++ controllers/front/webhookhandler.php | 8 ++------ paypal.php | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/controllers/front/abstract.php b/controllers/front/abstract.php index 8093a9f8..4dea4652 100644 --- a/controllers/front/abstract.php +++ b/controllers/front/abstract.php @@ -37,6 +37,9 @@ */ abstract class PaypalAbstarctModuleFrontController extends CommonAbstarctModuleFrontController { + /** @var Module|PayPal */ + public $module; + /** * @return PaymentData */ diff --git a/controllers/front/webhookhandler.php b/controllers/front/webhookhandler.php index 87d4fd2f..07968a9a 100644 --- a/controllers/front/webhookhandler.php +++ b/controllers/front/webhookhandler.php @@ -29,7 +29,6 @@ use PaypalAddons\classes\API\Model\WebhookEvent; use PaypalAddons\classes\Constants\WebhookHandler; use PaypalAddons\classes\Webhook\WebhookEventHandler; -use PaypalAddons\services\ServicePaypalOrder; use PaypalPPBTlib\Extensions\ProcessLogger\ProcessLoggerHandler; if (!defined('_PS_VERSION_')) { @@ -41,9 +40,6 @@ */ class PaypalWebhookhandlerModuleFrontController extends PaypalAbstarctModuleFrontController { - /** @var ServicePaypalOrder */ - protected $servicePaypalOrder; - /** @var array */ protected $requestData; @@ -85,7 +81,7 @@ public function run() if ($this->webhookEventHandler->handle($webhookEvent)) { header('HTTP/1.1 200 OK'); } else { - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); + header($_SERVER['SERVER_PROTOCOL'] . ' 422 Unprocessable Content', true, 422); } } else { $paypalOrder = $this->initPaypalOrder($this->getRequest()); @@ -193,7 +189,7 @@ protected function initPaypalOrder($requestData) if (false == empty($event->getResource()->supplementary_data->related_ids->order_id)) { $paymentId = $event->getResource()->supplementary_data->related_ids->order_id; - return $this->servicePaypalOrder->getPaypalOrderByPaymentId($paymentId); + return $this->module->getPaypalOrderService()->getPaypalOrderByPaymentId($paymentId); } return new PaypalOrder(); diff --git a/paypal.php b/paypal.php index c562b905..ffccba70 100755 --- a/paypal.php +++ b/paypal.php @@ -2908,7 +2908,7 @@ public function getWebhookOption() return new WebhookOption(); } - protected function getPaypalOrderService() + public function getPaypalOrderService() { return new ServicePaypalOrder(); }