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

Logging errors in webhook listener (49258) #383

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading