From c27045f28718d85e6a86c19671186565446a550c Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Thu, 16 Nov 2023 10:32:59 +0100 Subject: [PATCH 1/9] Add after no payment action hook. --- src/Payment/MollieOrderService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Payment/MollieOrderService.php b/src/Payment/MollieOrderService.php index 277d7a4f..9ce0ba6e 100644 --- a/src/Payment/MollieOrderService.php +++ b/src/Payment/MollieOrderService.php @@ -153,6 +153,7 @@ 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; } From 5bcf8f683d733f7d780fb1242d8ff3f400f0875d Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Thu, 16 Nov 2023 14:06:12 +0100 Subject: [PATCH 2/9] Fix capture payment badge, when captured from Mollie dasboard --- src/MerchantCapture/Capture/Type/StateChangeCapture.php | 9 +++++++++ src/MerchantCapture/MerchantCaptureModule.php | 7 +++++-- src/Payment/MollieOrderService.php | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) 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( From 141374e0be1cf1bb356e5bf5c20da3e250d0c0a4 Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Wed, 22 Nov 2023 09:02:23 +0100 Subject: [PATCH 3/9] Code style --- src/MerchantCapture/Capture/Type/StateChangeCapture.php | 4 ++-- src/MerchantCapture/MerchantCaptureModule.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MerchantCapture/Capture/Type/StateChangeCapture.php b/src/MerchantCapture/Capture/Type/StateChangeCapture.php index c1a01e04..1bafca2d 100644 --- a/src/MerchantCapture/Capture/Type/StateChangeCapture.php +++ b/src/MerchantCapture/Capture/Type/StateChangeCapture.php @@ -26,8 +26,8 @@ public function __construct(ContainerInterface $container) /** 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); + add_action($pluginId . '_before_webhook_payment_action', function () { + remove_action('woocommerce_order_status_changed', [$this, "orderStatusChange"]); }); } diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index f97fba83..9c52e722 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -145,10 +145,12 @@ static function (Payment $payment, WC_Order $order) use ($container) { ManualCaptureStatus::STATUS_AUTHORIZED ); $order->save(); - } elseif ($payment->isPaid() && ( + } 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 From 8348ba16132f79c056e3742eae0dc87ccb543726 Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Wed, 22 Nov 2023 09:24:03 +0100 Subject: [PATCH 4/9] Cancel payment if cancel triggered from Mollie dashboard --- src/MerchantCapture/MerchantCaptureModule.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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, From 6677c4952241550b587d8a7c99c7986085027383 Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Wed, 20 Dec 2023 07:41:20 +0100 Subject: [PATCH 5/9] Change strings void into cancel --- src/MerchantCapture/Capture/Action/VoidPayment.php | 2 +- src/MerchantCapture/MollieCaptureSettings.php | 6 +++--- src/MerchantCapture/UI/StatusRenderer.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MerchantCapture/Capture/Action/VoidPayment.php b/src/MerchantCapture/Capture/Action/VoidPayment.php index 0ef1d152..1b19a464 100644 --- a/src/MerchantCapture/Capture/Action/VoidPayment.php +++ b/src/MerchantCapture/Capture/Action/VoidPayment.php @@ -25,7 +25,7 @@ public function __invoke() $this->logger->error($exception->getMessage()); $this->order->add_order_note( __( - 'Payment Void Failed. We encountered an issue while canceling the pre-authorized payment.', + 'Payment cancelation failed. We encountered an issue while canceling the pre-authorized payment.', 'mollie-payments-for-woocommerce' ) ); diff --git a/src/MerchantCapture/MollieCaptureSettings.php b/src/MerchantCapture/MollieCaptureSettings.php index f263c1b4..cf5b9a9a 100644 --- a/src/MerchantCapture/MollieCaptureSettings.php +++ b/src/MerchantCapture/MollieCaptureSettings.php @@ -26,7 +26,7 @@ public function settings(array $advancedSettings, string $pluginName): array 'default' => 'immediate_capture', 'desc' => sprintf( __( - 'Authorized payment can be captured or voided by changing the order status instead of doing it manually.', + 'Authorized payment can be captured or canceled by changing the order status instead of doing it manually.', 'mollie-payments-for-woocommerce' ) ), @@ -34,13 +34,13 @@ public function settings(array $advancedSettings, string $pluginName): array [ 'id' => $pluginName . '_capture_or_void', 'title' => __( - 'Capture or void on status change', + 'Capture or cancel on status change', 'mollie-payments-for-woocommerce' ), 'type' => 'checkbox', 'default' => 'no', 'desc' => __( - 'Capture authorized payments automatically when setting the order status to Processing or Completed. Void the payment by setting the order status Canceled.', + 'Capture authorized payments automatically when setting the order status to Processing or Completed. Cancel the payment by setting the order status Canceled.', 'mollie-payments-for-woocommerce' ), ], diff --git a/src/MerchantCapture/UI/StatusRenderer.php b/src/MerchantCapture/UI/StatusRenderer.php index b23f9a63..5da2f856 100644 --- a/src/MerchantCapture/UI/StatusRenderer.php +++ b/src/MerchantCapture/UI/StatusRenderer.php @@ -18,7 +18,7 @@ public function __invoke(string $molliePaymentStatus) ); } elseif ($molliePaymentStatus === ManualCaptureStatus::STATUS_VOIDED) { (new StatusButton())( - __('Payment voided', 'mollie-payments-for-woocommerce'), + __('Payment canceled', 'mollie-payments-for-woocommerce'), SharedDataDictionary::STATUS_CANCELLED ); } elseif ($molliePaymentStatus === ManualCaptureStatus::STATUS_CAPTURED) { From 8acc682354ec60774003c010ac88664aa3712ea1 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 25 Jan 2024 10:32:13 +0100 Subject: [PATCH 6/9] Enable merchant capture by default PIWOO-369 --- src/MerchantCapture/MerchantCaptureModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index 697a457f..a3177f88 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -147,7 +147,7 @@ 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)) { + if (!apply_filters('mollie_wc_gateway_enable_merchant_capture_module', true)) { return; } From f5c8c04a0e5e55146ce2d9946e50ece03ea50f15 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 25 Jan 2024 10:47:05 +0100 Subject: [PATCH 7/9] Enable klarna one by default PIWOO-370 --- src/Gateway/GatewayModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index e0a9bdb3..d73dfb51 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -105,7 +105,7 @@ public function services(): array }, 'gateway.getKlarnaPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array { $availablePaymentMethods = $container->get('gateway.listAllMethodsAvailable'); - $klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', getenv('MOL_KLARNA_ENABLED') === '1'); + $klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', true); if (!$klarnaOneFlag) { return array_filter($availablePaymentMethods, static function ($method) { return $method['id'] !== Constants::KLARNA; From a0d391aea0b228acfaa9dd5e398a3bc62ed26516 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 25 Jan 2024 10:50:47 +0100 Subject: [PATCH 8/9] Change version number --- mollie-payments-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index 7fc6a19d..94440546 100644 --- a/mollie-payments-for-woocommerce.php +++ b/mollie-payments-for-woocommerce.php @@ -3,7 +3,7 @@ * Plugin Name: Mollie Payments for WooCommerce * Plugin URI: https://www.mollie.com * Description: Accept payments in WooCommerce with the official Mollie plugin - * Version: 7.4.1 + * Version: 7.4.2-beta1 * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0 From 14ce7836c8491711490c1f9f314ff32827f793d6 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 29 Jan 2024 14:46:56 +0100 Subject: [PATCH 9/9] Update version number --- mollie-payments-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index 94440546..e5805eff 100644 --- a/mollie-payments-for-woocommerce.php +++ b/mollie-payments-for-woocommerce.php @@ -3,7 +3,7 @@ * Plugin Name: Mollie Payments for WooCommerce * Plugin URI: https://www.mollie.com * Description: Accept payments in WooCommerce with the official Mollie plugin - * Version: 7.4.2-beta1 + * Version: 7.5.0-beta1 * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0