diff --git a/src/Components/OrderExpiration/ExpireAction.php b/src/Components/OrderExpiration/ExpireAction.php index 7537a2ae3..114cc1f40 100644 --- a/src/Components/OrderExpiration/ExpireAction.php +++ b/src/Components/OrderExpiration/ExpireAction.php @@ -34,7 +34,8 @@ public function __construct( OrderExpireService $orderExpireService, SettingsService $settingsService, LoggerInterface $logger - ) { + ) + { $this->orderRepository = $orderRepository; $this->salesChannelRepository = $salesChannelRepository; $this->orderExpireService = $orderExpireService; @@ -78,13 +79,18 @@ private function expireOrdersInSalesChannel(SalesChannelEntity $salesChannelEnti $date = new \DateTime(); $date->modify(sprintf('-%d days', (BankTransferPayment::DUE_DATE_MAX_DAYS + 1))); + + $orFilterArray = [ + new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_IN_PROGRESS), + ]; + if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) { + $orFilterArray[] = new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_UNCONFIRMED); + } $criteria = new Criteria(); $criteria->addAssociation('transactions.stateMachineState'); $criteria->addAssociation('transactions.paymentMethod'); - $criteria->addFilter(new OrFilter([ - new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_IN_PROGRESS), - new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_UNCONFIRMED) - ])); + + $criteria->addFilter(new OrFilter($orFilterArray)); $criteria->addFilter(new EqualsFilter('salesChannelId', $salesChannelEntity->getId())); $criteria->addFilter(new RangeFilter('orderDateTime', [RangeFilter::GTE => $date->format(Defaults::STORAGE_DATE_TIME_FORMAT)])); diff --git a/src/Service/Order/OrderStatusUpdater.php b/src/Service/Order/OrderStatusUpdater.php index 4fd1ba7cb..63988f676 100644 --- a/src/Service/Order/OrderStatusUpdater.php +++ b/src/Service/Order/OrderStatusUpdater.php @@ -100,9 +100,13 @@ public function updatePaymentStatus(OrderTransactionEntity $transaction, string switch ($targetShopwareStatusKey) { case MolliePaymentStatus::MOLLIE_PAYMENT_OPEN: { + $states = [OrderTransactionStates::STATE_IN_PROGRESS]; + if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) { + $states[] = OrderTransactionStates::STATE_UNCONFIRMED; + } # if we are already in_progress...then don't switch to OPEN again # otherwise SEPA bank transfer would switch back to OPEN - if (! in_array($currentShopwareStatusKey, [OrderTransactionStates::STATE_IN_PROGRESS, OrderTransactionStates::STATE_UNCONFIRMED]) || $context->hasState(self::ORDER_STATE_FORCE_OPEN)) { + if (! in_array($currentShopwareStatusKey, $states) || $context->hasState(self::ORDER_STATE_FORCE_OPEN)) { $addLog = true; $this->transactionTransitionService->reOpenTransaction($transaction, $context); } diff --git a/src/Service/Transition/TransactionTransitionService.php b/src/Service/Transition/TransactionTransitionService.php index cbac5cb4e..b9febed4b 100644 --- a/src/Service/Transition/TransactionTransitionService.php +++ b/src/Service/Transition/TransactionTransitionService.php @@ -11,6 +11,7 @@ use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity; use Shopware\Core\System\StateMachine\Aggregation\StateMachineTransition\StateMachineTransitionActions; + class TransactionTransitionService implements TransactionTransitionServiceInterface { /** @@ -46,19 +47,26 @@ public function __construct( public function processTransaction(OrderTransactionEntity $transaction, Context $context): void { $technicalName = ($transaction->getStateMachineState() instanceof StateMachineStateEntity) ? $transaction->getStateMachineState()->getTechnicalName() : ''; + $defaultState = OrderTransactionStates::STATE_IN_PROGRESS; + $action = StateMachineTransitionActions::ACTION_PROCESS; + + if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) { + $defaultState = OrderTransactionStates::STATE_UNCONFIRMED; + $action = StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED; + } - if ($this->isFinalOrTargetStatus($technicalName, [OrderTransactionStates::STATE_UNCONFIRMED])) { + if ($this->isFinalOrTargetStatus($technicalName, [$defaultState])) { return; } $entityId = $transaction->getId(); $availableTransitions = $this->getAvailableTransitions($entityId, $context); - if (!$this->transitionIsAllowed(StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED, $availableTransitions)) { + if (!$this->transitionIsAllowed($action, $availableTransitions)) { $this->reOpenTransaction($transaction, $context); } - $this->performTransition($entityId, StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED, $context); + $this->performTransition($entityId, $action, $context); } public function reOpenTransaction(OrderTransactionEntity $transaction, Context $context): void diff --git a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-states.cy.js b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-states.cy.js index 308060f4a..0177642cb 100644 --- a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-states.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-states.cy.js @@ -47,7 +47,7 @@ context("Order Status Mapping Tests", () => { context(devices.getDescription(device), () => { - it('C4028: Test Status Open stays In-Progress', () => { + it('C4028: Test Status Open stays Unconfirmed/In progress', () => { // we create a SEPA bank transfer payment // the payment status will be IN PROGRESS then in Shopware. @@ -66,7 +66,13 @@ context("Order Status Mapping Tests", () => { adminLogin.login(); adminOrders.assertLatestOrderStatus('Open'); - adminOrders.assertLatestPaymentStatus('In Progress'); + if (shopware.isVersionLower('6.4.4.0')) { + adminOrders.assertLatestPaymentStatus('In Progress'); + }else{ + adminOrders.assertLatestPaymentStatus('Unconfirmed'); + } + + }) it('C4023: Test Status Paid', () => {