diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index 9c52e722..b1a7231f 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -135,6 +135,7 @@ public function run(ContainerInterface $container): bool add_action( $pluginId . '_after_webhook_action', static function (Payment $payment, WC_Order $order) use ($container) { + if ($payment->isAuthorized()) { if (!$payment->getAmountCaptured() == 0.0) { return; @@ -156,6 +157,17 @@ static function (Payment $payment, WC_Order $order) use ($container) { ManualCaptureStatus::STATUS_CAPTURED ); $order->save(); + } elseif ( + $payment->isCanceled() && ( + ($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_VOIDED + ); + $order->save(); } }, 10,