Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/PIWOO-362' into release/7.4.…
Browse files Browse the repository at this point in the history
…2-beta

# Conflicts:
#	src/MerchantCapture/MerchantCaptureModule.php
  • Loading branch information
mmaymo committed Jan 18, 2024
2 parents 5314834 + b323b67 commit d33d2d7
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions src/MerchantCapture/MerchantCaptureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,38 +144,29 @@ public function services(): array

public function run(ContainerInterface $container): bool
{
add_action('init', static function () use ($container) {
$pluginId = $container->get('shared.plugin_id');
$captureSettings = new MollieCaptureSettings();

if (!apply_filters('mollie_wc_gateway_enable_merchant_capture_module', false)) {
return;
}

add_action(
$pluginId . '_after_webhook_action',
static function (Payment $payment, WC_Order $order) use ($container) {
if ($payment->isAuthorized()) {
if (!$payment->getAmountCaptured() == 0.0) {
return;
}
$order->set_status(SharedDataDictionary::STATUS_ON_HOLD);
$order->update_meta_data(
self::ORDER_PAYMENT_STATUS_META_KEY,
ManualCaptureStatus::STATUS_AUTHORIZED
);
$order->save();
} elseif ($payment->isPaid() && ($container->get('merchant.manual_capture.is_waiting'))($order)) {
$order->update_meta_data(
self::ORDER_PAYMENT_STATUS_META_KEY,
ManualCaptureStatus::STATUS_CAPTURED
);
$order->save();
$pluginId = $container->get('shared.plugin_id');
$captureSettings = new MollieCaptureSettings();
add_action(
/**
* @throws \WC_Data_Exception
*/ $pluginId . '_after_webhook_action',
static function (Payment $payment, WC_Order $order) use ($container) {
if ($payment->isAuthorized()) {
if (!$payment->getAmountCaptured() == 0.0) {
return;
}
},
10,
2
);
$order->set_status(SharedDataDictionary::STATUS_ON_HOLD);
$order->update_meta_data(self::ORDER_PAYMENT_STATUS_META_KEY, ManualCaptureStatus::STATUS_AUTHORIZED);
$order->set_transaction_id($payment->id);
$order->save();
} elseif ($payment->isPaid() && ($container->get('merchant.manual_capture.is_waiting'))($order)) {
$order->update_meta_data(self::ORDER_PAYMENT_STATUS_META_KEY, ManualCaptureStatus::STATUS_CAPTURED);
$order->save();
}
},
10,
2
);

add_action('woocommerce_order_refunded', static function (int $orderId) use ($container) {
$order = wc_get_order($orderId);
Expand Down Expand Up @@ -232,8 +223,6 @@ static function ($disableShipAndCapture, WC_Order $order) use ($container) {
new OrderListPaymentColumn();
new ManualCapture($container);
new StateChangeCapture($container);
});

return true;
}
}

0 comments on commit d33d2d7

Please sign in to comment.