Skip to content
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
14 changes: 1 addition & 13 deletions Helper/Webhook/ExpireWebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\Order as OrderHelper;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\Config\Source\CaptureMode;
use Adyen\Payment\Model\Notification;
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Model\Order;
Expand Down Expand Up @@ -50,19 +49,8 @@ public function handleWebhook(Order $order, Notification $notification, string $
{
$storeId = $order->getStoreId();
$isExpireWebhookIgnored = $this->configHelper->isExpireWebhookIgnored($storeId);
$captureMode = $this->configHelper->getCaptureMode($storeId);

if (strcmp($captureMode, CaptureMode::CAPTURE_MODE_AUTO) === 0) {
/*
* Expire webhook should not be obtained if auto capture is enabled.
* If so, it might be an indicator of an incorrect plugin configuration.
*/
$orderComment = __(
'An unexpected %1 webhook has arrived even though auto capture is enabled, please check the plugin configuration! This webhook was skipped.',
$notification->getEventCode()
);
$logMessage = $orderComment;
} elseif ($isExpireWebhookIgnored) {
if ($isExpireWebhookIgnored) {
$orderComment = __(
'The remaining uncaptured authorisation with amount %1 has expired but no action has been taken as the %2 webhook was skipped.',
$notification->getFormattedAmountCurrency(),
Expand Down
36 changes: 0 additions & 36 deletions Test/Unit/Helper/Webhook/ExpireWebhookHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Adyen\Payment\Helper\Webhook\ExpireWebhookHandler;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\AdyenAmountCurrency;
use Adyen\Payment\Model\Config\Source\CaptureMode;
use Adyen\Payment\Model\Notification;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Magento\Sales\Api\Data\OrderInterface;
Expand Down Expand Up @@ -65,31 +64,8 @@ protected function tearDown(): void
$this->webhookHandler = null;
}

public function testAutoCaptureEnabled(): void
{
$this->configMock->expects($this->once())
->method('getCaptureMode')
->willReturn(CaptureMode::CAPTURE_MODE_AUTO);

$this->adyenLoggerMock->expects($this->once())->method('addAdyenNotification');
$this->orderMock->expects($this->once())->method('addCommentToStatusHistory');
$this->orderHelperMock->expects($this->never())->method('holdCancelOrder');

$result = $this->webhookHandler->handleWebhook(
$this->orderMock,
$this->notificationMock,
'pending'
);

$this->assertInstanceOf(OrderInterface::class, $result);
}

public function testExpireWebhookIgnored()
{
$this->configMock->expects($this->once())
->method('getCaptureMode')
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);

$this->configMock->expects($this->once())
->method('isExpireWebhookIgnored')
->willReturn(true);
Expand All @@ -109,10 +85,6 @@ public function testExpireWebhookIgnored()

public function testHandleWebhookWithPartialExpiration()
{
$this->configMock->expects($this->once())
->method('getCaptureMode')
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);

$this->configMock->expects($this->once())
->method('isExpireWebhookIgnored')
->willReturn(false);
Expand Down Expand Up @@ -142,10 +114,6 @@ public function testHandleWebhookWithPartialExpiration()

public function testHandleWebhookWithShipments()
{
$this->configMock->expects($this->once())
->method('getCaptureMode')
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);

$this->configMock->expects($this->once())
->method('isExpireWebhookIgnored')
->willReturn(false);
Expand Down Expand Up @@ -176,10 +144,6 @@ public function testHandleWebhookWithShipments()

public function testHandleWebhookSuccessfully()
{
$this->configMock->expects($this->once())
->method('getCaptureMode')
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);

$this->configMock->expects($this->once())
->method('isExpireWebhookIgnored')
->willReturn(false);
Expand Down
Loading