Skip to content

Commit fcfbbca

Browse files
authored
[ECP-9894] Remove capture mode check from the handler (#3239)
1 parent c834274 commit fcfbbca

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

Helper/Webhook/ExpireWebhookHandler.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Adyen\Payment\Helper\Data;
1818
use Adyen\Payment\Helper\Order as OrderHelper;
1919
use Adyen\Payment\Logger\AdyenLogger;
20-
use Adyen\Payment\Model\Config\Source\CaptureMode;
2120
use Adyen\Payment\Model\Notification;
2221
use Magento\Framework\Exception\LocalizedException;
2322
use Magento\Sales\Model\Order;
@@ -50,19 +49,8 @@ public function handleWebhook(Order $order, Notification $notification, string $
5049
{
5150
$storeId = $order->getStoreId();
5251
$isExpireWebhookIgnored = $this->configHelper->isExpireWebhookIgnored($storeId);
53-
$captureMode = $this->configHelper->getCaptureMode($storeId);
5452

55-
if (strcmp($captureMode, CaptureMode::CAPTURE_MODE_AUTO) === 0) {
56-
/*
57-
* Expire webhook should not be obtained if auto capture is enabled.
58-
* If so, it might be an indicator of an incorrect plugin configuration.
59-
*/
60-
$orderComment = __(
61-
'An unexpected %1 webhook has arrived even though auto capture is enabled, please check the plugin configuration! This webhook was skipped.',
62-
$notification->getEventCode()
63-
);
64-
$logMessage = $orderComment;
65-
} elseif ($isExpireWebhookIgnored) {
53+
if ($isExpireWebhookIgnored) {
6654
$orderComment = __(
6755
'The remaining uncaptured authorisation with amount %1 has expired but no action has been taken as the %2 webhook was skipped.',
6856
$notification->getFormattedAmountCurrency(),

Test/Unit/Helper/Webhook/ExpireWebhookHandlerTest.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Adyen\Payment\Helper\Webhook\ExpireWebhookHandler;
1818
use Adyen\Payment\Logger\AdyenLogger;
1919
use Adyen\Payment\Model\AdyenAmountCurrency;
20-
use Adyen\Payment\Model\Config\Source\CaptureMode;
2120
use Adyen\Payment\Model\Notification;
2221
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
2322
use Magento\Sales\Api\Data\OrderInterface;
@@ -65,31 +64,8 @@ protected function tearDown(): void
6564
$this->webhookHandler = null;
6665
}
6766

68-
public function testAutoCaptureEnabled(): void
69-
{
70-
$this->configMock->expects($this->once())
71-
->method('getCaptureMode')
72-
->willReturn(CaptureMode::CAPTURE_MODE_AUTO);
73-
74-
$this->adyenLoggerMock->expects($this->once())->method('addAdyenNotification');
75-
$this->orderMock->expects($this->once())->method('addCommentToStatusHistory');
76-
$this->orderHelperMock->expects($this->never())->method('holdCancelOrder');
77-
78-
$result = $this->webhookHandler->handleWebhook(
79-
$this->orderMock,
80-
$this->notificationMock,
81-
'pending'
82-
);
83-
84-
$this->assertInstanceOf(OrderInterface::class, $result);
85-
}
86-
8767
public function testExpireWebhookIgnored()
8868
{
89-
$this->configMock->expects($this->once())
90-
->method('getCaptureMode')
91-
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);
92-
9369
$this->configMock->expects($this->once())
9470
->method('isExpireWebhookIgnored')
9571
->willReturn(true);
@@ -109,10 +85,6 @@ public function testExpireWebhookIgnored()
10985

11086
public function testHandleWebhookWithPartialExpiration()
11187
{
112-
$this->configMock->expects($this->once())
113-
->method('getCaptureMode')
114-
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);
115-
11688
$this->configMock->expects($this->once())
11789
->method('isExpireWebhookIgnored')
11890
->willReturn(false);
@@ -142,10 +114,6 @@ public function testHandleWebhookWithPartialExpiration()
142114

143115
public function testHandleWebhookWithShipments()
144116
{
145-
$this->configMock->expects($this->once())
146-
->method('getCaptureMode')
147-
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);
148-
149117
$this->configMock->expects($this->once())
150118
->method('isExpireWebhookIgnored')
151119
->willReturn(false);
@@ -176,10 +144,6 @@ public function testHandleWebhookWithShipments()
176144

177145
public function testHandleWebhookSuccessfully()
178146
{
179-
$this->configMock->expects($this->once())
180-
->method('getCaptureMode')
181-
->willReturn(CaptureMode::CAPTURE_MODE_MANUAL);
182-
183147
$this->configMock->expects($this->once())
184148
->method('isExpireWebhookIgnored')
185149
->willReturn(false);

0 commit comments

Comments
 (0)