From ae5b39cf01551159a0eb900b19a0a470259ff2cf Mon Sep 17 00:00:00 2001 From: Philip <17368112+vHeemstra@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:20:26 +0200 Subject: [PATCH 01/30] Fix deprecated expression in WcPsrLoggerAdapter Fix #803 --- src/Log/WcPsrLoggerAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Log/WcPsrLoggerAdapter.php b/src/Log/WcPsrLoggerAdapter.php index ce9ca3f1b..781a872fc 100644 --- a/src/Log/WcPsrLoggerAdapter.php +++ b/src/Log/WcPsrLoggerAdapter.php @@ -80,7 +80,7 @@ public function log($level, $message, array $context = []) } if (\WC_Log_Levels::get_level_severity($wcLevel) < \WC_Log_Levels::get_level_severity($this->loggingLevel)) { - throw new InvalidArgumentException("Unknown log level ${$wcLevel}"); + throw new InvalidArgumentException("Unknown log level {$wcLevel}"); } if (isset($context['source']) && $context['source'] !== $this-> loggerSource) { From 2cd2b2aa8e161c979e075adf132f8081a5af761b Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 7 Nov 2023 08:20:28 +0100 Subject: [PATCH 02/30] Undefined shipping id fix --- src/Buttons/ApplePayButton/AppleAjaxRequests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Buttons/ApplePayButton/AppleAjaxRequests.php b/src/Buttons/ApplePayButton/AppleAjaxRequests.php index ef8d2d603..6643cffe1 100644 --- a/src/Buttons/ApplePayButton/AppleAjaxRequests.php +++ b/src/Buttons/ApplePayButton/AppleAjaxRequests.php @@ -568,7 +568,7 @@ protected function calculateTotalsCartPage( $cart, $customerAddress, $shippingMethodId, - $shippingMethodId['identifier'] + $shippingMethodId['identifier'] ?? null ); } $cart->calculate_shipping(); From b9e8a3c1eee2736ee018807cca756a8d695bc5e8 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 9 Jan 2024 11:48:23 +0100 Subject: [PATCH 03/30] Change folder name in action --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6db1c4ce..fa82c84b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,4 +14,4 @@ jobs: PLUGIN_MAIN_FILE: mollie-payments-for-woocommerce.php ARCHIVE_NAME: mollie-payments-for-woocommerce PRE_SCRIPT: | - echo 'hello world!'; + cd .. && mv WooCommerce mollie-payments-for-woocommerce && cd mollie-payments-for-woocommerce From 178dced515cdf59162c8d31e7680c4c4599d12a2 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 9 Jan 2024 12:01:08 +0100 Subject: [PATCH 04/30] Add command to debug --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa82c84b9..a3872342c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,4 +14,6 @@ jobs: PLUGIN_MAIN_FILE: mollie-payments-for-woocommerce.php ARCHIVE_NAME: mollie-payments-for-woocommerce PRE_SCRIPT: | + ls + pwd cd .. && mv WooCommerce mollie-payments-for-woocommerce && cd mollie-payments-for-woocommerce From a175c53294d5bb02bd2184cfe8142ecf6c38ec4a Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 9 Jan 2024 14:20:23 +0100 Subject: [PATCH 05/30] Change name in post script --- .github/workflows/release.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3872342c..a80d56674 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,5 @@ jobs: PHP_VERSION: 7.2 PLUGIN_MAIN_FILE: mollie-payments-for-woocommerce.php ARCHIVE_NAME: mollie-payments-for-woocommerce - PRE_SCRIPT: | - ls - pwd - cd .. && mv WooCommerce mollie-payments-for-woocommerce && cd mollie-payments-for-woocommerce + POST_SCRIPT: | + mv dist/WooCommerce dist/mollie-payments-for-woocommerce From a6e2f82ffe24648e02b64f9e6d515acc2e8e3d21 Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 6 Feb 2024 08:12:34 +0100 Subject: [PATCH 06/30] Check if we receive a payment before running a manualcapture logic. --- src/Payment/MollieOrderService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Payment/MollieOrderService.php b/src/Payment/MollieOrderService.php index ede0c6d05..435332811 100644 --- a/src/Payment/MollieOrderService.php +++ b/src/Payment/MollieOrderService.php @@ -179,7 +179,9 @@ public function onWebhookAction() )); } - do_action($this->pluginId . '_after_webhook_action', $payment, $order); + if ($payment instanceof Payment) { + do_action($this->pluginId . '_after_webhook_action', $payment, $order); + } // Status 200 } /** From e86fee2e26f9f0be7c627a1d82c46af1e7dd6c02 Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 6 Feb 2024 08:58:27 +0100 Subject: [PATCH 07/30] Move Payment object check to the capture method --- src/MerchantCapture/MerchantCaptureModule.php | 6 +++++- src/Payment/MollieOrderService.php | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index a3177f880..0bdca1dfa 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -153,7 +153,11 @@ public function run(ContainerInterface $container): bool add_action( $pluginId . '_after_webhook_action', - static function (Payment $payment, WC_Order $order) use ($container) { + static function ($payment, WC_Order $order) use ($container) { + + if (!$payment instanceof Payment) { + return; + } if ($payment->isAuthorized()) { if (!$payment->getAmountCaptured() == 0.0) { diff --git a/src/Payment/MollieOrderService.php b/src/Payment/MollieOrderService.php index 435332811..ede0c6d05 100644 --- a/src/Payment/MollieOrderService.php +++ b/src/Payment/MollieOrderService.php @@ -179,9 +179,7 @@ public function onWebhookAction() )); } - if ($payment instanceof Payment) { - do_action($this->pluginId . '_after_webhook_action', $payment, $order); - } + do_action($this->pluginId . '_after_webhook_action', $payment, $order); // Status 200 } /** From 8d49e839cdfc752e38e9ad6342b711172650be9f Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 19 Feb 2024 10:47:24 +0100 Subject: [PATCH 08/30] Remove typed order in3 method --- src/Gateway/GatewayModule.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index d73dfb51b..e06c151e0 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -6,7 +6,6 @@ namespace Mollie\WooCommerce\Gateway; -use Automattic\WooCommerce\Admin\Overrides\Order; use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController; use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; @@ -639,9 +638,9 @@ public function in3FieldsMandatory($fields, $errors) } /** - * @param Order $order + * @param $order */ - public function in3FieldsMandatoryPayForOrder(Order $order) + public function in3FieldsMandatoryPayForOrder($order) { $paymentMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; From 3b6a9823083842e685a3081fb6482ab63cd884ef Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 21 Feb 2024 16:33:48 +0100 Subject: [PATCH 09/30] PIWOO-330 fix typo in variable subscription --- src/Payment/MollieObject.php | 8 ++++---- .../MollieSubscriptionGateway.php | 20 +++++++++---------- .../Subscription/MollieSubscriptionTest.php | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Payment/MollieObject.php b/src/Payment/MollieObject.php index 0f362bcf2..9a69a834a 100644 --- a/src/Payment/MollieObject.php +++ b/src/Payment/MollieObject.php @@ -588,13 +588,13 @@ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder( $subscription->update_meta_data('_mollie_payment_id', $payment->id); $subscription->set_payment_method('mollie_wc_gateway_' . $payment->method); $subscription->save(); - $subcriptionParentOrder = $subscription->get_parent(); - if ($subcriptionParentOrder) { - $subcriptionParentOrder->update_meta_data( + $subscriptionParentOrder = $subscription->get_parent(); + if ($subscriptionParentOrder) { + $subscriptionParentOrder->update_meta_data( '_mollie_mandate_id', $payment->mandateId ); - $subcriptionParentOrder->save(); + $subscriptionParentOrder->save(); } } } diff --git a/src/Subscription/MollieSubscriptionGateway.php b/src/Subscription/MollieSubscriptionGateway.php index 25fd2d545..f62a6e839 100644 --- a/src/Subscription/MollieSubscriptionGateway.php +++ b/src/Subscription/MollieSubscriptionGateway.php @@ -235,15 +235,15 @@ public function scheduled_subscription_payment($renewal_total, WC_Order $renewal $subscriptions = wcs_get_subscriptions_for_renewal_order($renewal_order->get_id()); $subscription = array_pop($subscriptions); // Just need one valid subscription $subscription_mollie_payment_id = $subscription->get_meta('_mollie_payment_id'); - $subcriptionParentOrder = $subscription->get_parent(); - $mandateId = !empty($subcriptionParentOrder) ? $subcriptionParentOrder->get_meta('_mollie_mandate_id') : null; + $subscriptionParentOrder = $subscription->get_parent(); + $mandateId = !empty($subscriptionParentOrder) ? $subscriptionParentOrder->get_meta('_mollie_mandate_id') : null; if (! empty($subscription_mollie_payment_id) && ! empty($subscription)) { $customer_id = $this->restore_mollie_customer_id_and_mandate($customer_id, $subscription_mollie_payment_id, $subscription); } // Get all data for the renewal payment - $initialPaymentUsedOrderAPI = $this->initialPaymentUsedOrderAPI($subcriptionParentOrder); + $initialPaymentUsedOrderAPI = $this->initialPaymentUsedOrderAPI($subscriptionParentOrder); $data = $this->subscriptionObject->getRecurringPaymentRequestData($renewal_order, $customer_id, $initialPaymentUsedOrderAPI); // Allow filtering the renewal payment data @@ -301,14 +301,14 @@ public function scheduled_subscription_payment($renewal_total, WC_Order $renewal (property_exists($payment, 'mandateId') && $payment->mandateId !== null) && $payment->mandateId !== $mandateId - && !empty($subcriptionParentOrder) + && !empty($subscriptionParentOrder) ) { $this->logger->debug("{$this->id}: updating to mandate {$payment->mandateId}"); - $subcriptionParentOrder->update_meta_data( + $subscriptionParentOrder->update_meta_data( '_mollie_mandate_id', $payment->mandateId ); - $subcriptionParentOrder->save(); + $subscriptionParentOrder->save(); $mandateId = $payment->mandateId; } } else { @@ -722,15 +722,15 @@ public function is_available(): bool } /** - * @param $subcriptionParentOrder + * @param $subscriptionParentOrder * @return bool */ - protected function initialPaymentUsedOrderAPI($subcriptionParentOrder): bool + protected function initialPaymentUsedOrderAPI($subscriptionParentOrder): bool { - if (!$subcriptionParentOrder) { + if (!$subscriptionParentOrder) { return false; } - $orderIdMeta = $subcriptionParentOrder->get_meta('_mollie_order_id'); + $orderIdMeta = $subscriptionParentOrder->get_meta('_mollie_order_id'); $parentOrderMeta = $orderIdMeta ?: PaymentService::PAYMENT_METHOD_TYPE_PAYMENT; diff --git a/tests/php/Functional/Subscription/MollieSubscriptionTest.php b/tests/php/Functional/Subscription/MollieSubscriptionTest.php index ae2c43e91..d792bfa8b 100644 --- a/tests/php/Functional/Subscription/MollieSubscriptionTest.php +++ b/tests/php/Functional/Subscription/MollieSubscriptionTest.php @@ -38,7 +38,7 @@ public function __construct($name = null, array $data = [], $dataName = '') * THEN THE ORDER NOTES ARE CREATED * @test */ - public function renewSubcriptionPaymentTest() + public function renewSubscriptionPaymentTest() { $gatewayName = 'mollie_wc_gateway_ideal'; $renewalOrder = $this->wcOrder(); From 04b0b3b1b9c7524d65a44ae047ad15868871b170 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 22 Feb 2024 16:21:17 +0100 Subject: [PATCH 10/30] PIWOO-237 fix render one issuer --- .../PaymentFieldsStrategies/GiftcardFieldsStrategy.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php index f9c52f32d..b3a460987 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php @@ -26,9 +26,13 @@ public function execute($gateway, $dataHelper) if (count($issuers) === 1) { $issuer = $issuers[0]; $issuerImageSvg = $this->checkSvgIssuers($issuers); - $issuerImageSvg && ($html .= ''); - $html .= $issuer->name; - echo esc_html(wpautop(wptexturize($html))); + if ($issuerImageSvg && isset($issuer->name)) { + $issuerImageSvg = esc_url($issuerImageSvg); + $issuerName = esc_html($issuer->name); + $html .= '' . $issuerName; + } + + echo wpautop(wptexturize($html)); return; } From 656ee8fb38744f20e14acb0f89bf37606c6c8eff Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 22 Feb 2024 16:42:02 +0100 Subject: [PATCH 11/30] PIWOO-382 dont cache empty methods --- src/Shared/Data.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Shared/Data.php b/src/Shared/Data.php index 387aa711a..f91865002 100644 --- a/src/Shared/Data.php +++ b/src/Shared/Data.php @@ -705,7 +705,7 @@ public function getAllAvailablePaymentMethods($useCache = true) delete_transient($transient_id); } // No cache exists, call the API and cache the result - if ($methods === false) { + if (empty($methods)) { if (!$apiKey) { return []; } @@ -720,8 +720,8 @@ public function getAllAvailablePaymentMethods($useCache = true) // $methods_cleaned is empty array when the API doesn't return any methods, cache the empty array $methods = $methods_cleaned; - // Set new transients (as cache) - if ($useCache) { + // Set new transients (as cache) only if we have something in + if ($useCache && !empty($methods)) { set_transient($transient_id, $methods, HOUR_IN_SECONDS); } } From 273f8e43c5b14cdbd51343d0a10da6340b6cb8b4 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 22 Feb 2024 17:07:19 +0100 Subject: [PATCH 12/30] PIWOO-389 apply filter only on payments --- src/Payment/PaymentService.php | 13 +++++++++++++ src/PaymentMethods/Banktransfer.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Payment/PaymentService.php b/src/Payment/PaymentService.php index c2123d869..459097cef 100644 --- a/src/Payment/PaymentService.php +++ b/src/Payment/PaymentService.php @@ -342,6 +342,14 @@ protected function processAsMollieOrder( $data, $order ); + $this->logger->debug( + json_encode($data, JSON_PRETTY_PRINT) + ); + /*$data = apply_filters( + 'woocommerce_mollie_wc_gateway_' . $this->gateway->id . '_args', + $data, + $order + );*/ do_action( $this->pluginId . '_create_payment', @@ -467,6 +475,11 @@ protected function processAsMolliePayment( $data, $order ); + $data = apply_filters( + 'woocommerce_' . $this->gateway->id . 'payment_args', + $data, + $order + ); try { // Only enable this for hardcore debugging! diff --git a/src/PaymentMethods/Banktransfer.php b/src/PaymentMethods/Banktransfer.php index ab946c46c..c27503213 100644 --- a/src/PaymentMethods/Banktransfer.php +++ b/src/PaymentMethods/Banktransfer.php @@ -82,7 +82,7 @@ public function getFormFields($generalFormFields): array public function filtersOnBuild() { - add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . '_args', function (array $args, \WC_Order $order): array { + add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . 'payment_args', function (array $args, \WC_Order $order): array { return $this->addPaymentArguments($args, $order); }, 10, 2); } From e61d4bce95f99e459dcc089a1338a4df30475454 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Fri, 23 Feb 2024 14:44:11 +0100 Subject: [PATCH 13/30] PIWOO-422 enable capture flag and process as payment --- src/MerchantCapture/MerchantCaptureModule.php | 2 +- src/Payment/PaymentService.php | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index bceac1f9b..0bdca1dfa 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; } diff --git a/src/Payment/PaymentService.php b/src/Payment/PaymentService.php index 459097cef..50127fdb6 100644 --- a/src/Payment/PaymentService.php +++ b/src/Payment/PaymentService.php @@ -342,14 +342,6 @@ protected function processAsMollieOrder( $data, $order ); - $this->logger->debug( - json_encode($data, JSON_PRETTY_PRINT) - ); - /*$data = apply_filters( - 'woocommerce_mollie_wc_gateway_' . $this->gateway->id . '_args', - $data, - $order - );*/ do_action( $this->pluginId . '_create_payment', @@ -537,6 +529,21 @@ protected function processPaymentForMollie( // PROCESS REGULAR PAYMENT AS MOLLIE ORDER // if ($molliePaymentType === self::PAYMENT_METHOD_TYPE_ORDER) { + // if the capture is set to manual, and this is a credit card payment, we need to create a payment instead of an order + $captureType = get_option('mollie-payments-for-woocommerce_place_payment_onhold'); + if ($captureType === 'later_capture' && $this->gateway->id === 'mollie_wc_gateway_creditcard') { + $this->logger->debug( + "{$this->gateway->id}: Create payment for order {$orderId} capture set to manual", + [true] + ); + + $paymentObject = $this->processAsMolliePayment( + $order, + $customer_id, + $apiKey + ); + return $paymentObject; + } $this->logger->debug( "{$this->gateway->id}: Create Mollie payment object for order {$orderId}", [true] From c9d52eae88779d387569eaef921e56652bdd4b08 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 26 Feb 2024 11:13:19 +0100 Subject: [PATCH 14/30] PIWOO-237 Fix cs we escaped before --- .../PaymentFieldsStrategies/GiftcardFieldsStrategy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php index b3a460987..97c0f0e48 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php @@ -31,7 +31,7 @@ public function execute($gateway, $dataHelper) $issuerName = esc_html($issuer->name); $html .= '' . $issuerName; } - + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo wpautop(wptexturize($html)); return; From f3aa7b164f9f4947b3ca674a29cf8550d80affb0 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 6 Mar 2024 10:07:21 +0100 Subject: [PATCH 15/30] PIWOO-414 Add bancomat and fix in3, billie --- mollie-payments-for-woocommerce.php | 2 +- public/images/bancomatpay.svg | 11 +++ resources/js/mollieBillie.js | 32 ------- src/Assets/AssetsModule.php | 7 -- src/Gateway/GatewayModule.php | 91 ++++++++++++++++++- src/PaymentMethods/Bancomatpay.php | 36 ++++++++ src/PaymentMethods/Billie.php | 2 +- .../BancomatpayFieldsStrategy.php | 56 ++++++++++++ .../BillieFieldsStrategy.php | 56 ++++++++++++ .../In3FieldsStrategy.php | 9 +- src/Shared/SharedDataDictionary.php | 1 + webpack.config.js | 1 - 12 files changed, 252 insertions(+), 52 deletions(-) create mode 100644 public/images/bancomatpay.svg delete mode 100644 resources/js/mollieBillie.js create mode 100644 src/PaymentMethods/Bancomatpay.php create mode 100644 src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php create mode 100644 src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index b62a5af25..07eae740b 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.5.1 + * Version: 7.6.0 * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0 diff --git a/public/images/bancomatpay.svg b/public/images/bancomatpay.svg new file mode 100644 index 000000000..6d0b5e845 --- /dev/null +++ b/public/images/bancomatpay.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/resources/js/mollieBillie.js b/resources/js/mollieBillie.js deleted file mode 100644 index ad31361e1..000000000 --- a/resources/js/mollieBillie.js +++ /dev/null @@ -1,32 +0,0 @@ -import {maybeRequireField, saveOriginalField} from "./wooCheckoutFieldsUtility"; - -( - function ({jQuery}) { - let gateway = 'mollie_wc_gateway_billie'; - let inputCompanyName = 'billing_company'; - let originalBillingCompanyField = saveOriginalField(inputCompanyName, {}); - let companyFieldId = 'billing_company_field'; - let companyField = jQuery('form[name="checkout"] p#billing_company_field'); - let positionCompanyField = 'li.wc_payment_method.payment_method_mollie_wc_gateway_billie'; - let companyMarkup = '

' - + '' - + '' - + '' - + '' - + '

' - - jQuery(function () { - jQuery('body') - .on('updated_checkout payment_method_selected', function () { - companyField = maybeRequireField(companyField, positionCompanyField, companyMarkup, inputCompanyName, companyFieldId, originalBillingCompanyField, gateway); - }); - }); - } -)( - window -) - - - diff --git a/src/Assets/AssetsModule.php b/src/Assets/AssetsModule.php index 5a97e4e73..da8c7a6e4 100644 --- a/src/Assets/AssetsModule.php +++ b/src/Assets/AssetsModule.php @@ -276,13 +276,6 @@ protected function registerFrontendScripts(string $pluginUrl, string $pluginPath (string) filemtime($this->getPluginPath($pluginPath, '/public/js/gatewaySurcharge.min.js')), true ); - wp_register_script( - 'mollie-billie-classic-handles', - $this->getPluginUrl($pluginUrl, '/public/js/mollieBillie.min.js'), - ['underscore', 'jquery'], - (string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollieBillie.min.js')), - true - ); } public function registerBlockScripts(string $pluginUrl, string $pluginPath): void diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index e06c151e0..f0ed2a3eb 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -249,6 +249,11 @@ static function () { 11, 2 ); + add_action( + 'woocommerce_checkout_posted_data', + [$this, 'switchFields'], + 11 + ); } $isIn3Enabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_in3_settings', 'enabled'); if ($isIn3Enabled) { @@ -263,6 +268,30 @@ static function () { [$this, 'in3FieldsMandatoryPayForOrder'], 11 ); + add_action( + 'woocommerce_checkout_posted_data', + [$this, 'switchFields'], + 11 + ); + } + $isBancomatPayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_bancomatpay_settings', 'enabled'); + if ($isBancomatPayEnabled) { + add_filter( + 'woocommerce_after_checkout_validation', + [$this, 'bancomatpayFieldsMandatory'], + 11, + 2 + ); + add_action( + 'woocommerce_before_pay_action', + [$this, 'bancomatpayFieldsMandatoryPayForOrder'], + 11 + ); + add_action( + 'woocommerce_checkout_posted_data', + [$this, 'switchFields'], + 11 + ); } // Set order to paid and processed when eventually completed without Mollie add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1); @@ -621,7 +650,7 @@ protected function instantiatePaymentMethods($container): array public function BillieFieldsMandatory($fields, $errors) { $gatewayName = "mollie_wc_gateway_billie"; - $field = 'billing_company'; + $field = 'billing_company_billie'; $companyLabel = __('Company', 'mollie-payments-for-woocommerce'); return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $field, $companyLabel, $errors); } @@ -629,7 +658,7 @@ public function BillieFieldsMandatory($fields, $errors) public function in3FieldsMandatory($fields, $errors) { $gatewayName = "mollie_wc_gateway_in3"; - $phoneField = 'billing_phone'; + $phoneField = 'billing_phone_in3'; $birthdateField = self::FIELD_IN3_BIRTHDATE; $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); $birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce'); @@ -637,6 +666,15 @@ public function in3FieldsMandatory($fields, $errors) return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors); } + public function bancomatpayFieldsMandatory($fields, $errors) + { + $gatewayName = "mollie_wc_gateway_bancomatpay"; + $phoneField = 'billing_phone_bancomatpay'; + $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); + return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $phoneField, $phoneLabel, $errors); + } + + /** * @param $order */ @@ -662,6 +700,31 @@ public function in3FieldsMandatoryPayForOrder($order) } } + /** + * @param $order + */ + public function bancomatpayFieldsMandatoryPayForOrder($order) + { + $paymentMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + + if ($paymentMethod !== 'mollie_wc_gateway_bancomatpay') { + return; + } + + $phoneValue = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); + + if (!$phoneValue) { + wc_add_notice( + sprintf( + __('%s is a required field.', 'woocommerce'), + "$phoneLabel" + ), + 'error' + ); + } + } + /** * @param string $id * @param IconFactory $iconFactory @@ -722,4 +785,28 @@ public function addPaymentMethodMandatoryFields($fields, string $gatewayName, st return $fields; } + + + public function switchFields($data) + { + if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_in3') { + $fieldPosted = filter_input(INPUT_POST, 'billing_phone_in3', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + if ($fieldPosted) { + $data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone']; + } + } + if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_bancomatpay') { + $fieldPosted = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + if ($fieldPosted) { + $data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone']; + } + } + if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_billie') { + $fieldPosted = filter_input(INPUT_POST, 'billing_company_billie', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + if ($fieldPosted) { + $data['billing_company'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_company']; + } + } + return $data; + } } diff --git a/src/PaymentMethods/Bancomatpay.php b/src/PaymentMethods/Bancomatpay.php new file mode 100644 index 000000000..dd3d33fed --- /dev/null +++ b/src/PaymentMethods/Bancomatpay.php @@ -0,0 +1,36 @@ + 'bancomatpay', + 'defaultTitle' => __('Bancomat Pay', 'mollie-payments-for-woocommerce'), + 'settingsDescription' => '', + 'defaultDescription' => '', + 'paymentFields' => true, + 'instructions' => false, + 'supports' => [ + 'products', + 'refunds', + ], + 'filtersOnBuild' => false, + 'confirmationDelayed' => false, + 'errorMessage' => __( + 'Required field is empty. Phone field is required.', + 'mollie-payments-for-woocommerce' + ), + 'phonePlaceholder' => __('Please enter your phone here. +00..', 'mollie-payments-for-woocommerce'), + ]; + } + + public function getFormFields($generalFormFields): array + { + return $generalFormFields; + } +} diff --git a/src/PaymentMethods/Billie.php b/src/PaymentMethods/Billie.php index 720aed889..369f49521 100644 --- a/src/PaymentMethods/Billie.php +++ b/src/PaymentMethods/Billie.php @@ -16,7 +16,7 @@ protected function getConfig(): array 'mollie-payments-for-woocommerce' ), 'defaultDescription' => '', - 'paymentFields' => false, + 'paymentFields' => true, 'instructions' => false, 'supports' => [ 'products', diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php new file mode 100644 index 000000000..a274e4516 --- /dev/null +++ b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php @@ -0,0 +1,56 @@ +getOrderIdOnPayForOrderPage(); + $showPhoneField = empty($order->get_billing_phone()); + } + + if (is_checkout() && !is_checkout_pay_page()) { + $showPhoneField = true; + } + + if ($showPhoneField) { + $this->phoneNumber(); + } + } + + protected function getOrderIdOnPayForOrderPage() + { + global $wp; + $orderId = absint($wp->query_vars['order-pay']); + return wc_get_order($orderId); + } + + protected function phoneNumber() + { + ?> +

+ + + + +

+ getOrderIdOnPayForOrderPage(); + $showCompanyField = empty($order->get_billing_company()); + } + + if (is_checkout() && !is_checkout_pay_page()) { + $showCompanyField = true; + } + + if ($showCompanyField) { + $this->company(); + } + } + + protected function getOrderIdOnPayForOrderPage() + { + global $wp; + $orderId = absint($wp->query_vars['order-pay']); + return wc_get_order($orderId); + } + + protected function company() + { + ?> +

+ + + + +

+ checkout()->get_checkout_fields(); - - if (!isset($checkoutFields["billing"][self::FIELD_PHONE])) { $showPhoneField = true; - } - - if (!isset($checkoutFields["billing"][self::FIELD_BIRTHDATE])) { $showBirthdateField = true; - } } if ($showPhoneField) { diff --git a/src/Shared/SharedDataDictionary.php b/src/Shared/SharedDataDictionary.php index eb7224391..c544c5937 100644 --- a/src/Shared/SharedDataDictionary.php +++ b/src/Shared/SharedDataDictionary.php @@ -33,6 +33,7 @@ class SharedDataDictionary 'Mollie_WC_Gateway_Directdebit', 'Mollie_WC_Gateway_Blik', 'Mollie_WC_Gateway_Twint', + 'Mollie_WC_Gateway_Bancomatpay', ]; public const MOLLIE_OPTIONS_NAMES = [ diff --git a/webpack.config.js b/webpack.config.js index 81a5f614e..1ae240bf1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,7 +30,6 @@ function configJavaScript ({ basePath }) .addEntry('mollieBlockIndex.min', './resources/js/mollieBlockIndex.js') .addEntry('paypalButtonBlockComponent.min', './resources/js/paypalButtonBlockComponent.js') .addEntry('applepayButtonBlockComponent.min', './resources/js/applepayButtonBlockComponent.js') - .addEntry('mollieBillie.min', './resources/js/mollieBillie.js') .enableSourceMaps(!Encore.isProduction()) return extractEncoreConfig('javascript-configuration') From ddd7453ab4c479ef63448f88a9e58c3ba1d0fb83 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 7 Mar 2024 09:47:58 +0100 Subject: [PATCH 16/30] PIWOO-414 Add feature flag for bancomat --- src/Gateway/GatewayModule.php | 10 ++++++++-- src/PaymentMethods/Constants.php | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index f0ed2a3eb..83ad0163b 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -102,7 +102,7 @@ public function services(): array } return $availableMethods; }, - 'gateway.getKlarnaPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array { + 'gateway.getPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array { $availablePaymentMethods = $container->get('gateway.listAllMethodsAvailable'); $klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', true); if (!$klarnaOneFlag) { @@ -110,6 +110,12 @@ public function services(): array return $method['id'] !== Constants::KLARNA; }); } + $bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', false); + if (!$bancomatpayFlag) { + return array_filter($availablePaymentMethods, static function ($method) { + return $method['id'] !== Constants::BANCOMATPAY; + }); + } return $availablePaymentMethods; }, 'gateway.isSDDGatewayEnabled' => static function (ContainerInterface $container): bool { @@ -611,7 +617,7 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container): protected function instantiatePaymentMethods($container): array { $paymentMethods = []; - $listAllAvailablePaymentMethods = $container->get('gateway.getKlarnaPaymentMethodsAfterFeatureFlag'); + $listAllAvailablePaymentMethods = $container->get('gateway.getPaymentMethodsAfterFeatureFlag'); $iconFactory = $container->get(IconFactory::class); assert($iconFactory instanceof IconFactory); $settingsHelper = $container->get('settings.settings_helper'); diff --git a/src/PaymentMethods/Constants.php b/src/PaymentMethods/Constants.php index 9ff73d941..6f62e6b27 100644 --- a/src/PaymentMethods/Constants.php +++ b/src/PaymentMethods/Constants.php @@ -10,4 +10,6 @@ class Constants public const KLARNA = 'klarna'; public const DIRECTDEBIT = 'directdebit'; public const BANKTRANSFER = 'banktransfer'; + + public const BANCOMATPAY = 'bancomatpay'; } From cf4a786b387d11083d75e5130829e68256fa8fbe Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 11 Mar 2024 09:42:30 +0100 Subject: [PATCH 17/30] PIWOO-414 Check phone is valid --- src/Gateway/GatewayModule.php | 75 ++++++++++++++++--- src/Payment/PaymentService.php | 2 +- .../BancomatpayFieldsStrategy.php | 7 +- .../BillieFieldsStrategy.php | 2 +- .../In3FieldsStrategy.php | 7 +- 5 files changed, 80 insertions(+), 13 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 83ad0163b..8981bee3c 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -255,11 +255,6 @@ static function () { 11, 2 ); - add_action( - 'woocommerce_checkout_posted_data', - [$this, 'switchFields'], - 11 - ); } $isIn3Enabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_in3_settings', 'enabled'); if ($isIn3Enabled) { @@ -656,7 +651,7 @@ protected function instantiatePaymentMethods($container): array public function BillieFieldsMandatory($fields, $errors) { $gatewayName = "mollie_wc_gateway_billie"; - $field = 'billing_company_billie'; + $field = 'billing_company'; $companyLabel = __('Company', 'mollie-payments-for-woocommerce'); return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $field, $companyLabel, $errors); } @@ -668,7 +663,7 @@ public function in3FieldsMandatory($fields, $errors) $birthdateField = self::FIELD_IN3_BIRTHDATE; $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); $birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce'); - $fields = $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $phoneField, $phoneLabel, $errors); + $fields = $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors); return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors); } @@ -677,7 +672,7 @@ public function bancomatpayFieldsMandatory($fields, $errors) $gatewayName = "mollie_wc_gateway_bancomatpay"; $phoneField = 'billing_phone_bancomatpay'; $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); - return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $phoneField, $phoneLabel, $errors); + return $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors); } @@ -704,6 +699,21 @@ public function in3FieldsMandatoryPayForOrder($order) 'error' ); } + $phoneValue = filter_input(INPUT_POST, 'billing_phone_in3', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + $phoneValue = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : false; + $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); + + if (!$phoneValue) { + wc_add_notice( + sprintf( + __('%s is a required field. Valid phone format +000000000', 'mollie-payments-for-woocommerce'), + "$phoneLabel" + ), + 'error' + ); + } else { + $order->set_billing_phone($phoneValue); + } } /** @@ -718,16 +728,19 @@ public function bancomatpayFieldsMandatoryPayForOrder($order) } $phoneValue = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + $phoneValue = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : false; $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); if (!$phoneValue) { wc_add_notice( sprintf( - __('%s is a required field.', 'woocommerce'), + __('%s is a required field. Valid phone format +00000000000', 'mollie-payments-for-woocommerce'), "$phoneLabel" ), 'error' ); + } else { + $order->set_billing_phone($phoneValue); } } @@ -792,6 +805,45 @@ public function addPaymentMethodMandatoryFields($fields, string $gatewayName, st return $fields; } + public function addPaymentMethodMandatoryFieldsPhoneVerification( + $fields, + string $gatewayName, + string $field, + string $fieldLabel, + $errors + ) { + if ($fields['payment_method'] !== $gatewayName) { + return $fields; + } + if (isset($fields['billing_phone']) && $this->isPhoneValid($fields['billing_phone'])) { + return $fields; + } + $fieldPosted = filter_input(INPUT_POST, $field, FILTER_SANITIZE_SPECIAL_CHARS) ?? false; + if (!$fieldPosted) { + $errors->add( + 'validation', + sprintf( + __('%s is a required field.', 'woocommerce'), + "$fieldLabel" + ) + ); + return $fields; + } + + if (!$this->isPhoneValid($fieldPosted)) { + $errors->add( + 'validation', + sprintf( + __('%s is not a valid phone number. Valid phone format +00000000000', 'woocommerce'), + "$fieldLabel" + ) + ); + return $fields; + } else { + $fields['billing_phone'] = $fieldPosted; + } + return $fields; + } public function switchFields($data) { @@ -815,4 +867,9 @@ public function switchFields($data) } return $data; } + + private function isPhoneValid($billing_phone) + { + return preg_match('/^\+[1-9]\d{1,14}$/', $billing_phone); + } } diff --git a/src/Payment/PaymentService.php b/src/Payment/PaymentService.php index 50127fdb6..f866de5fa 100644 --- a/src/Payment/PaymentService.php +++ b/src/Payment/PaymentService.php @@ -491,7 +491,7 @@ protected function processAsMolliePayment( : '', ]; - $this->logger->debug($apiCallLog); + $this->logger->debug(json_encode($apiCallLog, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); // Try as simple payment $paymentObject = $this->apiHelper->getApiClient( diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php index a274e4516..447ff85d9 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php @@ -14,7 +14,7 @@ public function execute($gateway, $dataHelper) if (is_checkout_pay_page()) { $order = $this->getOrderIdOnPayForOrderPage(); - $showPhoneField = empty($order->get_billing_phone()); + $showPhoneField = empty($order->get_billing_phone()) || !$this->isPhoneValid($order->get_billing_phone()); } if (is_checkout() && !is_checkout_pay_page()) { @@ -53,4 +53,9 @@ public function getFieldMarkup($gateway, $dataHelper) { return ""; } + + private function isPhoneValid(string $get_billing_phone) + { + return preg_match('/^\+[0-9]{11,13}$/', $get_billing_phone) === 1; + } } diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php index df2ca0ae2..4cab3e164 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php @@ -6,7 +6,7 @@ class BillieFieldsStrategy implements PaymentFieldsStrategyI { - const FIELD_COMPANY = "billing_company_billie"; + const FIELD_COMPANY = "billing_company"; public function execute($gateway, $dataHelper) { diff --git a/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php index 6985d0f70..f12d41a6d 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php @@ -16,7 +16,7 @@ public function execute($gateway, $dataHelper) if (is_checkout_pay_page()) { $order = $this->getOrderIdOnPayForOrderPage(); - $showPhoneField = empty($order->get_billing_phone()); + $showPhoneField = empty($order->get_billing_phone()) || !$this->isPhoneValid($order->get_billing_phone()); $showBirthdateField = true; } @@ -76,4 +76,9 @@ public function getFieldMarkup($gateway, $dataHelper) { return ""; } + + private function isPhoneValid(string $get_billing_phone) + { + return preg_match('/^\+[0-9]{11,13}$/', $get_billing_phone) === 1; + } } From 6faa795312203a739705607fd4d96609cf78cefb Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 11 Mar 2024 17:22:26 +0100 Subject: [PATCH 18/30] PIWOO-414 Add gateway phone when on blocks --- resources/js/blocks/molliePaymentMethod.js | 46 +++++++++++++++++++++- src/Gateway/GatewayModule.php | 17 ++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 39303c616..83de427ea 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -191,6 +191,36 @@ const MollieComponent = (props) => { }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate, inputPhone]); + useEffect(() => { + let phoneLabel = getPhoneField()?.labels?.[0] ?? null; + if (!phoneLabel || phoneLabel.length === 0) { + return + } + if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay') { + phoneLabel.innerText = item.phonePlaceholder + } else { + if (phoneString !== false) { + phoneLabel.innerText = phoneString + } + } + let isPhoneEmpty = (billing.billingData.phone === '' && shippingData.shippingAddress.phone === '') && inputPhone === ''; + const unsubscribeProcessing = onCheckoutValidation( + + () => { + if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay' && isPhoneEmpty) { + return { + errorMessage: item.errorMessage, + }; + } + } + ); + return () => { + unsubscribeProcessing() + }; + + }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputPhone]); + + onSubmitLocal = onSubmit const updateIssuer = ( changeEvent ) => { selectIssuer( changeEvent.target.value ) @@ -214,7 +244,9 @@ const MollieComponent = (props) => { } function fieldMarkup(id, fieldType, label, action, value) { - return
+ const className = "wc-block-components-text-input wc-block-components-address-form__" + id; + return
+
} if (item.name === "mollie_wc_gateway_billie"){ @@ -231,7 +263,17 @@ const MollieComponent = (props) => { fields.push(fieldMarkup("billing-birthdate", "date", birthdateField, updateBirthdate, inputBirthdate)); if (!isPhoneFieldVisible) { const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; - fields.push(fieldMarkup("billing-phone", "tel", phoneField, updatePhone, inputPhone)); + fields.push(fieldMarkup("billing-phone-in3", "tel", phoneField, updatePhone, inputPhone)); + } + + return <>{fields}; + } + + if (item.name === "mollie_wc_gateway_bancomatpay"){ + let fields = []; + if (!isPhoneFieldVisible) { + const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; + fields.push(fieldMarkup("billing-phone-bancomatpay", "tel", phoneField, updatePhone, inputPhone)); } return <>{fields}; diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 8981bee3c..2a7d2dcec 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -274,6 +274,8 @@ static function () { [$this, 'switchFields'], 11 ); + add_action( 'woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'],11 ); + } $isBancomatPayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_bancomatpay_settings', 'enabled'); if ($isBancomatPayEnabled) { @@ -293,6 +295,7 @@ static function () { [$this, 'switchFields'], 11 ); + add_action( 'woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'],11 ); } // Set order to paid and processed when eventually completed without Mollie add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1); @@ -872,4 +875,18 @@ private function isPhoneValid($billing_phone) { return preg_match('/^\+[1-9]\d{1,14}$/', $billing_phone); } + + public function addPhoneWhenRest($arrayContext) + { + $context = $arrayContext; + $phoneMandatoryGateways = ['mollie_wc_gateway_in3', 'mollie_wc_gateway_bancomatpay']; + $paymentMethod = $context->payment_data['payment_method']; + if (in_array($paymentMethod, $phoneMandatoryGateways)) { + $billingPhone = $context->payment_data['billing_phone']; + if ($billingPhone) { + $context->order->set_billing_phone($billingPhone); + $context->order->save(); + } + } + } } From ff6cedc0cf5d10483b6ff14a830e398757aabd75 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 13 Mar 2024 17:49:28 +0100 Subject: [PATCH 19/30] PIWOO-414 add phone only if optional --- src/Gateway/GatewayModule.php | 13 +++++++++- src/PaymentMethods/Bancomatpay.php | 22 +++++++++++++++- .../BancomatpayFieldsStrategy.php | 21 ++++++++-------- .../In3FieldsStrategy.php | 25 ++++++++++--------- src/Shared/SharedDataDictionary.php | 1 + 5 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 2a7d2dcec..5f0111871 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -346,6 +346,17 @@ static function ($paymentContext) { } ); add_action('add_meta_boxes_woocommerce_page_wc-orders', [$this, 'addShopOrderMetabox'], 10); + add_filter( 'woocommerce_form_field_args', static function ($args, $key, $value) use ($container) { + if ($key !== 'billing_phone') { + return $args; + } + if ($args['required'] === true) { + update_option('mollie_wc_is_phone_required_flag', true); + }else{ + update_option('mollie_wc_is_phone_required_flag', false); + } + return $args; + }, 10, 3); return true; } @@ -873,7 +884,7 @@ public function switchFields($data) private function isPhoneValid($billing_phone) { - return preg_match('/^\+[1-9]\d{1,14}$/', $billing_phone); + return preg_match('/^\+[1-9]\d{10,13}$/', $billing_phone); } public function addPhoneWhenRest($arrayContext) diff --git a/src/PaymentMethods/Bancomatpay.php b/src/PaymentMethods/Bancomatpay.php index dd3d33fed..510aa9226 100644 --- a/src/PaymentMethods/Bancomatpay.php +++ b/src/PaymentMethods/Bancomatpay.php @@ -19,7 +19,7 @@ public function getConfig(): array 'products', 'refunds', ], - 'filtersOnBuild' => false, + 'filtersOnBuild' => true, 'confirmationDelayed' => false, 'errorMessage' => __( 'Required field is empty. Phone field is required.', @@ -33,4 +33,24 @@ public function getFormFields($generalFormFields): array { return $generalFormFields; } + + public function filtersOnBuild() + { + add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . 'payment_args', function (array $args, \WC_Order $order): array { + return $this->addPaymentArguments($args, $order); + }, 10, 2); + } + /** + * @param WC_Order $order + * @return array + */ + public function addPaymentArguments(array $args, $order) + { + $phone = $order->get_billing_phone(); + if (!empty($phone)) { + $args['billingAddress']['phone'] = $phone; + } + + return $args; + } } diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php index 447ff85d9..0952e3924 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php @@ -11,18 +11,21 @@ class BancomatpayFieldsStrategy implements PaymentFieldsStrategyI public function execute($gateway, $dataHelper) { $showPhoneField = false; + $isPhoneRequired = get_option('mollie_wc_is_phone_required_flag'); + $phoneValue = false; if (is_checkout_pay_page()) { $order = $this->getOrderIdOnPayForOrderPage(); - $showPhoneField = empty($order->get_billing_phone()) || !$this->isPhoneValid($order->get_billing_phone()); + $phoneValue = $order->get_billing_phone(); + $showPhoneField = true; } - if (is_checkout() && !is_checkout_pay_page()) { - $showPhoneField = true; + if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) { + $showPhoneField = true; } if ($showPhoneField) { - $this->phoneNumber(); + $this->phoneNumber($phoneValue); } } @@ -33,8 +36,9 @@ protected function getOrderIdOnPayForOrderPage() return wc_get_order($orderId); } - protected function phoneNumber() + protected function phoneNumber($phoneValue) { + $phoneValue = $phoneValue ?: ''; ?>

getOrderIdOnPayForOrderPage(); - $showPhoneField = empty($order->get_billing_phone()) || !$this->isPhoneValid($order->get_billing_phone()); $showBirthdateField = true; + $showPhoneField = true; + $order = $this->getOrderIdOnPayForOrderPage(); + $phoneValue = $order->get_billing_phone(); } + if (is_checkout() && !is_checkout_pay_page() && !$isPhoneRequired) { + $showPhoneField = true; + } if (is_checkout() && !is_checkout_pay_page()) { - $showPhoneField = true; - $showBirthdateField = true; + $showBirthdateField = true; } if ($showPhoneField) { - $this->phoneNumber(); + $this->phoneNumber($phoneValue); } if ($showBirthdateField) { @@ -56,8 +61,9 @@ protected function dateOfBirth()

Date: Thu, 14 Mar 2024 10:12:48 +0100 Subject: [PATCH 20/30] PIWOO-414 add phone only if optional in blocks --- resources/js/mollieBlockIndex.js | 25 +++++++++++-------------- src/Gateway/GatewayModule.php | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/resources/js/mollieBlockIndex.js b/resources/js/mollieBlockIndex.js index 641511e57..8f4f9e3c2 100644 --- a/resources/js/mollieBlockIndex.js +++ b/resources/js/mollieBlockIndex.js @@ -7,33 +7,30 @@ import molliePaymentMethod from './blocks/molliePaymentMethod' } window.onload = (event) => { const { registerPaymentMethod } = wc.wcBlocksRegistry; + const { checkoutData, defaultFields } = wc.wcSettings.allSettings; + const { billing_address, shipping_address } = checkoutData; const { ajaxUrl, filters, gatewayData, availableGateways } = mollieBlockData.gatewayData; const {useEffect} = wp.element; const isAppleSession = typeof window.ApplePaySession === "function" const isBlockEditor = !!wp?.blockEditor; function getCompanyField() { - let shippingCompany = document.getElementById('shipping-company'); - let billingCompany = document.getElementById('billing-company'); + let shippingCompany = shipping_address.company ?? false; + let billingCompany = billing_address.company ?? false; return shippingCompany ? shippingCompany : billingCompany; } function getPhoneField() { - const shippingPhone = document.getElementById('shipping-phone'); - const billingPhone = document.getElementById('billing-phone'); + const shippingPhone = shipping_address.phone ?? false; + const billingPhone = billing_address.phone ?? false return billingPhone || shippingPhone; } - function isFieldVisible(field) - { - return field && field.style.display !== 'none'; - } - let companyField = getCompanyField(); - const isCompanyFieldVisible = companyField && isFieldVisible(companyField); - const companyNameString = companyField && companyField.parentNode.querySelector('label') ? companyField.parentNode.querySelector('label').innerHTML : false; - let phoneField = getPhoneField(); - const isPhoneFieldVisible = phoneField && isFieldVisible(phoneField); - const phoneString = phoneField && phoneField.parentNode.querySelector('label') ? phoneField.parentNode.querySelector('label').innerHTML : false; + + const isCompanyFieldVisible = getCompanyField(); + const companyNameString = defaultFields.company.label + const isPhoneFieldVisible = getPhoneField(); + const phoneString = defaultFields.phone.label let requiredFields = { 'companyNameString': companyNameString, 'phoneString': phoneString, diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 5f0111871..01b636b29 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -7,6 +7,7 @@ namespace Mollie\WooCommerce\Gateway; use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController; +use Automattic\WooCommerce\StoreApi\Exceptions\RouteException; use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; @@ -274,8 +275,7 @@ static function () { [$this, 'switchFields'], 11 ); - add_action( 'woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'],11 ); - + add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11); } $isBancomatPayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_bancomatpay_settings', 'enabled'); if ($isBancomatPayEnabled) { @@ -295,7 +295,7 @@ static function () { [$this, 'switchFields'], 11 ); - add_action( 'woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'],11 ); + add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11); } // Set order to paid and processed when eventually completed without Mollie add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1); @@ -346,13 +346,13 @@ static function ($paymentContext) { } ); add_action('add_meta_boxes_woocommerce_page_wc-orders', [$this, 'addShopOrderMetabox'], 10); - add_filter( 'woocommerce_form_field_args', static function ($args, $key, $value) use ($container) { + add_filter('woocommerce_form_field_args', static function ($args, $key, $value) use ($container) { if ($key !== 'billing_phone') { return $args; } if ($args['required'] === true) { update_option('mollie_wc_is_phone_required_flag', true); - }else{ + } else { update_option('mollie_wc_is_phone_required_flag', false); } return $args; @@ -897,6 +897,13 @@ public function addPhoneWhenRest($arrayContext) if ($billingPhone) { $context->order->set_billing_phone($billingPhone); $context->order->save(); + } else { + $message = __('Please introduce a valid phone number. +00000000000', 'mollie-payments-for-woocommerce'); + throw new RouteException( + 'woocommerce_rest_checkout_process_payment_error', + $message, + 402 + ); } } } From dedfade56e5a73ec21f165d94a44dfbff66e0c99 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 19 Mar 2024 10:29:06 +0100 Subject: [PATCH 21/30] PIWOO-441 phone number can be prepopulated in block preview --- mollie-payments-for-woocommerce.php | 2 +- src/Gateway/GatewayModule.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index 07eae740b..bffaa36c4 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.6.0 + * Version: 7.5.2-beta * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0 diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 01b636b29..cc6fba010 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -893,6 +893,10 @@ public function addPhoneWhenRest($arrayContext) $phoneMandatoryGateways = ['mollie_wc_gateway_in3', 'mollie_wc_gateway_bancomatpay']; $paymentMethod = $context->payment_data['payment_method']; if (in_array($paymentMethod, $phoneMandatoryGateways)) { + $billingPhone = $context->order->get_billing_phone(); + if (!empty($billingPhone) && $this->isPhoneValid($billingPhone)) { + return; + } $billingPhone = $context->payment_data['billing_phone']; if ($billingPhone) { $context->order->set_billing_phone($billingPhone); From 025ba9675d7bde64710c04d12c7b2a90f6c732b5 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 11 Apr 2024 09:03:31 +0200 Subject: [PATCH 22/30] Remove phone mandatory in bancomatpay --- src/Gateway/GatewayModule.php | 66 +----------------------------- src/PaymentMethods/Bancomatpay.php | 29 +------------ 2 files changed, 4 insertions(+), 91 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index cc6fba010..e1528a6cd 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -277,26 +277,7 @@ static function () { ); add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11); } - $isBancomatPayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_bancomatpay_settings', 'enabled'); - if ($isBancomatPayEnabled) { - add_filter( - 'woocommerce_after_checkout_validation', - [$this, 'bancomatpayFieldsMandatory'], - 11, - 2 - ); - add_action( - 'woocommerce_before_pay_action', - [$this, 'bancomatpayFieldsMandatoryPayForOrder'], - 11 - ); - add_action( - 'woocommerce_checkout_posted_data', - [$this, 'switchFields'], - 11 - ); - add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11); - } + // Set order to paid and processed when eventually completed without Mollie add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1); $appleGateway = isset($container->get('gateway.instances')['mollie_wc_gateway_applepay']) ? $container->get( @@ -681,15 +662,6 @@ public function in3FieldsMandatory($fields, $errors) return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors); } - public function bancomatpayFieldsMandatory($fields, $errors) - { - $gatewayName = "mollie_wc_gateway_bancomatpay"; - $phoneField = 'billing_phone_bancomatpay'; - $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); - return $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors); - } - - /** * @param $order */ @@ -730,34 +702,6 @@ public function in3FieldsMandatoryPayForOrder($order) } } - /** - * @param $order - */ - public function bancomatpayFieldsMandatoryPayForOrder($order) - { - $paymentMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; - - if ($paymentMethod !== 'mollie_wc_gateway_bancomatpay') { - return; - } - - $phoneValue = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; - $phoneValue = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : false; - $phoneLabel = __('Phone', 'mollie-payments-for-woocommerce'); - - if (!$phoneValue) { - wc_add_notice( - sprintf( - __('%s is a required field. Valid phone format +00000000000', 'mollie-payments-for-woocommerce'), - "$phoneLabel" - ), - 'error' - ); - } else { - $order->set_billing_phone($phoneValue); - } - } - /** * @param string $id * @param IconFactory $iconFactory @@ -867,12 +811,6 @@ public function switchFields($data) $data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone']; } } - if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_bancomatpay') { - $fieldPosted = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; - if ($fieldPosted) { - $data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone']; - } - } if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_billie') { $fieldPosted = filter_input(INPUT_POST, 'billing_company_billie', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; if ($fieldPosted) { @@ -890,7 +828,7 @@ private function isPhoneValid($billing_phone) public function addPhoneWhenRest($arrayContext) { $context = $arrayContext; - $phoneMandatoryGateways = ['mollie_wc_gateway_in3', 'mollie_wc_gateway_bancomatpay']; + $phoneMandatoryGateways = ['mollie_wc_gateway_in3']; $paymentMethod = $context->payment_data['payment_method']; if (in_array($paymentMethod, $phoneMandatoryGateways)) { $billingPhone = $context->order->get_billing_phone(); diff --git a/src/PaymentMethods/Bancomatpay.php b/src/PaymentMethods/Bancomatpay.php index 510aa9226..054ef951d 100644 --- a/src/PaymentMethods/Bancomatpay.php +++ b/src/PaymentMethods/Bancomatpay.php @@ -13,19 +13,14 @@ public function getConfig(): array 'defaultTitle' => __('Bancomat Pay', 'mollie-payments-for-woocommerce'), 'settingsDescription' => '', 'defaultDescription' => '', - 'paymentFields' => true, + 'paymentFields' => false, 'instructions' => false, 'supports' => [ 'products', 'refunds', ], - 'filtersOnBuild' => true, + 'filtersOnBuild' => false, 'confirmationDelayed' => false, - 'errorMessage' => __( - 'Required field is empty. Phone field is required.', - 'mollie-payments-for-woocommerce' - ), - 'phonePlaceholder' => __('Please enter your phone here. +00..', 'mollie-payments-for-woocommerce'), ]; } @@ -33,24 +28,4 @@ public function getFormFields($generalFormFields): array { return $generalFormFields; } - - public function filtersOnBuild() - { - add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . 'payment_args', function (array $args, \WC_Order $order): array { - return $this->addPaymentArguments($args, $order); - }, 10, 2); - } - /** - * @param WC_Order $order - * @return array - */ - public function addPaymentArguments(array $args, $order) - { - $phone = $order->get_billing_phone(); - if (!empty($phone)) { - $args['billingAddress']['phone'] = $phone; - } - - return $args; - } } From ba5f84bda31f35c596c0990f5cc4edb0e29e9b38 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 11 Apr 2024 09:20:30 +0200 Subject: [PATCH 23/30] Remove phone mandatory in bancomatpay block checkout --- resources/js/blocks/molliePaymentMethod.js | 40 ---------------------- 1 file changed, 40 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 83de427ea..3eeb5bc07 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -191,36 +191,6 @@ const MollieComponent = (props) => { }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate, inputPhone]); - useEffect(() => { - let phoneLabel = getPhoneField()?.labels?.[0] ?? null; - if (!phoneLabel || phoneLabel.length === 0) { - return - } - if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay') { - phoneLabel.innerText = item.phonePlaceholder - } else { - if (phoneString !== false) { - phoneLabel.innerText = phoneString - } - } - let isPhoneEmpty = (billing.billingData.phone === '' && shippingData.shippingAddress.phone === '') && inputPhone === ''; - const unsubscribeProcessing = onCheckoutValidation( - - () => { - if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay' && isPhoneEmpty) { - return { - errorMessage: item.errorMessage, - }; - } - } - ); - return () => { - unsubscribeProcessing() - }; - - }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputPhone]); - - onSubmitLocal = onSubmit const updateIssuer = ( changeEvent ) => { selectIssuer( changeEvent.target.value ) @@ -269,16 +239,6 @@ const MollieComponent = (props) => { return <>{fields}; } - if (item.name === "mollie_wc_gateway_bancomatpay"){ - let fields = []; - if (!isPhoneFieldVisible) { - const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; - fields.push(fieldMarkup("billing-phone-bancomatpay", "tel", phoneField, updatePhone, inputPhone)); - } - - return <>{fields}; - } - return

} From dc1b40354836a3753cfbf40a330dbf9728f1919f Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 11 Apr 2024 12:36:51 +0200 Subject: [PATCH 24/30] reorder gateway settings PIWOO-454 --- src/PaymentMethods/Giftcard.php | 9 +- src/PaymentMethods/Ideal.php | 9 +- src/PaymentMethods/Kbc.php | 9 +- .../General/MollieGeneralSettings.php | 134 ++++++++---------- 4 files changed, 87 insertions(+), 74 deletions(-) diff --git a/src/PaymentMethods/Giftcard.php b/src/PaymentMethods/Giftcard.php index 395016fa3..dbbd3895c 100644 --- a/src/PaymentMethods/Giftcard.php +++ b/src/PaymentMethods/Giftcard.php @@ -73,6 +73,11 @@ protected function getConfig(): array public function getFormFields($generalFormFields): array { + $searchKey = 'advanced'; + $keys = array_keys($generalFormFields); + $index = array_search($searchKey, $keys); + $before = array_slice($generalFormFields, 0, $index + 1, true); + $after = array_slice($generalFormFields, $index + 1, null, true); $paymentMethodFormFields = [ 'issuers_dropdown_shown' => [ 'title' => __( @@ -105,6 +110,8 @@ public function getFormFields($generalFormFields): array 'default' => __('Select your gift card', 'mollie-payments-for-woocommerce'), ], ]; - return array_merge($generalFormFields, $paymentMethodFormFields); + $before = array_merge($before, $paymentMethodFormFields); + $formFields = array_merge($before, $after); + return $formFields; } } diff --git a/src/PaymentMethods/Ideal.php b/src/PaymentMethods/Ideal.php index c02ee7e75..006ea6d95 100644 --- a/src/PaymentMethods/Ideal.php +++ b/src/PaymentMethods/Ideal.php @@ -29,6 +29,11 @@ public function getConfig(): array public function getFormFields($generalFormFields): array { + $searchKey = 'advanced'; + $keys = array_keys($generalFormFields); + $index = array_search($searchKey, $keys); + $before = array_slice($generalFormFields, 0, $index + 1, true); + $after = array_slice($generalFormFields, $index + 1, null, true); $paymentMethodFormFieds = [ 'issuers_dropdown_shown' => [ 'title' => __('Show iDEAL banks dropdown', 'mollie-payments-for-woocommerce'), @@ -55,6 +60,8 @@ public function getFormFields($generalFormFields): array 'default' => __('Select your bank', 'mollie-payments-for-woocommerce'), ], ]; - return array_merge($generalFormFields, $paymentMethodFormFieds); + $before = array_merge($before, $paymentMethodFormFieds); + $formFields = array_merge($before, $after); + return $formFields; } } diff --git a/src/PaymentMethods/Kbc.php b/src/PaymentMethods/Kbc.php index 5c220cac5..4005b83fd 100644 --- a/src/PaymentMethods/Kbc.php +++ b/src/PaymentMethods/Kbc.php @@ -28,6 +28,11 @@ protected function getConfig(): array public function getFormFields($generalFormFields): array { + $searchKey = 'advanced'; + $keys = array_keys($generalFormFields); + $index = array_search($searchKey, $keys); + $before = array_slice($generalFormFields, 0, $index + 1, true); + $after = array_slice($generalFormFields, $index + 1, null, true); $paymentMethodFormFieds = [ 'issuers_dropdown_shown' => [ 'title' => __( @@ -60,6 +65,8 @@ public function getFormFields($generalFormFields): array 'default' => __('Select your bank', 'mollie-payments-for-woocommerce'), ], ]; - return array_merge($generalFormFields, $paymentMethodFormFieds); + $before = array_merge($before, $paymentMethodFormFieds); + $formFields = array_merge($before, $after); + return $formFields; } } diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index a97d4a380..f55a549dc 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -28,7 +28,7 @@ public function gatewayFormFields( ), 'default' => 'yes', ], - [ + 'display'=>[ 'id' => $defaultTitle . '_' . 'title', 'title' => sprintf( /* translators: Placeholder 1: Gateway title */ @@ -37,20 +37,6 @@ public function gatewayFormFields( ), 'type' => 'title', ], - 'title' => [ - 'title' => __('Title', 'mollie-payments-for-woocommerce'), - 'type' => 'text', - /* translators: Placeholder 1: Gateway title */ - 'description' => sprintf( - __( - 'This controls the title which the user sees during checkout. Default %s', - 'mollie-payments-for-woocommerce' - ), - $defaultTitle - ), - 'default' => $defaultTitle, - 'desc_tip' => true, - ], 'use_api_title' => [ 'title' => __( 'Use API dynamic title and gateway logo', @@ -60,18 +46,18 @@ public function gatewayFormFields( 'label' => __('Retrieve the gateway title and logo from the Mollie API', 'mollie-payments-for-woocommerce'), 'default' => 'no', ], - 'description' => [ - 'title' => __('Description', 'mollie-payments-for-woocommerce'), - 'type' => 'textarea', - /* translators: Placeholder 1: Gateway description */ + 'title' => [ + 'title' => __('Title', 'mollie-payments-for-woocommerce'), + 'type' => 'text', + /* translators: Placeholder 1: Gateway title */ 'description' => sprintf( __( - 'Payment method description that the customer will see on your checkout. Default %s', + 'This controls the title which the user sees during checkout. Default %s', 'mollie-payments-for-woocommerce' ), - $defaultDescription + $defaultTitle ), - 'default' => $defaultDescription, + 'default' => $defaultTitle, 'desc_tip' => true, ], 'display_logo' => [ @@ -86,33 +72,6 @@ public function gatewayFormFields( ), 'default' => 'yes', ], - [ - 'id' => $defaultTitle . '_' . 'title', - 'title' => sprintf(__( - 'Sales countries', - 'mollie-payments-for-woocommerce' - )), - 'type' => 'title', - ], - 'allowed_countries' => [ - 'title' => __( - 'Sell to specific countries', - 'mollie-payments-for-woocommerce' - ), - 'desc' => '', - 'css' => 'min-width: 350px;', - 'default' => [], - 'type' => 'multi_select_countries', - ], - [ - 'id' => $defaultTitle . '_' . 'custom_logo', - 'title' => sprintf( - /* translators: Placeholder 1: Gateway title */ - __('%s custom logo', 'mollie-payments-for-woocommerce'), - $defaultTitle - ), - 'type' => 'title', - ], 'enable_custom_logo' => [ 'title' => __( 'Enable custom logo', @@ -141,7 +100,39 @@ public function gatewayFormFields( ), 'desc_tip' => true, ], - [ + 'description' => [ + 'title' => __('Description', 'mollie-payments-for-woocommerce'), + 'type' => 'textarea', + /* translators: Placeholder 1: Gateway description */ + 'description' => sprintf( + __( + 'Payment method description that the customer will see on your checkout. Default %s', + 'mollie-payments-for-woocommerce' + ), + $defaultDescription + ), + 'default' => $defaultDescription, + 'desc_tip' => true, + ], + 'sales'=>[ + 'id' => $defaultTitle . '_' . 'title', + 'title' => sprintf(__( + 'Sales countries', + 'mollie-payments-for-woocommerce' + )), + 'type' => 'title', + ], + 'allowed_countries' => [ + 'title' => __( + 'Sell to specific countries', + 'mollie-payments-for-woocommerce' + ), + 'desc' => '', + 'css' => 'min-width: 350px;', + 'default' => [], + 'type' => 'multi_select_countries', + ], + 'surcharge'=>[ 'id' => $defaultTitle . '_' . 'surcharge', 'title' => sprintf( /* translators: Placeholder 1: Gateway title */ @@ -239,7 +230,7 @@ public function gatewayFormFields( 'default' => '0.00', 'desc_tip' => true, ], - [ + 'advanced' =>[ 'id' => $defaultTitle . '_' . 'advanced', 'title' => sprintf( /* translators: Placeholder 1: gateway title */ @@ -248,26 +239,6 @@ public function gatewayFormFields( ), 'type' => 'title', ], - 'activate_expiry_days_setting' => [ - 'title' => __('Activate expiry time setting', 'mollie-payments-for-woocommerce'), - 'label' => __('Enable expiry time for payments', 'mollie-payments-for-woocommerce'), - 'description' => __('Enable this option if you want to be able to set the time after which the order will expire.', 'mollie-payments-for-woocommerce'), - 'type' => 'checkbox', - 'default' => 'no', - ], - 'order_dueDate' => [ - 'title' => sprintf(__('Expiry time', 'mollie-payments-for-woocommerce')), - 'type' => 'number', - 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], - 'description' => sprintf( - __( - 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', - 'mollie-payments-for-woocommerce' - ) - ), - 'default' => '10', - 'desc_tip' => false, - ], ]; if ($paymentConfirmation) { @@ -306,6 +277,27 @@ public function gatewayFormFields( ]; } + $formFields['activate_expiry_days_setting'] = [ + 'title' => __('Activate expiry time setting', 'mollie-payments-for-woocommerce'), + 'label' => __('Enable expiry time for payments', 'mollie-payments-for-woocommerce'), + 'description' => __('Enable this option if you want to be able to set the time after which the order will expire.', 'mollie-payments-for-woocommerce'), + 'type' => 'checkbox', + 'default' => 'no', + ]; + $formFields['order_dueDate'] = [ + 'title' => sprintf(__('Expiry time', 'mollie-payments-for-woocommerce')), + 'type' => 'number', + 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], + 'description' => sprintf( + __( + 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', + 'mollie-payments-for-woocommerce' + ) + ), + 'default' => '10', + 'desc_tip' => false, + ]; + return $formFields; } } From 4f71e105f7b0f1093f49af4cf9e710a2355590e1 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 11 Apr 2024 12:42:15 +0200 Subject: [PATCH 25/30] fix phpcs PIWOO-454 --- src/Settings/General/MollieGeneralSettings.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index f55a549dc..d92ea402f 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -28,7 +28,7 @@ public function gatewayFormFields( ), 'default' => 'yes', ], - 'display'=>[ + 'display' => [ 'id' => $defaultTitle . '_' . 'title', 'title' => sprintf( /* translators: Placeholder 1: Gateway title */ @@ -114,7 +114,7 @@ public function gatewayFormFields( 'default' => $defaultDescription, 'desc_tip' => true, ], - 'sales'=>[ + 'sales' => [ 'id' => $defaultTitle . '_' . 'title', 'title' => sprintf(__( 'Sales countries', @@ -132,7 +132,7 @@ public function gatewayFormFields( 'default' => [], 'type' => 'multi_select_countries', ], - 'surcharge'=>[ + 'surcharge' => [ 'id' => $defaultTitle . '_' . 'surcharge', 'title' => sprintf( /* translators: Placeholder 1: Gateway title */ @@ -230,7 +230,7 @@ public function gatewayFormFields( 'default' => '0.00', 'desc_tip' => true, ], - 'advanced' =>[ + 'advanced' => [ 'id' => $defaultTitle . '_' . 'advanced', 'title' => sprintf( /* translators: Placeholder 1: gateway title */ From 3432b5d3cfefffaf3791bea100527f67030e7734 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 15 Apr 2024 17:57:38 +0200 Subject: [PATCH 26/30] remove fields by type instead of key --- src/PaymentMethods/AbstractPaymentMethod.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PaymentMethods/AbstractPaymentMethod.php b/src/PaymentMethods/AbstractPaymentMethod.php index 1b16d1f3b..4aaa2576f 100644 --- a/src/PaymentMethods/AbstractPaymentMethod.php +++ b/src/PaymentMethods/AbstractPaymentMethod.php @@ -297,9 +297,9 @@ public function defaultSettings(): array { $fields = $this->getAllFormFields(); //remove setting title fields - $fields = array_filter($fields, static function ($key) { - return !is_numeric($key); - }, ARRAY_FILTER_USE_KEY); + $fields = array_filter($fields, static function ($field) { + return isset($field['type']) && $field['type']!== 'title'; + }); //we don't save the default description or title, in case the language changes unset($fields['description']); unset($fields['title']); From 2500d0766ee7c5717e963edf57e6459d5e98f555 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 15 Apr 2024 18:01:34 +0200 Subject: [PATCH 27/30] fix cs --- src/PaymentMethods/AbstractPaymentMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PaymentMethods/AbstractPaymentMethod.php b/src/PaymentMethods/AbstractPaymentMethod.php index 4aaa2576f..a83cee26f 100644 --- a/src/PaymentMethods/AbstractPaymentMethod.php +++ b/src/PaymentMethods/AbstractPaymentMethod.php @@ -298,7 +298,7 @@ public function defaultSettings(): array $fields = $this->getAllFormFields(); //remove setting title fields $fields = array_filter($fields, static function ($field) { - return isset($field['type']) && $field['type']!== 'title'; + return isset($field['type']) && $field['type'] !== 'title'; }); //we don't save the default description or title, in case the language changes unset($fields['description']); From 109d1508f82b180ea74adb4fc5970ae3bfa97406 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 17 Apr 2024 10:18:06 +0200 Subject: [PATCH 28/30] Enable bancomat feature flag --- 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 e1528a6cd..ad6520696 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -111,7 +111,7 @@ public function services(): array return $method['id'] !== Constants::KLARNA; }); } - $bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', false); + $bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', true); if (!$bancomatpayFlag) { return array_filter($availablePaymentMethods, static function ($method) { return $method['id'] !== Constants::BANCOMATPAY; From 4de58ad299b58accdeaf65b8375bec8f0b3a19a1 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 17 Apr 2024 10:22:09 +0200 Subject: [PATCH 29/30] 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 bffaa36c4..d4cdedd3b 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.5.2-beta + * Version: 7.5.2 * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0 From ab6fe7cce00f9c251ba529f483675317066b8d2d Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 17 Apr 2024 12:14:31 +0200 Subject: [PATCH 30/30] Update wp and wc tested versions --- mollie-payments-for-woocommerce.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index d4cdedd3b..e87005d15 100644 --- a/mollie-payments-for-woocommerce.php +++ b/mollie-payments-for-woocommerce.php @@ -7,12 +7,12 @@ * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0 - * Tested up to: 6.4 + * Tested up to: 6.5 * Text Domain: mollie-payments-for-woocommerce * Domain Path: /languages * License: GPLv2 or later * WC requires at least: 3.9 - * WC tested up to: 8.5 + * WC tested up to: 8.7 * Requires PHP: 7.2 */ declare(strict_types=1);