-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Module-Payment to handle dispute notifications.
- Loading branch information
1 parent
ba281cb
commit 1bf1fd4
Showing
11 changed files
with
242 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Adyen\Webhook\PaymentStates; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
use Adyen\Payment\Logger\AdyenLogger; | ||
use Adyen\Payment\Helper\Config; | ||
|
||
|
||
abstract class AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
/** @var Order */ | ||
private $orderHelper; | ||
|
||
/** @var AdyenLogger */ | ||
private $adyenLogger; | ||
|
||
/** @var Config */ | ||
private $configHelper; | ||
|
||
public function __construct(Order $orderHelper, AdyenLogger $adyenLogger, Config $configHelper) | ||
{ | ||
$this->orderHelper = $orderHelper; | ||
$this->adyenLogger = $adyenLogger; | ||
$this->configHelper = $configHelper; | ||
} | ||
|
||
public function handleWebhook(MagentoOrder $order, Notification $notification, string $transitionState): MagentoOrder | ||
{ | ||
$ignoreDisputeNotifications = $this->configHelper->getConfigData( | ||
'ignore_dispute_notification', | ||
'adyen_abstract', | ||
$order->getStoreId() | ||
); | ||
|
||
if ($transitionState === PaymentStates::STATE_REFUNDED && !$ignoreDisputeNotifications){ | ||
$order = $this->orderHelper->refundOrder($order, $notification); | ||
$this->adyenLogger->addAdyenNotification(sprintf( | ||
'The order has been updated by the %s notification. ', | ||
$notification->getEventCode(), | ||
), [ | ||
'pspReference' => $order->getPayment()->getData('adyen_psp_reference'), | ||
'merchantReference' => $order->getPayment()->getData('entity_id') | ||
]); | ||
} | ||
elseif ($ignoreDisputeNotifications){ | ||
$this->adyenLogger->addAdyenNotification(sprintf( | ||
'Config to ignore dispute notification is enabled. Notification %s will be ignored', | ||
$notification->getId() | ||
), [ | ||
'pspReference' => $notification->getPspreference(), | ||
'merchantReference' => $notification->getMerchantReference() | ||
]); | ||
} | ||
else { | ||
$this->orderHelper->addWebhookStatusHistoryComment($order, $notification); | ||
$this->adyenLogger->addAdyenNotification(sprintf( | ||
'There is a %s notification for the order.', | ||
$notification->getEventCode(), | ||
), [ | ||
'pspReference' => $order->getPayment()->getData('adyen_psp_reference'), | ||
'merchantReference' => $order->getPayment()->getData('entity_id') | ||
]); | ||
|
||
} | ||
return $order; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
|
||
|
||
class ChargebackReversedWebhookHandler extends AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
|
||
|
||
class ChargebackWebhookHandler extends AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
|
||
|
||
class NotificationOfChargebackWebhookHandler extends AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
|
||
|
||
class RequestForInformationWebhookHandler extends AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2022 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Helper\Webhook; | ||
|
||
use Adyen\Payment\Helper\Order; | ||
use Adyen\Payment\Model\Notification; | ||
use Magento\Sales\Model\Order as MagentoOrder; | ||
|
||
|
||
class SecondChargebackWebhookHandler extends AbstractDisputeWebhookHandler implements WebhookHandlerInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters