Skip to content

Commit

Permalink
Merge pull request #383 from 202ecommerce/bugfix/49258-webhook-handling
Browse files Browse the repository at this point in the history
refs #49258 logging errors in webhook listener
  • Loading branch information
bogdan202 authored Dec 4, 2024
2 parents c36624d + 4a6c387 commit 9f19a59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions controllers/front/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
abstract class PaypalAbstarctModuleFrontController extends CommonAbstarctModuleFrontController
{
/** @var Module|PayPal */
public $module;

/**
* @return PaymentData
*/
Expand Down
8 changes: 2 additions & 6 deletions controllers/front/webhookhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_')) {
Expand All @@ -41,9 +40,6 @@
*/
class PaypalWebhookhandlerModuleFrontController extends PaypalAbstarctModuleFrontController
{
/** @var ServicePaypalOrder */
protected $servicePaypalOrder;

/** @var array */
protected $requestData;

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,7 @@ public function getWebhookOption()
return new WebhookOption();
}

protected function getPaypalOrderService()
public function getPaypalOrderService()
{
return new ServicePaypalOrder();
}
Expand Down

0 comments on commit 9f19a59

Please sign in to comment.