Skip to content

Commit 8a0b031

Browse files
authored
[ECP-9827] Fix webhook test response object (#3111)
1 parent 56bd303 commit 8a0b031

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Controller/Adminhtml/Configuration/WebhookTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Adyen\Payment\Controller\Adminhtml\Configuration;
1313

1414
use Adyen\AdyenException;
15+
use Adyen\Model\Management\TestWebhookResponse;
1516
use Adyen\Payment\Helper\Config;
1617
use Adyen\Payment\Helper\ManagementHelper;
1718
use Magento\Backend\App\Action;
@@ -87,9 +88,19 @@ public function execute(): Json
8788

8889
$client = $this->managementApiHelper->getAdyenApiClient($apiKey, $isDemoMode);
8990
$service =$this->managementApiHelper->getWebhooksMerchantLevelApi($client);
90-
$response = $this->managementApiHelper->webhookTest($merchantAccount, $webhookId, $service);
91-
$success = isset($response) &&
92-
in_array('success', array_column($response->getData(), 'status'), true);
91+
92+
$responseObj = $this->managementApiHelper->webhookTest($merchantAccount, $webhookId, $service);
93+
94+
$success = false;
95+
$response = null;
96+
97+
if ($responseObj instanceof TestWebhookResponse) {
98+
$responseData = $responseObj->getData();
99+
$responseData = reset($responseData);
100+
$response = $responseData->toArray();
101+
102+
$success = $response['status'] === 'success';
103+
}
93104

94105
$resultJson = $this->resultJsonFactory->create();
95106
$resultJson->setData([

0 commit comments

Comments
 (0)