diff --git a/Helper/Webhook.php b/Helper/Webhook.php index ce8c3009c..39f74c54e 100644 --- a/Helper/Webhook.php +++ b/Helper/Webhook.php @@ -421,7 +421,9 @@ private function updateAdyenAttributes(Order $order, Notification $notification) * the previous notification was authorisation : true do not update pspreference */ if (!$notification->isSuccessful()) { - $previousAdyenEventCode = $order->getData('adyen_notification_event_code'); + $previousAdyenEventCode = $this->orderRepository + ->get($order->getId()) + ->getData('adyen_notification_event_code'); if ($previousAdyenEventCode != "AUTHORISATION : TRUE") { $this->updateOrderPaymentWithAdyenAttributes($order->getPayment(), $notification, $additionalData); } diff --git a/Test/Unit/Helper/WebhookTest.php b/Test/Unit/Helper/WebhookTest.php index 3d818df85..b94d27f3a 100644 --- a/Test/Unit/Helper/WebhookTest.php +++ b/Test/Unit/Helper/WebhookTest.php @@ -2,7 +2,6 @@ namespace Adyen\Payment\Test\Unit\Helper; use Adyen\Payment\Helper\Webhook; -use Adyen\Payment\Helper\Webhook\AuthorisationWebhookHandler; use Adyen\Payment\Helper\Webhook\WebhookHandlerInterface; use Adyen\Payment\Model\Notification; use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; @@ -19,7 +18,6 @@ use Adyen\Payment\Helper\Webhook\WebhookHandlerFactory; use Adyen\Payment\Logger\AdyenLogger; use ReflectionMethod; -use ReflectionClass; class WebhookTest extends AbstractAdyenTestCase { @@ -190,6 +188,7 @@ public function testUpdateAdyenAttributes() $orderMock = $this->getMockBuilder(Order::class) ->disableOriginalConstructor() ->getMock(); + $orderMock->method('getData')->willReturnSelf(); $paymentMock = $this->getMockBuilder(Payment::class) ->disableOriginalConstructor() @@ -203,8 +202,21 @@ public function testUpdateAdyenAttributes() ->disableOriginalConstructor() ->getMock(); + $orderRepositoryMock = $this->createMock(OrderRepository::class); + $orderRepositoryMock->method('get')->willReturn($orderMock); + // Create an instance of your class - $webhook = $this->createWebhook(null, $serializerMock, null, null, null, $loggerMock, null, null, null); + $webhook = $this->createWebhook( + null, + $serializerMock, + null, + null, + null, + $loggerMock, + null, + null, + $orderRepositoryMock + ); // Set up expectations for the mocked objects $notificationMock->expects($this->once())