diff --git a/src/MerchantCapture/Capture/Type/StateChangeCapture.php b/src/MerchantCapture/Capture/Type/StateChangeCapture.php index 9e9ec3e8..c1a01e04 100644 --- a/src/MerchantCapture/Capture/Type/StateChangeCapture.php +++ b/src/MerchantCapture/Capture/Type/StateChangeCapture.php @@ -19,7 +19,16 @@ class StateChangeCapture public function __construct(ContainerInterface $container) { $this->container = $container; + $pluginId = $container->get('shared.plugin_id'); + add_action('woocommerce_order_status_changed', [$this, "orderStatusChange"], 10, 3); + + /** When the webhook process is activated we don't need automatic status change. Status change is handled + * by the webhook logic. + */ + add_action($pluginId . '_before_webhook_payment_action', function(){ + remove_action('woocommerce_order_status_changed', [$this, "orderStatusChange"], 10, 3); + }); } public function orderStatusChange(int $orderId, string $oldStatus, string $newStatus) diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index 9232061c..f97fba83 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -145,7 +145,10 @@ static function (Payment $payment, WC_Order $order) use ($container) { ManualCaptureStatus::STATUS_AUTHORIZED ); $order->save(); - } elseif ($payment->isPaid() && ($container->get('merchant.manual_capture.is_waiting'))($order)) { + } elseif ($payment->isPaid() && ( + ($container->get('merchant.manual_capture.is_waiting'))($order) || + ($container->get('merchant.manual_capture.is_authorized'))($order) + )) { $order->update_meta_data( self::ORDER_PAYMENT_STATUS_META_KEY, ManualCaptureStatus::STATUS_CAPTURED @@ -198,7 +201,7 @@ static function ($disableShipAndCapture, WC_Order $order) use ($container) { if ($disableShipAndCapture) { return true; } - return $container->get('merchant.manual_capture.is_waiting')($order); + return $container->get('merchant.manual_capture.is_waiting')($order) || $container->get('merchant.manual_capture.is_authorized')($order); }, 10, 2 diff --git a/src/Payment/MollieOrderService.php b/src/Payment/MollieOrderService.php index 9ce0ba6e..a5f5cfec 100644 --- a/src/Payment/MollieOrderService.php +++ b/src/Payment/MollieOrderService.php @@ -153,7 +153,6 @@ public function onWebhookAction() if ($order->get_status() === 'processing' && $payment->isCompleted() && method_exists($payment_object, 'onWebhookCompleted')) { $payment_object->onWebhookCompleted($order, $payment, $payment_method_title); } - do_action($this->pluginId . '_after_webhook_no_payment_action', $payment, $order); return; } @@ -163,6 +162,7 @@ public function onWebhookAction() } if (method_exists($payment_object, $method_name)) { + do_action($this->pluginId . '_before_webhook_payment_action', $payment, $order); $payment_object->{$method_name}($order, $payment, $payment_method_title); } else { $order->add_order_note(sprintf(