diff --git a/Observer/SetOrderStatusAfterInvoice.php b/Observer/SetOrderStatusAfterInvoice.php index 7a1af86..a836d23 100644 --- a/Observer/SetOrderStatusAfterInvoice.php +++ b/Observer/SetOrderStatusAfterInvoice.php @@ -43,7 +43,7 @@ public function execute(Observer $observer): void $invoice = $observer->getInvoice(); if ($order->getData('monei_payment_id') !== null && $invoice->getIsPaid() === true) { $orderStatus = Monei::STATUS_MONEI_SUCCEDED; - $orderState = Order::STATE_NEW; + $orderState = Order::STATE_PROCESSING; $order->setStatus($orderStatus)->setState($orderState); $this->orderRepository->save($order); } diff --git a/Service/SetOrderStatusAndState.php b/Service/SetOrderStatusAndState.php index 99da465..2c41d17 100644 --- a/Service/SetOrderStatusAndState.php +++ b/Service/SetOrderStatusAndState.php @@ -74,7 +74,7 @@ public function execute(array $data): bool break; case Monei::ORDER_STATUS_SUCCEEDED: $orderStatus = Monei::STATUS_MONEI_SUCCEDED; - $orderState = Order::STATE_NEW; + $orderState = Order::STATE_PROCESSING; break; case Monei::ORDER_STATUS_PARTIALLY_REFUNDED: $orderStatus = Monei::STATUS_MONEI_PARTIALLY_REFUNDED; diff --git a/Setup/Patch/Data/SetupSales.php b/Setup/Patch/Data/SetupSales.php index 9dc993c..1b30bb1 100644 --- a/Setup/Patch/Data/SetupSales.php +++ b/Setup/Patch/Data/SetupSales.php @@ -6,7 +6,6 @@ use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; - use Magento\Sales\Model\Order; use Monei\MoneiPayment\Model\Payment\Monei; use Magento\Sales\Setup\SalesSetup; @@ -52,7 +51,7 @@ public function getAliases(): array */ public static function getVersion(): string { - return '1.2.0'; + return '1.1.4'; } public function apply(): void @@ -77,7 +76,7 @@ public function apply(): void $statuses = [ Monei::STATUS_MONEI_PENDING => __('Monei - pending'), - Monei::STATUS_MONEI_AUTHORIZED => __('Monei - Preauthorized'), + Monei::STATUS_MONEI_AUTHORIZED => __('Monei - pre-authorized'), Monei::STATUS_MONEI_EXPIRED => __('Monei - expired'), Monei::STATUS_MONEI_FAILED => __('Monei - failed'), Monei::STATUS_MONEI_SUCCEDED => __('Monei - succeeded'), @@ -87,31 +86,29 @@ public function apply(): void foreach ($statuses as $code => $info) { $data[] = ['status' => $code, 'label' => $info]; } - $this->moduleDataSetup->getConnection()->insertOnDuplicate( + $this->moduleDataSetup->getConnection()->insertArray( $this->moduleDataSetup->getTable('sales_order_status'), - $data, - ['status', 'label'] + ['status', 'label'], + $data ); $data = []; $statuses = [ - Order::STATE_PENDING_PAYMENT => [ + 'pending_payment' => [ Monei::STATUS_MONEI_PENDING => false, Monei::STATUS_MONEI_AUTHORIZED => false, ], - Order::STATE_CANCELED => [ + 'canceled' => [ Monei::STATUS_MONEI_EXPIRED => false, Monei::STATUS_MONEI_FAILED => false, ], - Order::STATE_PROCESSING => [ + 'processing' => [ + Monei::STATUS_MONEI_SUCCEDED => false, Monei::STATUS_MONEI_PARTIALLY_REFUNDED => false, ], - Order::STATE_COMPLETE => [ + 'complete' => [ Monei::STATUS_MONEI_REFUNDED => false, ], - Order::STATE_NEW => [ - Monei::STATUS_MONEI_SUCCEDED => false, - ] ]; foreach ($statuses as $stateCode => $status) { @@ -121,17 +118,13 @@ public function apply(): void 'state' => $stateCode, 'is_default' => $isDefault, ]; - $this->moduleDataSetup->getConnection()->delete( - $this->moduleDataSetup->getTable('sales_order_status_state'), - ["state" => $stateCode] - ); } } - $this->moduleDataSetup->getConnection()->insertOnDuplicate( + $this->moduleDataSetup->getConnection()->insertArray( $this->moduleDataSetup->getTable('sales_order_status_state'), - $data, - ['status', 'state', 'is_default'] + ['status', 'state', 'is_default'], + $data ); $this->moduleDataSetup->getConnection()->endSetup(); diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index d09299c..c9e956e 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -79,7 +79,7 @@ - Magento\Sales\Model\Config\Source\Order\Status\NewStatus + Magento\Sales\Model\Config\Source\Order\Status\Processing Selectable with all the processing order statuses 1 diff --git a/etc/module.xml b/etc/module.xml index d6e3c54..de08c0c 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -4,7 +4,7 @@ ~ @copyright Copyright © Monei (https://monei.com) --> - +