Skip to content

Commit

Permalink
Moved checking inside of actions so that settings are working
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuesken committed Jan 29, 2025
1 parent 83566e7 commit 7051687
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/MerchantCapture/MerchantCaptureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,16 @@ public function run(ContainerInterface $container): bool
if (!apply_filters('mollie_wc_gateway_enable_merchant_capture_module', true)) {
return;
}
if (!$container->get('merchant.manual_capture.enabled')) {
return;
}

add_action(
$pluginId . '_after_webhook_action',
static function ($payment, WC_Order $order) use ($container) {

if (!$payment instanceof Payment) {
if (!$container->get('merchant.manual_capture.enabled') || !in_array($order->get_payment_method(), $container->get('merchant.manual_capture.supported_methods'), true)) {
return;
}

if (!in_array($order->get_payment_method(), $container->get('merchant.manual_capture.supported_methods'), true)) {
if (!$payment instanceof Payment) {
return;
}

Expand Down Expand Up @@ -210,6 +207,9 @@ static function ($payment, WC_Order $order) use ($container) {
if (!is_a($order, WC_Order::class)) {
return;
}
if (!$container->get('merchant.manual_capture.enabled') || !in_array($order->get_payment_method(), $container->get('merchant.manual_capture.supported_methods'), true)) {
return;
}
$merchantCanCapture = ($container->get('merchant.manual_capture.is_authorized'))($order);
if ($merchantCanCapture) {
($container->get(VoidPayment::class))($order->get_id());
Expand All @@ -220,6 +220,9 @@ static function ($payment, WC_Order $order) use ($container) {
if (!is_a($order, WC_Order::class)) {
return;
}
if (!$container->get('merchant.manual_capture.enabled') || !in_array($order->get_payment_method(), $container->get('merchant.manual_capture.supported_methods'), true)) {
return;
}
$paymentStatus = $order->get_meta(MerchantCaptureModule::ORDER_PAYMENT_STATUS_META_KEY, true);
$actionBlockParagraphs = [];

Expand Down

0 comments on commit 7051687

Please sign in to comment.