diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 841e1a1a6..68772eef6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - php-version: [8.1] + php-version: [8.2,8.3] steps: - uses: actions/checkout@v3 diff --git a/Helper/PaymentResponseHandler.php b/Helper/PaymentResponseHandler.php index fe8cec13f..6c11537a9 100644 --- a/Helper/PaymentResponseHandler.php +++ b/Helper/PaymentResponseHandler.php @@ -275,17 +275,20 @@ public function handlePaymentsDetailsResponse( case self::CANCELLED: // Cancel order in case result is refused if (null !== $order) { - // Set order to new so it can be cancelled - $order->setState(\Magento\Sales\Model\Order::STATE_NEW); - $order->save(); - $order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, true); - $this->dataHelper->cancelOrder($order); + // Check if the current state allows for changing to new for cancellation + if ($order->canCancel()) { + // Proceed to set cancellation action flag and cancel the order + $order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, true); + $this->dataHelper->cancelOrder($order); + } else { + $this->adyenLogger->addAdyenResult('The order cannot be cancelled'); + } } $result = false; break; default: $this->adyenLogger->error( - sprintf("Payment details call failed for action, resultCode is %s Raw API responds: %s. + sprintf("Payment details call failed for action, resultCode is %s Raw API responds: %s. Cancel or Hold the order on OFFER_CLOSED notification.", $paymentsDetailsResponse['resultCode'], json_encode($paymentsDetailsResponse) diff --git a/Helper/Webhook/WebhookHandlerFactory.php b/Helper/Webhook/WebhookHandlerFactory.php index edb815b47..2bc9d6dd5 100644 --- a/Helper/Webhook/WebhookHandlerFactory.php +++ b/Helper/Webhook/WebhookHandlerFactory.php @@ -35,6 +35,8 @@ class WebhookHandlerFactory private ChargebackWebhookHandler $chargebackWebhookHandler; private ChargebackReversedWebhookHandler $chargebackReversedWebhookHandler; private NotificationOfChargebackWebhookHandler $notificationOfChargebackWebhookHandler; + private RequestForInformationWebhookHandler $requestForInformationWebhookHandler; + private SecondChargebackWebhookHandler $secondChargebackWebhookHandler; public function __construct( diff --git a/Test/Unit/Model/Sales/OrderRepositoryTest.php b/Test/Unit/Model/Sales/OrderRepositoryTest.php index c0b0fb133..261640f06 100644 --- a/Test/Unit/Model/Sales/OrderRepositoryTest.php +++ b/Test/Unit/Model/Sales/OrderRepositoryTest.php @@ -13,22 +13,15 @@ use Adyen\Payment\Model\Sales\OrderRepository; use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; -use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; use Magento\Framework\Api\Filter; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\Search\FilterGroup; use Magento\Framework\Api\Search\FilterGroupBuilder; use Magento\Framework\Api\SearchCriteria; -use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; use Magento\Framework\Api\SearchCriteriaBuilder; -use Magento\Framework\Serialize\Serializer\Json as JsonSerializer; -use Magento\Payment\Api\Data\PaymentAdditionalInfoInterfaceFactory; -use Magento\Sales\Api\Data\OrderExtensionFactory; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\Data\OrderSearchResultInterface; -use Magento\Sales\Api\Data\OrderSearchResultInterfaceFactory as SearchResultFactory; -use Magento\Sales\Model\ResourceModel\Metadata; -use Magento\Tax\Api\OrderTaxManagementInterface; +use ReflectionClass; class OrderRepositoryTest extends AbstractAdyenTestCase { @@ -61,15 +54,7 @@ public function testGetOrderByQuoteId() public function buildOrderRepositoryClass( $searchCriteriaBuilderMock = null, $filterBuilderMock = null, - $filterGroupBuilderMock = null, - $metadataMock = null, - $searchResultFactoryMock = null, - $collectionProcessorMock = null, - $orderExtensionFactoryMock = null, - $orderTaxManagementMock = null, - $paymentAdditionalInfoFactoryMock = null, - $serializerMock = null, - $extensionAttributesJoinProcessorMock = null + $filterGroupBuilderMock = null ): OrderRepository { if (is_null($searchCriteriaBuilderMock)) { $searchCriteriaBuilderMock = $this->createMock(SearchCriteriaBuilder::class); @@ -83,54 +68,24 @@ public function buildOrderRepositoryClass( $filterGroupBuilderMock = $this->createMock(FilterGroupBuilder::class); } - if (is_null($metadataMock)) { - $metadataMock = $this->createMock(Metadata::class); - } - - if (is_null($searchResultFactoryMock)) { - $searchResultFactoryMock = $this->createGeneratedMock(SearchResultFactory::class); - } - - if (is_null($collectionProcessorMock)) { - $collectionProcessorMock = $this->createMock(CollectionProcessorInterface::class); - } - - if (is_null($orderExtensionFactoryMock)) { - $orderExtensionFactoryMock = $this->createGeneratedMock(OrderExtensionFactory::class); - } - - if (is_null($orderTaxManagementMock)) { - $orderTaxManagementMock = $this->createMock(OrderTaxManagementInterface::class); - } + $orderRepositoryPartialMock = $this->getMockBuilder(OrderRepository::class) + ->setMethods(['getList']) + ->disableOriginalConstructor() + ->getMock(); - if (is_null($paymentAdditionalInfoFactoryMock)) { - $paymentAdditionalInfoFactoryMock = $this->createGeneratedMock(PaymentAdditionalInfoInterfaceFactory::class); - } + $reflection = new ReflectionClass(OrderRepository::class); - if (is_null($serializerMock)) { - $serializerMock = $this->createMock(JsonSerializer::class); - } + $searchCriteriaBuilderProperty = $reflection->getProperty('searchCriteriaBuilder'); + $searchCriteriaBuilderProperty->setAccessible(true); + $searchCriteriaBuilderProperty->setValue($orderRepositoryPartialMock, $searchCriteriaBuilderMock); - if (is_null($extensionAttributesJoinProcessorMock)) { - $extensionAttributesJoinProcessorMock = $this->createMock(JoinProcessorInterface::class); - } + $filterBuilderProperty = $reflection->getProperty('filterBuilder'); + $filterBuilderProperty->setAccessible(true); + $filterBuilderProperty->setValue($orderRepositoryPartialMock, $filterBuilderMock); - $orderRepositoryPartialMock = $this->getMockBuilder(OrderRepository::class) - ->setMethods(['getList']) - ->setConstructorArgs([ - $searchCriteriaBuilderMock, - $filterBuilderMock, - $filterGroupBuilderMock, - $metadataMock, - $searchResultFactoryMock, - $collectionProcessorMock, - $orderExtensionFactoryMock, - $orderTaxManagementMock, - $paymentAdditionalInfoFactoryMock, - $serializerMock, - $extensionAttributesJoinProcessorMock - ]) - ->getMock(); + $filterGroupBuilderProperty = $reflection->getProperty('filterGroupBuilder'); + $filterGroupBuilderProperty->setAccessible(true); + $filterGroupBuilderProperty->setValue($orderRepositoryPartialMock, $filterGroupBuilderMock); $orderSearchResultMock = $this->createConfiguredMock(OrderSearchResultInterface::class, [ 'getItems' => [$this->createMock(OrderInterface::class)] diff --git a/composer.json b/composer.json index fb3c9fabd..c252da230 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "adyen/module-payment", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "type": "magento2-module", - "version": "9.5.0", + "version": "9.5.1", "license": "MIT", "repositories": [ { diff --git a/view/frontend/templates/checkout/multishipping/billing.phtml b/view/frontend/templates/checkout/multishipping/billing.phtml index c82648ada..b3ab2b9a2 100644 --- a/view/frontend/templates/checkout/multishipping/billing.phtml +++ b/view/frontend/templates/checkout/multishipping/billing.phtml @@ -106,11 +106,7 @@ data-bind=" value: getCode(), checked: isChecked, - click: selectPaymentMethod, visible: isRadioButtonVisible()" - - checked="checked" - class="radio"/> diff --git a/view/frontend/web/template/payment/multishipping/cc-form.html b/view/frontend/web/template/payment/multishipping/cc-form.html index 7461f667d..6f0ca3970 100644 --- a/view/frontend/web/template/payment/multishipping/cc-form.html +++ b/view/frontend/web/template/payment/multishipping/cc-form.html @@ -1 +1,4 @@ -
+