From 9a47c90ba82192cbadbc6ba55922f6081d8e3ebb Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 5 Jun 2023 15:31:20 +0200 Subject: [PATCH 01/41] Show paysafecard in blocks P-153 --- src/PaymentMethods/Paysafecard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PaymentMethods/Paysafecard.php b/src/PaymentMethods/Paysafecard.php index 04554c6e9..b1e180f3d 100644 --- a/src/PaymentMethods/Paysafecard.php +++ b/src/PaymentMethods/Paysafecard.php @@ -15,7 +15,7 @@ protected function getConfig(): array 'defaultDescription' => '', 'paymentFields' => false, 'instructions' => false, - 'supports' => [], + 'supports' => ['products'], 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'SEPA' => false, From b1c573600656975bcdb14b910c3f3e20d8197463 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 20 Jun 2023 17:24:17 +0200 Subject: [PATCH 02/41] Add in3 and billie required fields in block --- resources/js/blocks/molliePaymentMethod.js | 126 ++++++++++++++++++--- resources/js/mollieBlockIndex.js | 22 +--- src/Assets/AssetsModule.php | 2 + src/PaymentMethods/In3.php | 6 + 4 files changed, 120 insertions(+), 36 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 158170858..55635ce0c 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -4,13 +4,35 @@ let activePaymentMethodLocal let cachedAvailableGateways let creditCardSelected = new Event("mollie_creditcard_component_selected", {bubbles: true}); +function getCompanyField() +{ + let shippingCompany = document.getElementById('shipping-company'); + let billingCompany = document.getElementById('billing-company'); + return shippingCompany ? shippingCompany : billingCompany; +} + +function getPhoneField() +{ + let shippingPhone = document.getElementById('shipping-phone'); + let billingPhone = document.getElementById('billing-phone'); + return billingPhone ? billingPhone : shippingPhone; +} + const MollieComponent = (props) => { - let {onSubmit, activePaymentMethod, billing, item, useEffect, ajaxUrl, jQuery, emitResponse, eventRegistration, companyNameString} = props + let {onSubmit, activePaymentMethod, billing, item, useEffect, ajaxUrl, jQuery, emitResponse, eventRegistration, requiredFields, shippingData} = props const { responseTypes } = emitResponse; - const {onPaymentProcessing, onCheckoutValidationBeforeProcessing} = eventRegistration; + const {onPaymentSetup, onCheckoutValidation} = eventRegistration; const [ selectedIssuer, selectIssuer ] = wp.element.useState(''); - const issuerKey = 'mollie-payments-for-woocommerce_issuer_' + activePaymentMethod + const [ inputPhone, selectPhone ] = wp.element.useState(''); + const [ inputBirthdate, selectBirthdate ] = wp.element.useState(''); + const [ inputCompany, selectCompany ] = wp.element.useState(''); + const issuerKey = 'mollie-payments-for-woocommerce_issuer_' + activePaymentMethod + const {companyNameString, phoneString} = requiredFields + function isFieldVisible(field) + { + return field && field.style.display !== 'none'; + } function updateTotalLabel(newTotal, currency) { let feeText = newTotal + " " + currency let totalSpan = "" + feeText + "" @@ -93,23 +115,30 @@ const MollieComponent = (props) => { paymentMethodData: { payment_method: activePaymentMethod, payment_method_title: item.title, - [issuerKey]: selectedIssuer + [issuerKey]: selectedIssuer, + billing_phone: inputPhone, + billing_company: inputCompany, + billing_birthdate: inputBirthdate, } }, }; } - const unsubscribePaymentProcessing = onPaymentProcessing( + const unsubscribePaymentProcessing = onPaymentSetup( onProcessingPayment ); return () => { unsubscribePaymentProcessing() }; - }, [selectedIssuer, onPaymentProcessing]) + }, [selectedIssuer, onPaymentSetup, inputPhone, inputCompany, inputBirthdate]) useEffect(() => { let companyLabel = jQuery('div.wc-block-components-text-input.wc-block-components-address-form__company > label') + if (companyLabel.length === 0) { + return + } + if (activePaymentMethod === 'mollie_wc_gateway_billie') { let message = item.companyPlaceholder companyLabel.replaceWith('') @@ -118,9 +147,10 @@ const MollieComponent = (props) => { companyLabel.replaceWith('') } } - const unsubscribeProcessing = onCheckoutValidationBeforeProcessing( + let isCompanyEmpty = billing.billingData.company === '' && shippingData.shippingAddress.company === '' + const unsubscribeProcessing = onCheckoutValidation( () => { - if (activePaymentMethod === 'mollie_wc_gateway_billie' && billing.billingData.company === '') { + if (activePaymentMethod === 'mollie_wc_gateway_billie' && isCompanyEmpty) { return { errorMessage: item.errorMessage, }; @@ -131,36 +161,103 @@ const MollieComponent = (props) => { unsubscribeProcessing() }; - }, [activePaymentMethod, onCheckoutValidationBeforeProcessing, billing.billingData, item, companyNameString]); + }, [activePaymentMethod, onCheckoutValidation, billing.billingData, item, companyNameString]); - onSubmitLocal = onSubmit + useEffect(() => { + let phoneLabel = getPhoneField().labels[0]; + if (phoneLabel.length === 0) { + return + } + if (activePaymentMethod === 'mollie_wc_gateway_in3') { + phoneLabel.innerText = item.phonePlaceholder + } else { + if (phoneString !== false) { + phoneLabel.innerText = phoneString + } + } + let isPhoneEmpty = billing.billingData.phone === '' && shippingData.shippingAddress.phone === '' + let isBirthdateEmpty = inputBirthdate === '' + const unsubscribeProcessing = onCheckoutValidation( + () => { + if (activePaymentMethod === 'mollie_wc_gateway_in3' && (isPhoneEmpty || isBirthdateEmpty)) { + return { + errorMessage: item.errorMessage, + }; + } + } + ); + return () => { + unsubscribeProcessing() + }; + + }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate]); + + onSubmitLocal = onSubmit const updateIssuer = ( changeEvent ) => { selectIssuer( changeEvent.target.value ) }; + const updateCompany = ( changeEvent ) => { + selectCompany( changeEvent.target.value ) + }; + const updatePhone = ( changeEvent ) => { + selectPhone( changeEvent.target.value ) + } + const updateBirthdate = ( changeEvent ) => { + selectBirthdate( changeEvent.target.value ) + } if (item.issuers && item.name !== "mollie_wc_gateway_creditcard"){ return

{item.content}

} - return
+ function fieldMarkup(id, fieldType, label, action, value) { + return
+ } + if (item.name === "mollie_wc_gateway_billie"){ + if(!isFieldVisible(getCompanyField())) { + const companyField = item.companyPlaceholder ? item.companyPlaceholder : "Company name"; + return fieldMarkup("billing-company","text", companyField, updateCompany, inputCompany); + } + return; + } + + if (item.name === "mollie_wc_gateway_in3"){ + let fields = []; + const birthdateField = item.birthdatePlaceholder ? item.birthdatePlaceholder : "Birthdate"; + fields.push(fieldMarkup("billing-birthdate", "date", birthdateField, updateBirthdate, inputBirthdate)); + if (!isFieldVisible(getPhoneField())) { + const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; + fields.push(fieldMarkup("billing-phone", "phone", phoneField, updatePhone, inputPhone)); + } + return <>{fields}; + } + + return } -const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery, companyNameString) =>{ +const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery) =>{ let billingCountry = filters.billingCountry let cartTotal = filters.cartTotal cachedAvailableGateways = availableGateways let changedBillingCountry = filters.billingCountry - + let companyField = getCompanyField(); + const companyNameString = companyField && companyField.parentNode.querySelector('label') ? companyField.parentNode.querySelector('label').innerHTML : false; + let phoneField = getPhoneField(); + const phoneString = phoneField && phoneField.parentNode.querySelector('label') ? phoneField.parentNode.querySelector('label').innerHTML : false; + let requiredFields = { + 'companyNameString': companyNameString, + 'phoneString': phoneString, + } document.addEventListener('mollie_components_ready_to_submit', function () { onSubmitLocal() }) return { name: item.name, label:
, - content: , + content: , edit:
{item.edit}
, paymentMethodId: item.paymentMethodId, canMakePayment: ({cartTotals, billingData}) => { @@ -212,7 +309,6 @@ const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, available }, }) } - } if (!cachedAvailableGateways.hasOwnProperty(currentFilterKey)) { diff --git a/resources/js/mollieBlockIndex.js b/resources/js/mollieBlockIndex.js index 8342a1213..c9e4eb92a 100644 --- a/resources/js/mollieBlockIndex.js +++ b/resources/js/mollieBlockIndex.js @@ -11,28 +11,8 @@ import molliePaymentMethod from './blocks/molliePaymentMethod' const {useEffect} = wp.element; const isAppleSession = typeof window.ApplePaySession === "function" - function getCompanyField() - { - let shippingCompany = document.getElementById('shipping-company'); - let billingCompany = document.getElementById('billing-company'); - return shippingCompany ? shippingCompany : billingCompany; - } - - function isFieldVisible(field) - { - return field && field.style.display !== 'none'; - } - - let companyField = getCompanyField(); - let companyNameString = companyField && companyField.parentNode.querySelector("label[for='" + companyField.id + "']").innerHTML; gatewayData.forEach(item => { - let register = () => registerPaymentMethod(molliePaymentMethod(useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery, companyNameString)); - if (item.name === 'mollie_wc_gateway_billie') { - if (isFieldVisible(companyField)) { - register(); - } - return; - } + let register = () => registerPaymentMethod(molliePaymentMethod(useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery)); if (item.name === 'mollie_wc_gateway_applepay' ) { if (isAppleSession && window.ApplePaySession.canMakePayments()) { register(); diff --git a/src/Assets/AssetsModule.php b/src/Assets/AssetsModule.php index cfe0a3b5f..6247f50b3 100644 --- a/src/Assets/AssetsModule.php +++ b/src/Assets/AssetsModule.php @@ -488,6 +488,8 @@ protected function gatewayDataForWCBlocks(Data $dataService, array $gatewayInsta 'supports' => $this->gatewaySupportsFeatures($gateway->paymentMethod(), $isSepaEnabled), 'errorMessage' => $gateway->paymentMethod()->getProperty('errorMessage'), 'companyPlaceholder' => $gateway->paymentMethod()->getProperty('companyPlaceholder'), + 'phonePlaceholder' => $gateway->paymentMethod()->getProperty('phonePlaceholder'), + 'birthdatePlaceholder' => $gateway->paymentMethod()->getProperty('birthdatePlaceholder'), ]; } $dataToScript['gatewayData'] = $gatewayData; diff --git a/src/PaymentMethods/In3.php b/src/PaymentMethods/In3.php index 5bfeb4514..e70dffd83 100644 --- a/src/PaymentMethods/In3.php +++ b/src/PaymentMethods/In3.php @@ -22,6 +22,12 @@ public function getConfig(): array 'filtersOnBuild' => false, 'confirmationDelayed' => false, 'orderMandatory' => true, + 'errorMessage' => __( + 'Required field is empty. To proceed with In3 payment, phone and birthdate fields are required.', + 'mollie-payments-for-woocommerce' + ), + 'phonePlaceholder' => __('To proceed with In3, please enter your phone here.', 'mollie-payments-for-woocommerce'), + 'birthdatePlaceholder' => __('To proceed with In3, please enter your birthdate here.', 'mollie-payments-for-woocommerce'), ]; } From 4da72f2847ba2a33630b0c761d07e6284b481315 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 28 Jun 2023 17:29:23 +0200 Subject: [PATCH 03/41] Move required fields under gw in checkout --- resources/js/blocks/molliePaymentMethod.js | 2 +- resources/js/mollieBillie.js | 2 +- resources/js/mollieIn3.js | 8 +++---- resources/js/wooCheckoutFieldsUtility.js | 27 ++++++++++++---------- src/Payment/MollieOrder.php | 15 +++++------- src/PaymentMethods/In3.php | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 55635ce0c..beea214f3 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -228,7 +228,7 @@ const MollieComponent = (props) => { fields.push(fieldMarkup("billing-birthdate", "date", birthdateField, updateBirthdate, inputBirthdate)); if (!isFieldVisible(getPhoneField())) { const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; - fields.push(fieldMarkup("billing-phone", "phone", phoneField, updatePhone, inputPhone)); + fields.push(fieldMarkup("billing-phone", "tel", phoneField, updatePhone, inputPhone)); } return <>{fields}; diff --git a/resources/js/mollieBillie.js b/resources/js/mollieBillie.js index 59d4c78be..4a567292d 100644 --- a/resources/js/mollieBillie.js +++ b/resources/js/mollieBillie.js @@ -7,7 +7,7 @@ import {maybeRequireField, saveOriginalField} from "./wooCheckoutFieldsUtility"; let originalBillingCompanyField = saveOriginalField(inputCompanyName, {}); let companyFieldId = 'billing_company_field'; let companyField = jQuery('form[name="checkout"] p#billing_company_field'); - let positionCompanyField = 'form[name="checkout"] input[name="billing_last_name"]'; + let positionCompanyField = '#payment > ul > li.wc_payment_method.payment_method_mollie_wc_gateway_billie > div'; let companyMarkup = '

' + '

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

' let inputBirthName = 'billing_birthdate'; let originalBirth = saveOriginalField(inputBirthName, {}); let birthId = 'billing_birthdate_field'; let birthField = jQuery('form[name="checkout"] p#billing_birthdate_field'); - let positionBirthField = 'form[name="checkout"] input[name="billing_phone"]'; + let positionBirthField = '#payment > ul > li.wc_payment_method.payment_method_mollie_wc_gateway_in3 > div'; let birthMarkup = '

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

' jQuery(function () { diff --git a/resources/js/wooCheckoutFieldsUtility.js b/resources/js/wooCheckoutFieldsUtility.js index c8b030c19..d27cc1cc0 100644 --- a/resources/js/wooCheckoutFieldsUtility.js +++ b/resources/js/wooCheckoutFieldsUtility.js @@ -2,13 +2,10 @@ function usingGateway(gateway) { return jQuery('form[name="checkout"] input[name="payment_method"]:checked').val() === gateway; } -function showField(billingField, positionField, fieldMarkup) -{ - if ((billingField).length <= 0) { - jQuery(positionField) - .closest('p') - .after(fieldMarkup); - } +function showField(field, positionField, fieldMarkup) { + jQuery(positionField) + .find('p') + .after(fieldMarkup); } function requireField(inputName, fieldId) { @@ -54,14 +51,20 @@ export function saveOriginalField(inputName, originalField) originalField = { isVisible, isRequired }; return originalField; } -export function maybeRequireField(billingField, positionField, fieldMarkup, inputName, fieldId, originalField, gateway) +export function maybeRequireField(field, positionField, fieldMarkup, inputName, fieldId, originalField, gateway) { if (usingGateway(gateway)) { - showField(billingField, positionField, fieldMarkup); - requireField(inputName, fieldId); - return jQuery('form[name="checkout"] p#' + fieldId); + if (!originalField.isVisible) { + showField(field, positionField, fieldMarkup); + requireField(inputName, fieldId); + return jQuery('form[name="checkout"] p#' + fieldId); + } + if (!originalField.isRequired) { + requireField(inputName, fieldId); + return jQuery('form[name="checkout"] p#' + fieldId); + } } else { - restoreOriginalField(billingField, positionField, fieldMarkup, inputName, fieldId, originalField); + restoreOriginalField(field, positionField, fieldMarkup, inputName, fieldId, originalField); return false; } } diff --git a/src/Payment/MollieOrder.php b/src/Payment/MollieOrder.php index 26d092cfb..5832c0e18 100644 --- a/src/Payment/MollieOrder.php +++ b/src/Payment/MollieOrder.php @@ -944,9 +944,10 @@ protected function createBillingAddress($order) self::MAXIMAL_LENGHT_REGION ); $billingAddress->organizationName = $this->billingCompanyField($order); - $billingAddress->phone = (ctype_space($order->get_billing_phone())) + $phone = !empty($order->get_billing_phone())? $order->get_billing_phone() : $order->get_shipping_phone(); + $billingAddress->phone = (ctype_space($phone)) ? null - : $this->getFormatedPhoneNumber($order->get_billing_phone()); + : $this->getFormatedPhoneNumber($phone); return $billingAddress; } @@ -1190,16 +1191,12 @@ protected function getCustomerBirthdate($order) } $methodId = $gateway->id === 'mollie_wc_gateway_in3'; if ($methodId) { - $fieldPosted = filter_input(INPUT_POST, 'billing_birthdate', FILTER_SANITIZE_SPECIAL_CHARS) ?? false; - if (!$fieldPosted) { + $fieldPosted = wc_clean(wp_unslash($_POST["billing_birthdate"] ?? '')); + if ($fieldPosted === '' || !is_string($fieldPosted)) { return null; } $format = "Y-m-d"; - $pattern = "/(\d{1,2})[\s,\/-]+(\d{1,2})[\s,\/-]+(\d{4})/"; - if (preg_match($pattern, $fieldPosted, $matches)) { - $date = $matches[3] . "-" . $matches[2] . "-" . $matches[1]; - return date($format, strtotime($date)); - } + return date($format, (int) strtotime($fieldPosted)); } return null; } diff --git a/src/PaymentMethods/In3.php b/src/PaymentMethods/In3.php index e70dffd83..92952e91d 100644 --- a/src/PaymentMethods/In3.php +++ b/src/PaymentMethods/In3.php @@ -26,7 +26,7 @@ public function getConfig(): array 'Required field is empty. To proceed with In3 payment, phone and birthdate fields are required.', 'mollie-payments-for-woocommerce' ), - 'phonePlaceholder' => __('To proceed with In3, please enter your phone here.', 'mollie-payments-for-woocommerce'), + 'phonePlaceholder' => __('To proceed with In3, please enter your phone here. +00 00000000', 'mollie-payments-for-woocommerce'), 'birthdatePlaceholder' => __('To proceed with In3, please enter your birthdate here.', 'mollie-payments-for-woocommerce'), ]; } From 3698f91228a4db2f0d8f9fb6da20bdc27927dcaa Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 08:53:06 +0200 Subject: [PATCH 04/41] Fix cs --- src/Payment/MollieOrder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Payment/MollieOrder.php b/src/Payment/MollieOrder.php index 5832c0e18..0a23ea0d2 100644 --- a/src/Payment/MollieOrder.php +++ b/src/Payment/MollieOrder.php @@ -944,7 +944,7 @@ protected function createBillingAddress($order) self::MAXIMAL_LENGHT_REGION ); $billingAddress->organizationName = $this->billingCompanyField($order); - $phone = !empty($order->get_billing_phone())? $order->get_billing_phone() : $order->get_shipping_phone(); + $phone = !empty($order->get_billing_phone()) ? $order->get_billing_phone() : $order->get_shipping_phone(); $billingAddress->phone = (ctype_space($phone)) ? null : $this->getFormatedPhoneNumber($phone); From d41dd2c26b821edffc2f56d86f063abc502bb9f1 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 08:56:21 +0200 Subject: [PATCH 05/41] Update composer and add php8 to grid --- .ddev/config.yaml | 143 +++++++++++++++------ .github/workflows/ci.yml | 2 +- composer.lock | 269 +++++++++++---------------------------- 3 files changed, 179 insertions(+), 235 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 16f0f8802..d679225e5 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -1,36 +1,37 @@ name: mollie-payments-for-woocommerce -type: php +type: wordpress docroot: .ddev/wordpress -php_version: "7.4" +php_version: "7.2" webserver_type: nginx-fpm router_http_port: "80" router_https_port: "443" xdebug_enabled: false additional_hostnames: [] additional_fqdns: [] -mariadb_version: "10.3" -mysql_version: "" +database: + type: mariadb + version: "10.3" nfs_mount_enabled: false mutagen_enabled: false -use_dns_when_possible: true -composer_version: "2" hooks: + post-start: + - exec-host: .ddev/bin/dump-compose-config + - exec-host: ddev describe -j | SOURCE_NAME=$DDEV_PROJECT .ddev/bin/setup-ide-datasource.php pre-start: - - exec-host: "mkdir -p .ddev/wordpress/wp-content/plugins/${DDEV_PROJECT}" + - exec-host: mkdir -p .ddev/wordpress/wp-content/plugins/${DDEV_PROJECT} +use_dns_when_possible: true +composer_version: "2" web_environment: - - WP_VERSION=6.1 - - WP_LOCALE=en_US - - WP_TITLE=Mollie WordPress Test - - PLUGIN_NAME=mollie-payments-for-woocommerce - - ADMIN_USER=admin - - ADMIN_PASS=admin - - ADMIN_EMAIL=admin@example.com - - WC_VERSION=7.2.2 - -hooks: - post-start: - - exec-host: ".ddev/bin/dump-compose-config" - - exec-host: "ddev describe -j | SOURCE_NAME=$DDEV_PROJECT .ddev/bin/setup-ide-datasource.php" +- BASEURL=https://fd8d-88-17-29-100.ngrok-free.app +- ' WP_VERSION=6.1' +- ' WP_LOCALE=en_US' +- ' WP_TITLE=Mollie WordPress Test' +- ' PLUGIN_NAME=mollie-payments-for-woocommerce' +- ' ADMIN_USER=admin' +- ' ADMIN_PASS=admin' +- ' ADMIN_EMAIL=admin@example.com' +- ' WC_VERSION=7.2.2' +nodejs_version: "16" # Key features of ddev's config.yaml: @@ -41,21 +42,19 @@ hooks: # docroot: # Relative path to the directory containing index.php. -# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1" +# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" -# You can explicitly specify the webimage, dbimage, dbaimage lines but this +# You can explicitly specify the webimage but this # is not recommended, as the images are often closely tied to ddev's' behavior, # so this can break upgrades. # webimage: # nginx/php docker image. -# dbimage: # mariadb docker image. -# dbaimage: -# mariadb_version and mysql_version -# ddev can use many versions of mariadb and mysql -# However these directives are mutually exclusive -# mariadb_version: 10.2 -# mysql_version: 8.0 +# database: +# type: # mysql, mariadb +# version: # database version, like "10.3" or "8.0" +# Note that mariadb_version or mysql_version from v1.18 and earlier +# will automatically be converted to this notation with just a "ddev config --auto" # router_http_port: # Port to be used for http (defaults to port 80) # router_https_port: # Port for https (defaults to 443) @@ -78,12 +77,26 @@ hooks: # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # For example Europe/Dublin or MST7MDT +# composer_root: +# Relative path to the composer root directory from the project root. This is +# the directory which contains the composer.json and where all Composer related +# commands are executed. + # composer_version: "2" -# if composer_version:"2" it will use the most recent composer v2 -# It can also be set to "1", to get most recent composer v1 -# or "" for the default v2 created at release time. -# It can be set to any existing specific composer version. -# After first project 'ddev start' this will not be updated until it changes +# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1 +# to use the latest major version available at the time your container is built. +# It is also possible to use each other Composer version channel. This includes: +# - 2.2 (latest Composer LTS version) +# - stable +# - preview +# - snapshot +# Alternatively, an explicit Composer version may be specified, for example "2.2.18". +# To reinstall Composer after the image was built, run "ddev debug refresh". + +# nodejs_version: "16" +# change from the default system Node.js version to another supported version, like 12, 14, 17, 18. +# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any +# Node.js version, including v6, etc. # additional_hostnames: # - somename @@ -99,6 +112,8 @@ hooks: # upload_dir: custom/upload/dir # would set the destination path for ddev import-files to /custom/upload/dir +# When mutagen is enabled this path is bind-mounted so that all the files +# in the upload_dir don't have to be synced into mutagen # working_dir: # web: /var/www/html @@ -116,11 +131,11 @@ hooks: # nfs_mount_enabled: false # Great performance improvement but requires host configuration first. -# See https://ddev.readthedocs.io/en/stable/users/performance/#using-nfs-to-mount-the-project-into-the-container +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs # mutagen_enabled: false -# Experimental performance improvement using mutagen asynchronous updates. -# See https://ddev.readthedocs.io/en/latest/users/performance/#using-mutagen +# Performance improvement using mutagen asynchronous updates. +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen # fail_on_hook_fail: False # Decide whether 'ddev start' should be interrupted by a failing hook @@ -175,7 +190,7 @@ hooks: # If you prefer you can change this to "ddev.local" to preserve # pre-v1.9 behavior. -# ngrok_args: --subdomain mysite --auth username:pass +# ngrok_args: --basic-auth username:pass1234 # Provide extra flags to the "ngrok http" command, see # https://ngrok.com/docs#http or run "ngrok http -h" @@ -201,10 +216,60 @@ hooks: # will be available on the local network if the host firewall # allows it. +# default_container_timeout: 120 +# The default time that ddev waits for all containers to become ready can be increased from +# the default 120. This helps in importing huge databases, for example. + +#web_extra_exposed_ports: +#- name: nodejs +# container_port: 3000 +# http_port: 2999 +# https_port: 3000 +#- name: something +# container_port: 4000 +# https_port: 4000 +# http_port: 3999 +# Allows a set of extra ports to be exposed via ddev-router +# The port behavior on the ddev-webserver must be arranged separately, for example +# using web_extra_daemons. +# For example, with a web app on port 3000 inside the container, this config would +# expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 +# web_extra_exposed_ports: +# - container_port: 3000 +# http_port: 9998 +# https_port: 9999 + +#web_extra_daemons: +#- name: "http-1" +# command: "/var/www/html/node_modules/.bin/http-server -p 3000" +# directory: /var/www/html +#- name: "http-2" +# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000" +# directory: /var/www/html + +# override_config: false +# By default, config.*.yaml files are *merged* into the configuration +# But this means that some things can't be overridden +# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge +# and you can't erase existing hooks or all environment variables. +# However, with "override_config: true" in a particular config.*.yaml file, +# 'nfs_mount_enabled: false' can override the existing values, and +# hooks: +# post-start: [] +# or +# web_environment: [] +# or +# additional_hostnames: [] +# can have their intended affect. 'override_config' affects only behavior of the +# config.*.yaml file it exists in. + # Many ddev commands can be extended to run tasks before or after the # ddev command is executed, for example "post-start", "post-import-db", # "pre-composer", "post-composer" -# See https://ddev.readthedocs.io/en/stable/users/extending-commands/ for more +# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more # information on the commands that can be extended and the tasks you can define # for them. Example: #hooks: +# Un-comment to emit the WP CLI version after ddev start. +# post-start: +# - exec: wp cli version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 348be82bd..017d51cab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.2', '7.3', '7.4', '8.0'] name: PHP ${{ matrix.php-versions }} steps: diff --git a/composer.lock b/composer.lock index 50473fcf4..6364ce4bf 100644 --- a/composer.lock +++ b/composer.lock @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "232808b3c65f244189bea949db2455840b2e719c" + "reference": "90d087e988ff194065333d16bc5cf649872d9cdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/232808b3c65f244189bea949db2455840b2e719c", - "reference": "232808b3c65f244189bea949db2455840b2e719c", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/90d087e988ff194065333d16bc5cf649872d9cdb", + "reference": "90d087e988ff194065333d16bc5cf649872d9cdb", "shasum": "" }, "require": { @@ -65,7 +65,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/main" + "source": "https://github.com/composer/ca-bundle/tree/1.3.6" }, "funding": [ { @@ -81,7 +81,7 @@ "type": "tidelift" } ], - "time": "2023-05-01T20:58:12+00:00" + "time": "2023-06-06T12:02:59+00:00" }, { "name": "inpsyde/modularity", @@ -158,16 +158,16 @@ }, { "name": "mollie/mollie-api-php", - "version": "v2.56.0", + "version": "v2.58.0-beta", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "a14c294cfefbe91cc14a59809032fc95ee994645" + "reference": "4940ecd1d57ddea6b1ce7ebd98df63e54834aebb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/a14c294cfefbe91cc14a59809032fc95ee994645", - "reference": "a14c294cfefbe91cc14a59809032fc95ee994645", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/4940ecd1d57ddea6b1ce7ebd98df63e54834aebb", + "reference": "4940ecd1d57ddea6b1ce7ebd98df63e54834aebb", "shasum": "" }, "require": { @@ -244,9 +244,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.56.0" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.58.0-beta" }, - "time": "2023-05-30T13:11:03+00:00" + "time": "2023-06-23T09:10:23+00:00" }, { "name": "psr/container", @@ -813,31 +813,30 @@ }, { "name": "composer/pcre", - "version": "dev-main", + "version": "2.x-dev", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717", + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^1.3", "phpstan/phpstan-strict-rules": "^1.1", "symfony/phpunit-bridge": "^5" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.x-dev" + "dev-main": "2.x-dev" } }, "autoload": { @@ -865,7 +864,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/2.x" }, "funding": [ { @@ -881,7 +880,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2022-11-16T18:32:04+00:00" }, { "name": "composer/semver", @@ -1143,49 +1142,6 @@ }, "time": "2019-12-04T15:06:13+00:00" }, - { - "name": "doctrine/deprecations", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "8cffffb2218e01f3b370bf763e00e81697725259" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/8cffffb2218e01f3b370bf763e00e81697725259", - "reference": "8cffffb2218e01f3b370bf763e00e81697725259", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.0" - }, - "time": "2023-05-29T18:55:17+00:00" - }, { "name": "doctrine/instantiator", "version": "1.5.x-dev", @@ -1585,34 +1541,30 @@ }, { "name": "mockery/mockery", - "version": "dev-master", + "version": "1.3.x-dev", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "612a8f9839a296edd9e2c23334f39c2fd8457ee0" + "reference": "dc206df4fa314a50bbb81cf72239a305c5bbd5c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/612a8f9839a296edd9e2c23334f39c2fd8457ee0", - "reference": "612a8f9839a296edd9e2c23334f39c2fd8457ee0", + "url": "https://api.github.com/repos/mockery/mockery/zipball/dc206df4fa314a50bbb81cf72239a305c5bbd5c0", + "reference": "dc206df4fa314a50bbb81cf72239a305c5bbd5c0", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": "^7.3 || ^8.0" - }, - "conflict": { - "phpunit/phpunit": "<8.0" + "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3" + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -1652,9 +1604,9 @@ ], "support": { "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/master" + "source": "https://github.com/mockery/mockery/tree/1.3" }, - "time": "2023-05-09T15:00:16+00:00" + "time": "2022-09-07T15:05:49+00:00" }, { "name": "myclabs/deep-copy", @@ -1774,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -1821,9 +1773,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/4.x" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2023-05-21T19:22:47+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "openlss/lib-array2xml", @@ -1880,27 +1832,25 @@ }, { "name": "phar-io/manifest", - "version": "dev-master", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138" + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/36d8a21e851a9512db2b086dc5ac2c61308f0138", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { "ext-dom": "*", - "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", "php": "^7.2 || ^8.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1936,15 +1886,9 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/master" + "source": "https://github.com/phar-io/manifest/tree/2.0.3" }, - "funding": [ - { - "url": "https://github.com/theseer", - "type": "github" - } - ], - "time": "2022-02-21T19:55:33+00:00" + "time": "2021-07-20T11:28:43+00:00" }, { "name": "phar-io/version", @@ -2203,36 +2147,29 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "dev-master", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/7b217217725dc991a0ae7b995041cee1d5019561", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { "ext-filter": "*", "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "1.x-dev@dev", - "phpstan/phpdoc-parser": "^1.7", + "phpdocumentor/type-resolver": "^1.3", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.5", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.26" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2261,41 +2198,32 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" }, - "time": "2023-03-12T10:50:44+00:00" + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.x-dev", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" + "reference": "77a32518733312af16a44300404e945338981de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", + "reference": "77a32518733312af16a44300404e945338981de3", "shasum": "" }, "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.13" + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" + "psalm/phar": "^4.8" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2320,57 +2248,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" - }, - "time": "2023-05-30T18:13:47+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "1.22.x-dev", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7", - "reference": "97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "symfony/process": "^5.2" - }, - "default-branch": true, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.x" - }, - "time": "2023-05-30T21:18:52+00:00" + "time": "2022-03-15T21:29:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2611,30 +2491,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "dev-master", + "version": "3.1.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "76fc0567751d177847112bd3e26e4890529c98da" + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/76fc0567751d177847112bd3e26e4890529c98da", - "reference": "76fc0567751d177847112bd3e26e4890529c98da", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.3 || ^8.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^7.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -2659,7 +2538,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1" }, "funding": [ { @@ -2668,7 +2547,7 @@ } ], "abandoned": true, - "time": "2020-08-06T06:03:05+00:00" + "time": "2021-07-26T12:15:06+00:00" }, { "name": "phpunit/phpunit", @@ -2676,12 +2555,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f7e7556c4089d14f9b0d2887350db35071438bf9" + "reference": "c8bf4ddc3ee3263c2f77477cbd1849832f34f473" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f7e7556c4089d14f9b0d2887350db35071438bf9", - "reference": "f7e7556c4089d14f9b0d2887350db35071438bf9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c8bf4ddc3ee3263c2f77477cbd1849832f34f473", + "reference": "c8bf4ddc3ee3263c2f77477cbd1849832f34f473", "shasum": "" }, "require": { @@ -2766,7 +2645,7 @@ "type": "tidelift" } ], - "time": "2023-05-28T06:55:25+00:00" + "time": "2023-06-28T05:06:28+00:00" }, { "name": "ptrofimov/xpmock", @@ -4400,12 +4279,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62" + "reference": "1181fe9270e373537475e826873b5867b863883c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", + "url": "https://api.github.com/repos/symfony/string/zipball/1181fe9270e373537475e826873b5867b863883c", + "reference": "1181fe9270e373537475e826873b5867b863883c", "shasum": "" }, "require": { @@ -4478,7 +4357,7 @@ "type": "tidelift" } ], - "time": "2023-03-14T06:11:53+00:00" + "time": "2023-06-28T12:46:07+00:00" }, { "name": "theseer/tokenizer", From f46f7591496eccf95853c6341804427488afce65 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 09:18:57 +0200 Subject: [PATCH 06/41] Fix cs --- src/Payment/MollieOrder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Payment/MollieOrder.php b/src/Payment/MollieOrder.php index 0a23ea0d2..126384105 100644 --- a/src/Payment/MollieOrder.php +++ b/src/Payment/MollieOrder.php @@ -1191,6 +1191,7 @@ protected function getCustomerBirthdate($order) } $methodId = $gateway->id === 'mollie_wc_gateway_in3'; if ($methodId) { + //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $fieldPosted = wc_clean(wp_unslash($_POST["billing_birthdate"] ?? '')); if ($fieldPosted === '' || !is_string($fieldPosted)) { return null; From 4c44d14f7de34149d54db6ab94170c16276d733e Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 09:26:43 +0200 Subject: [PATCH 07/41] Update psalm for php 8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 633f64355..9336d23c3 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "inpsyde/php-coding-standards": "^1.0.0", "php-stubs/wordpress-stubs": "^5.0@stable", "php-stubs/woocommerce-stubs": "^5.0@stable", - "vimeo/psalm": "^4.8" + "vimeo/psalm": "^4.8 || ^5.13.0" }, "autoload": { "psr-4": { From a8e9705e3526edbf7970c628bdce3ca45c1235c8 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 09:28:41 +0200 Subject: [PATCH 08/41] Update composer lock --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 6364ce4bf..28c3c95dd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "09ea901d61c355303e89097f52cf5861", + "content-hash": "cea1ff9bf85bcfc84018e2cbe6806299", "packages": [ { "name": "composer/ca-bundle", From 786f8349590896c9ce7a120949576a6494c496fc Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 17:13:52 +0200 Subject: [PATCH 09/41] Fix update surcharge fee handling --- src/Shared/GatewaySurchargeHandler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Shared/GatewaySurchargeHandler.php b/src/Shared/GatewaySurchargeHandler.php index 93e498bbb..d4e467ffa 100644 --- a/src/Shared/GatewaySurchargeHandler.php +++ b/src/Shared/GatewaySurchargeHandler.php @@ -99,7 +99,7 @@ public function updateSurchargeOrderPay() } $this->orderRemoveFee($order); $gatewaySettings = $this->gatewaySettings($gatewayName); - $orderAmount = $order->get_total(); + $orderAmount = (float) $order->get_total(); if ($this->surcharge->aboveMaxLimit($orderAmount, $gatewaySettings)) { return; } @@ -283,7 +283,12 @@ protected function canProcessOrder() protected function canProcessGateway() { - $postedMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS); + // phpcs:ignore WordPress.Security.NonceVerification + if (!isset($_POST['method'])) { + return false; + } + // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + $postedMethod = wc_clean(wp_unslash($_POST['method'])); $gateway = !empty($postedMethod) ? $postedMethod : false; if (!$gateway) { return false; From f06f1b783321069f39e6b00459b2f442345d4c7d Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 29 Jun 2023 17:16:42 +0200 Subject: [PATCH 10/41] composer update with php7.2 --- composer.lock | 269 ++++++++++++++------------------------------------ 1 file changed, 74 insertions(+), 195 deletions(-) diff --git a/composer.lock b/composer.lock index 50473fcf4..6364ce4bf 100644 --- a/composer.lock +++ b/composer.lock @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "232808b3c65f244189bea949db2455840b2e719c" + "reference": "90d087e988ff194065333d16bc5cf649872d9cdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/232808b3c65f244189bea949db2455840b2e719c", - "reference": "232808b3c65f244189bea949db2455840b2e719c", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/90d087e988ff194065333d16bc5cf649872d9cdb", + "reference": "90d087e988ff194065333d16bc5cf649872d9cdb", "shasum": "" }, "require": { @@ -65,7 +65,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/main" + "source": "https://github.com/composer/ca-bundle/tree/1.3.6" }, "funding": [ { @@ -81,7 +81,7 @@ "type": "tidelift" } ], - "time": "2023-05-01T20:58:12+00:00" + "time": "2023-06-06T12:02:59+00:00" }, { "name": "inpsyde/modularity", @@ -158,16 +158,16 @@ }, { "name": "mollie/mollie-api-php", - "version": "v2.56.0", + "version": "v2.58.0-beta", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "a14c294cfefbe91cc14a59809032fc95ee994645" + "reference": "4940ecd1d57ddea6b1ce7ebd98df63e54834aebb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/a14c294cfefbe91cc14a59809032fc95ee994645", - "reference": "a14c294cfefbe91cc14a59809032fc95ee994645", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/4940ecd1d57ddea6b1ce7ebd98df63e54834aebb", + "reference": "4940ecd1d57ddea6b1ce7ebd98df63e54834aebb", "shasum": "" }, "require": { @@ -244,9 +244,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.56.0" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.58.0-beta" }, - "time": "2023-05-30T13:11:03+00:00" + "time": "2023-06-23T09:10:23+00:00" }, { "name": "psr/container", @@ -813,31 +813,30 @@ }, { "name": "composer/pcre", - "version": "dev-main", + "version": "2.x-dev", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717", + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^1.3", "phpstan/phpstan-strict-rules": "^1.1", "symfony/phpunit-bridge": "^5" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.x-dev" + "dev-main": "2.x-dev" } }, "autoload": { @@ -865,7 +864,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/2.x" }, "funding": [ { @@ -881,7 +880,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2022-11-16T18:32:04+00:00" }, { "name": "composer/semver", @@ -1143,49 +1142,6 @@ }, "time": "2019-12-04T15:06:13+00:00" }, - { - "name": "doctrine/deprecations", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "8cffffb2218e01f3b370bf763e00e81697725259" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/8cffffb2218e01f3b370bf763e00e81697725259", - "reference": "8cffffb2218e01f3b370bf763e00e81697725259", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.0" - }, - "time": "2023-05-29T18:55:17+00:00" - }, { "name": "doctrine/instantiator", "version": "1.5.x-dev", @@ -1585,34 +1541,30 @@ }, { "name": "mockery/mockery", - "version": "dev-master", + "version": "1.3.x-dev", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "612a8f9839a296edd9e2c23334f39c2fd8457ee0" + "reference": "dc206df4fa314a50bbb81cf72239a305c5bbd5c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/612a8f9839a296edd9e2c23334f39c2fd8457ee0", - "reference": "612a8f9839a296edd9e2c23334f39c2fd8457ee0", + "url": "https://api.github.com/repos/mockery/mockery/zipball/dc206df4fa314a50bbb81cf72239a305c5bbd5c0", + "reference": "dc206df4fa314a50bbb81cf72239a305c5bbd5c0", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": "^7.3 || ^8.0" - }, - "conflict": { - "phpunit/phpunit": "<8.0" + "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3" + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -1652,9 +1604,9 @@ ], "support": { "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/master" + "source": "https://github.com/mockery/mockery/tree/1.3" }, - "time": "2023-05-09T15:00:16+00:00" + "time": "2022-09-07T15:05:49+00:00" }, { "name": "myclabs/deep-copy", @@ -1774,12 +1726,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -1821,9 +1773,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/4.x" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2023-05-21T19:22:47+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "openlss/lib-array2xml", @@ -1880,27 +1832,25 @@ }, { "name": "phar-io/manifest", - "version": "dev-master", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138" + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/36d8a21e851a9512db2b086dc5ac2c61308f0138", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { "ext-dom": "*", - "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", "php": "^7.2 || ^8.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1936,15 +1886,9 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/master" + "source": "https://github.com/phar-io/manifest/tree/2.0.3" }, - "funding": [ - { - "url": "https://github.com/theseer", - "type": "github" - } - ], - "time": "2022-02-21T19:55:33+00:00" + "time": "2021-07-20T11:28:43+00:00" }, { "name": "phar-io/version", @@ -2203,36 +2147,29 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "dev-master", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/7b217217725dc991a0ae7b995041cee1d5019561", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { "ext-filter": "*", "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "1.x-dev@dev", - "phpstan/phpdoc-parser": "^1.7", + "phpdocumentor/type-resolver": "^1.3", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.5", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.26" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2261,41 +2198,32 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" }, - "time": "2023-03-12T10:50:44+00:00" + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.x-dev", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" + "reference": "77a32518733312af16a44300404e945338981de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", + "reference": "77a32518733312af16a44300404e945338981de3", "shasum": "" }, "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.13" + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" + "psalm/phar": "^4.8" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2320,57 +2248,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" - }, - "time": "2023-05-30T18:13:47+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "1.22.x-dev", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7", - "reference": "97abd8a24ee5154b2cdc0de1ea0ac27e6541f0c7", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "symfony/process": "^5.2" - }, - "default-branch": true, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.x" - }, - "time": "2023-05-30T21:18:52+00:00" + "time": "2022-03-15T21:29:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2611,30 +2491,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "dev-master", + "version": "3.1.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "76fc0567751d177847112bd3e26e4890529c98da" + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/76fc0567751d177847112bd3e26e4890529c98da", - "reference": "76fc0567751d177847112bd3e26e4890529c98da", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", + "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.3 || ^8.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^7.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -2659,7 +2538,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1" }, "funding": [ { @@ -2668,7 +2547,7 @@ } ], "abandoned": true, - "time": "2020-08-06T06:03:05+00:00" + "time": "2021-07-26T12:15:06+00:00" }, { "name": "phpunit/phpunit", @@ -2676,12 +2555,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f7e7556c4089d14f9b0d2887350db35071438bf9" + "reference": "c8bf4ddc3ee3263c2f77477cbd1849832f34f473" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f7e7556c4089d14f9b0d2887350db35071438bf9", - "reference": "f7e7556c4089d14f9b0d2887350db35071438bf9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c8bf4ddc3ee3263c2f77477cbd1849832f34f473", + "reference": "c8bf4ddc3ee3263c2f77477cbd1849832f34f473", "shasum": "" }, "require": { @@ -2766,7 +2645,7 @@ "type": "tidelift" } ], - "time": "2023-05-28T06:55:25+00:00" + "time": "2023-06-28T05:06:28+00:00" }, { "name": "ptrofimov/xpmock", @@ -4400,12 +4279,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62" + "reference": "1181fe9270e373537475e826873b5867b863883c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", + "url": "https://api.github.com/repos/symfony/string/zipball/1181fe9270e373537475e826873b5867b863883c", + "reference": "1181fe9270e373537475e826873b5867b863883c", "shasum": "" }, "require": { @@ -4478,7 +4357,7 @@ "type": "tidelift" } ], - "time": "2023-03-14T06:11:53+00:00" + "time": "2023-06-28T12:46:07+00:00" }, { "name": "theseer/tokenizer", From 7f01e8f791c6cf0a5dc100590aa6daffa89e6fd3 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Sat, 1 Jul 2023 12:59:54 +0200 Subject: [PATCH 11/41] Ignore default title to get api one --- src/PaymentMethods/AbstractPaymentMethod.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/PaymentMethods/AbstractPaymentMethod.php b/src/PaymentMethods/AbstractPaymentMethod.php index b17fa84e3..6ed8880e4 100644 --- a/src/PaymentMethods/AbstractPaymentMethod.php +++ b/src/PaymentMethods/AbstractPaymentMethod.php @@ -65,16 +65,10 @@ public function __construct( public function title(): string { - $titleIsDefault = $this->titleIsDefault(); $useApiTitle = $this->getProperty(SharedDataDictionary::USE_API_TITLE) === 'yes'; - if ($titleIsDefault && $useApiTitle === false) { - $this->updateMethodOption(SharedDataDictionary::USE_API_TITLE, 'yes'); - $useApiTitle = true; - } - $title = $this->getProperty('title'); - //new installations or installations that saved the default one should use the api title - if ($useApiTitle || $title === false || $titleIsDefault) { + //new installations should use the api title + if ($useApiTitle || $title === false) { return $this->getApiTitle(); } return $title; From 2c8daeef8244c85897cde94cc22d53e3db87aaa7 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Sun, 2 Jul 2023 10:21:07 +0200 Subject: [PATCH 12/41] Save new mandate data in subscription order --- src/Payment/MollieObject.php | 20 +++++++++++++++++++- src/Payment/PaymentService.php | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Payment/MollieObject.php b/src/Payment/MollieObject.php index 5ea1bde11..8cc3641c9 100644 --- a/src/Payment/MollieObject.php +++ b/src/Payment/MollieObject.php @@ -580,13 +580,31 @@ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder( $payment->mandateId ); $order->save(); + $subscriptions = wcs_get_subscriptions_for_renewal_order($order->get_id()); + $subscription = array_pop($subscriptions); + if (!$subscription) { + return; + } + $subscription->update_meta_data( + '_mollie_payment_id', + $payment->id + ); + $subscription->save(); + $subcriptionParentOrder = $subscription->get_parent(); + if ($subcriptionParentOrder) { + $subcriptionParentOrder->update_meta_data( + '_mollie_mandate_id', + $payment->mandateId + ); + $subcriptionParentOrder->save(); + } } } } protected function addSequenceTypeForSubscriptionsFirstPayments($orderId, $gateway, $paymentRequestData): array { - if ($this->dataHelper->isSubscription($orderId)) { + if ($this->dataHelper->isSubscription($orderId) || $this->dataHelper->isWcSubscription($orderId)) { $disable_automatic_payments = apply_filters($this->pluginId . '_is_automatic_payment_disabled', false); $supports_subscriptions = $gateway->supports('subscriptions'); diff --git a/src/Payment/PaymentService.php b/src/Payment/PaymentService.php index 94a2eaefa..9fd2e2099 100644 --- a/src/Payment/PaymentService.php +++ b/src/Payment/PaymentService.php @@ -740,6 +740,10 @@ protected function saveSubscriptionMandateData( $dataHelper = $this->dataHelper; if ($dataHelper->isSubscription($orderId)) { $mandates = $this->apiHelper->getApiClient($apiKey)->customers->get($customerId)->mandates(); + if (!isset($mandates[0])) { + return; + } + // madates are sorted by date, so the first one is the newest $mandate = $mandates[0]; $customerId = $mandate->customerId; $mandateId = $mandate->id; From 5f62fcf357acc8219da64d6e720e4e385b5a09de Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 10:54:47 +0200 Subject: [PATCH 13/41] Refactor get phone field --- resources/js/blocks/molliePaymentMethod.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index beea214f3..a9d0de9c9 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -13,9 +13,9 @@ function getCompanyField() function getPhoneField() { - let shippingPhone = document.getElementById('shipping-phone'); - let billingPhone = document.getElementById('billing-phone'); - return billingPhone ? billingPhone : shippingPhone; + const shippingPhone = document.getElementById('shipping-phone'); + const billingPhone = document.getElementById('billing-phone'); + return billingPhone || shippingPhone; } const MollieComponent = (props) => { From c65c057d24fb3c5f537e5c60a573fef6a0c6f60f Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 10:55:02 +0200 Subject: [PATCH 14/41] Revert config changes --- .ddev/config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index d679225e5..a83f4050e 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -23,14 +23,14 @@ use_dns_when_possible: true composer_version: "2" web_environment: - BASEURL=https://fd8d-88-17-29-100.ngrok-free.app -- ' WP_VERSION=6.1' -- ' WP_LOCALE=en_US' -- ' WP_TITLE=Mollie WordPress Test' -- ' PLUGIN_NAME=mollie-payments-for-woocommerce' -- ' ADMIN_USER=admin' -- ' ADMIN_PASS=admin' -- ' ADMIN_EMAIL=admin@example.com' -- ' WC_VERSION=7.2.2' +- WP_VERSION=6.1 +- WP_LOCALE=en_US +- WP_TITLE=Mollie WordPress Test +- PLUGIN_NAME=mollie-payments-for-woocommerce +- ADMIN_USER=admin +- ADMIN_PASS=admin +- ADMIN_EMAIL=admin@example.com +- WC_VERSION=7.2.2 nodejs_version: "16" # Key features of ddev's config.yaml: From f41c4525814c37eec4da9bfd6d049cc8e6c383a2 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 10:58:48 +0200 Subject: [PATCH 15/41] Update CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 017d51cab..034247daa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,10 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate + - name: Upgrade Dependencies + run: composer require --dev -W brianium/paratest:^6 + if: ${{ matrix.php-versions == '8.0' || matrix.php-versions == '8.1' }} + - name: install dependencies run: composer install --no-interaction --optimize-autoloader From dce486700e1fa9b00b32d2f9fe6a829221a9ee35 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 11:03:45 +0200 Subject: [PATCH 16/41] Update CI with correct package --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 034247daa..1024eb6b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: composer validate - name: Upgrade Dependencies - run: composer require --dev -W brianium/paratest:^6 + run: composer require --dev vimeo/psalm:^5.13 if: ${{ matrix.php-versions == '8.0' || matrix.php-versions == '8.1' }} - name: install dependencies From 4a5f021d6e61c5d3bf9e2fe547a612efc3f3cba9 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 11:31:09 +0200 Subject: [PATCH 17/41] Update CI with param --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1024eb6b0..5332f5b44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: composer validate - name: Upgrade Dependencies - run: composer require --dev vimeo/psalm:^5.13 + run: composer require --dev -W vimeo/psalm:^5.13 if: ${{ matrix.php-versions == '8.0' || matrix.php-versions == '8.1' }} - name: install dependencies From 077cc5d370bb738dbc4134b4a26e97e2efbb4ed6 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 4 Jul 2023 11:43:46 +0200 Subject: [PATCH 18/41] Use composer update in CI --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5332f5b44..034311fe3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,12 +24,8 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate - - name: Upgrade Dependencies - run: composer require --dev -W vimeo/psalm:^5.13 - if: ${{ matrix.php-versions == '8.0' || matrix.php-versions == '8.1' }} - - name: install dependencies - run: composer install --no-interaction --optimize-autoloader + run: composer update --prefer-dist --no-progress - name: dump autoload run: composer dump-autoload From 56d5734a3628887ed5070a9b9e50c32ca1da950f Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 6 Jul 2023 11:10:29 +0200 Subject: [PATCH 19/41] Fix fee in blocks --- src/Shared/GatewaySurchargeHandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Shared/GatewaySurchargeHandler.php b/src/Shared/GatewaySurchargeHandler.php index d4e467ffa..633737239 100644 --- a/src/Shared/GatewaySurchargeHandler.php +++ b/src/Shared/GatewaySurchargeHandler.php @@ -165,7 +165,8 @@ public function updateSurchargeCheckoutBlock() } $feeAmount = $this->surcharge->calculateFeeAmount($cart, $gatewaySettings); $feeAmountTaxed = $feeAmount + $cart->get_fee_tax(); - $newTotal = (float) $cart->get_total('edit'); + $cart->add_fee($this->gatewayFeeLabel, $feeAmount, true, 'standard'); + $newTotal = (float) $cart->get_total('edit') + $feeAmountTaxed; $data = [ 'amount' => $feeAmountTaxed, 'name' => $this->gatewayFeeLabel, From 2f894086ff5c2ef9f8bb616a1cf98d9047983769 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 6 Jul 2023 11:11:08 +0200 Subject: [PATCH 20/41] Fix custom fields in blocks and classic --- resources/js/blocks/molliePaymentMethod.js | 65 +++++++++------------- resources/js/mollieBillie.js | 2 +- resources/js/mollieIn3.js | 7 +-- resources/js/wooCheckoutFieldsUtility.js | 8 +-- src/PaymentMethods/Billie.php | 4 +- src/PaymentMethods/In3.php | 6 +- 6 files changed, 38 insertions(+), 54 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index a9d0de9c9..c016fcd42 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -3,23 +3,8 @@ let onSubmitLocal let activePaymentMethodLocal let cachedAvailableGateways let creditCardSelected = new Event("mollie_creditcard_component_selected", {bubbles: true}); - -function getCompanyField() -{ - let shippingCompany = document.getElementById('shipping-company'); - let billingCompany = document.getElementById('billing-company'); - return shippingCompany ? shippingCompany : billingCompany; -} - -function getPhoneField() -{ - const shippingPhone = document.getElementById('shipping-phone'); - const billingPhone = document.getElementById('billing-phone'); - return billingPhone || shippingPhone; -} - const MollieComponent = (props) => { - let {onSubmit, activePaymentMethod, billing, item, useEffect, ajaxUrl, jQuery, emitResponse, eventRegistration, requiredFields, shippingData} = props + let {onSubmit, activePaymentMethod, billing, item, useEffect, ajaxUrl, jQuery, emitResponse, eventRegistration, requiredFields, shippingData, isCompanyFieldVisible, isPhoneFieldVisible} = props const { responseTypes } = emitResponse; const {onPaymentSetup, onCheckoutValidation} = eventRegistration; const [ selectedIssuer, selectIssuer ] = wp.element.useState(''); @@ -29,9 +14,11 @@ const MollieComponent = (props) => { const issuerKey = 'mollie-payments-for-woocommerce_issuer_' + activePaymentMethod const {companyNameString, phoneString} = requiredFields - function isFieldVisible(field) + function getPhoneField() { - return field && field.style.display !== 'none'; + const shippingPhone = document.getElementById('shipping-phone'); + const billingPhone = document.getElementById('billing-phone'); + return billingPhone || shippingPhone; } function updateTotalLabel(newTotal, currency) { let feeText = newTotal + " " + currency @@ -94,11 +81,12 @@ const MollieComponent = (props) => { method: 'POST', data: { action: 'mollie_checkout_blocks_surchage', - payment_method: activePaymentMethod + method: activePaymentMethod }, complete: (jqXHR, textStatus) => { }, success: (response, textStatus, jqXHR) => { + console.log(response) handleFees(response) }, error: (jqXHR, textStatus, errorThrown) => { @@ -147,7 +135,7 @@ const MollieComponent = (props) => { companyLabel.replaceWith('') } } - let isCompanyEmpty = billing.billingData.company === '' && shippingData.shippingAddress.company === '' + let isCompanyEmpty = (billing.billingData.company === '' && shippingData.shippingAddress.company === '') && inputCompany === ''; const unsubscribeProcessing = onCheckoutValidation( () => { if (activePaymentMethod === 'mollie_wc_gateway_billie' && isCompanyEmpty) { @@ -161,11 +149,11 @@ const MollieComponent = (props) => { unsubscribeProcessing() }; - }, [activePaymentMethod, onCheckoutValidation, billing.billingData, item, companyNameString]); + }, [activePaymentMethod, onCheckoutValidation, billing.billingData, item, companyNameString, inputCompany]); useEffect(() => { - let phoneLabel = getPhoneField().labels[0]; - if (phoneLabel.length === 0) { + let phoneLabel = getPhoneField()?.labels?.[0] ?? null; + if (!phoneLabel || phoneLabel.length === 0) { return } if (activePaymentMethod === 'mollie_wc_gateway_in3') { @@ -175,7 +163,7 @@ const MollieComponent = (props) => { phoneLabel.innerText = phoneString } } - let isPhoneEmpty = billing.billingData.phone === '' && shippingData.shippingAddress.phone === '' + let isPhoneEmpty = (billing.billingData.phone === '' && shippingData.shippingAddress.phone === '') && inputPhone === ''; let isBirthdateEmpty = inputBirthdate === '' const unsubscribeProcessing = onCheckoutValidation( @@ -191,7 +179,7 @@ const MollieComponent = (props) => { unsubscribeProcessing() }; - }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate]); + }, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate, inputPhone]); onSubmitLocal = onSubmit const updateIssuer = ( changeEvent ) => { @@ -211,22 +199,27 @@ const MollieComponent = (props) => { return

{item.content}

} + if(item.name === "mollie_wc_gateway_creditcard"){ + return
; + } + function fieldMarkup(id, fieldType, label, action, value) { return
} + if (item.name === "mollie_wc_gateway_billie"){ - if(!isFieldVisible(getCompanyField())) { - const companyField = item.companyPlaceholder ? item.companyPlaceholder : "Company name"; - return fieldMarkup("billing-company","text", companyField, updateCompany, inputCompany); + if(isCompanyFieldVisible) { + return; } - return; + const companyField = item.companyPlaceholder ? item.companyPlaceholder : "Company name"; + return fieldMarkup("billing-company","text", companyField, updateCompany, inputCompany); } if (item.name === "mollie_wc_gateway_in3"){ let fields = []; const birthdateField = item.birthdatePlaceholder ? item.birthdatePlaceholder : "Birthdate"; fields.push(fieldMarkup("billing-birthdate", "date", birthdateField, updateBirthdate, inputBirthdate)); - if (!isFieldVisible(getPhoneField())) { + if (!isPhoneFieldVisible) { const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone"; fields.push(fieldMarkup("billing-phone", "tel", phoneField, updatePhone, inputPhone)); } @@ -238,26 +231,18 @@ const MollieComponent = (props) => { } -const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery) =>{ +const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery, requiredFields, isCompanyFieldVisible, isPhoneFieldVisible) =>{ let billingCountry = filters.billingCountry let cartTotal = filters.cartTotal cachedAvailableGateways = availableGateways let changedBillingCountry = filters.billingCountry - let companyField = getCompanyField(); - const companyNameString = companyField && companyField.parentNode.querySelector('label') ? companyField.parentNode.querySelector('label').innerHTML : false; - let phoneField = getPhoneField(); - const phoneString = phoneField && phoneField.parentNode.querySelector('label') ? phoneField.parentNode.querySelector('label').innerHTML : false; - let requiredFields = { - 'companyNameString': companyNameString, - 'phoneString': phoneString, - } document.addEventListener('mollie_components_ready_to_submit', function () { onSubmitLocal() }) return { name: item.name, label:
, - content: , + content: , edit:
{item.edit}
, paymentMethodId: item.paymentMethodId, canMakePayment: ({cartTotals, billingData}) => { diff --git a/resources/js/mollieBillie.js b/resources/js/mollieBillie.js index 4a567292d..ad31361e1 100644 --- a/resources/js/mollieBillie.js +++ b/resources/js/mollieBillie.js @@ -7,7 +7,7 @@ import {maybeRequireField, saveOriginalField} from "./wooCheckoutFieldsUtility"; let originalBillingCompanyField = saveOriginalField(inputCompanyName, {}); let companyFieldId = 'billing_company_field'; let companyField = jQuery('form[name="checkout"] p#billing_company_field'); - let positionCompanyField = '#payment > ul > li.wc_payment_method.payment_method_mollie_wc_gateway_billie > div'; + let positionCompanyField = 'li.wc_payment_method.payment_method_mollie_wc_gateway_billie'; let companyMarkup = '

' + '

' + '

' + '

+ return
} if (item.name === "mollie_wc_gateway_billie"){ From c01ffd878f556af66ca5eff2410a0ee34bef1a42 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 10 Jul 2023 10:21:15 +0200 Subject: [PATCH 27/41] Fix duplication on changing shipping --- resources/js/wooCheckoutFieldsUtility.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/wooCheckoutFieldsUtility.js b/resources/js/wooCheckoutFieldsUtility.js index adc81a21c..5964edb70 100644 --- a/resources/js/wooCheckoutFieldsUtility.js +++ b/resources/js/wooCheckoutFieldsUtility.js @@ -54,7 +54,8 @@ export function saveOriginalField(inputName, originalField) export function maybeRequireField(field, positionField, fieldMarkup, inputName, fieldId, originalField, gateway) { if (usingGateway(gateway)) { - if (!originalField.isVisible) { + const field = jQuery("#" + inputName); + if (!originalField.isVisible && field.length === 0) { showField(positionField, fieldMarkup); requireField(inputName, fieldId); return jQuery('form[name="checkout"] p#' + fieldId); From 7a41f21a61050b6d5cf9b7b8163eaaca9a91a045 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 10 Jul 2023 11:52:52 +0200 Subject: [PATCH 28/41] Fix unmounting error on blocks --- resources/js/mollie-components.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/js/mollie-components.js b/resources/js/mollie-components.js index 04a9c9901..836d28d10 100644 --- a/resources/js/mollie-components.js +++ b/resources/js/mollie-components.js @@ -253,6 +253,7 @@ function componentByName (name, mollie, settings, mollieComponentsMap) function unmountComponents (mollieComponentsMap) { + console.log(mollieComponentsMap) mollieComponentsMap.forEach(component => component.unmount()) } @@ -338,8 +339,11 @@ function initializeComponents ( * Mollie does not allow to keep a copy of the mounted components. * * We have to mount every time the components but we cannot recreate them. + * But only unmount if they exists. */ - unmountComponents(mollieComponentsMap) + if (jQuery("#cardHolder").length > 0) { + unmountComponents(mollieComponentsMap) + } enabledGateways.forEach(gateway => { From adce8c43c5a0a26d9e7ae2730db96fb98c11d433 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 10 Jul 2023 11:57:49 +0200 Subject: [PATCH 29/41] Remove log in script --- resources/js/mollie-components.js | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/js/mollie-components.js b/resources/js/mollie-components.js index 836d28d10..2fb1aa62b 100644 --- a/resources/js/mollie-components.js +++ b/resources/js/mollie-components.js @@ -253,7 +253,6 @@ function componentByName (name, mollie, settings, mollieComponentsMap) function unmountComponents (mollieComponentsMap) { - console.log(mollieComponentsMap) mollieComponentsMap.forEach(component => component.unmount()) } From 0d1216f2c76eee2e2b7b0e80ea250d9512d14721 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 10 Jul 2023 14:43:08 +0200 Subject: [PATCH 30/41] Fix typo in param name --- resources/js/blocks/molliePaymentMethod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 16d90cc60..96368d1c4 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -242,7 +242,7 @@ const molliePaymentMethod = (useEffect, ajaxUrl, filters, gatewayData, available return { name: item.name, label:
, - content: , + content: , edit:
{item.edit}
, paymentMethodId: item.paymentMethodId, canMakePayment: ({cartTotals, billingData}) => { From 39f8fb11783ba7e63a27cff3314d9909de2fd54e Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 12 Jul 2023 11:10:28 +0200 Subject: [PATCH 31/41] Remove disabling Billie --- src/Gateway/GatewayModule.php | 38 ----------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 4b72a586c..b4c8a0627 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -201,11 +201,6 @@ public function run(ContainerInterface $container): bool [$this, 'maybeDisableBankTransferGateway'], 20 ); - add_filter( - 'woocommerce_payment_gateways', - [$this, 'maybeDisableBillieGateway'], - 20 - ); // Disable SEPA as payment option in WooCommerce checkout add_filter( 'woocommerce_available_payment_gateways', @@ -300,39 +295,6 @@ static function ($paymentContext) { return true; } - /** - * Disable Bank Transfer Gateway - * - * @param ?array $gateways - * @return array - */ - public function maybeDisableBillieGateway(?array $gateways): array - { - if (!is_array($gateways)) { - return []; - } - $isWcApiRequest = (bool)filter_input(INPUT_GET, 'wc-api', FILTER_SANITIZE_SPECIAL_CHARS); - - /* - * There is only one case where we want to filter the gateway and it's when the - * pay-page render the available payments methods AND the setting is enabled - * - * For any other case we want to be sure billie gateway is included. - */ - if ( - $isWcApiRequest || - is_checkout() && ! is_wc_endpoint_url('order-pay') || - !wp_doing_ajax() && ! is_wc_endpoint_url('order-pay') || - is_admin() - ) { - return $gateways; - } - if (isset($gateways['mollie_wc_gateway_billie'])) { - unset($gateways['mollie_wc_gateway_billie']); - } - - return $gateways; - } /** * Disable Bank Transfer Gateway * From d1534da3d1061c90f07071d400e00c0f8ed81ba0 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 12 Jul 2023 11:10:49 +0200 Subject: [PATCH 32/41] Update mandate in subscription on paid --- src/Payment/MollieObject.php | 6 ++---- src/Subscription/MollieSubscriptionGateway.php | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Payment/MollieObject.php b/src/Payment/MollieObject.php index 8cc3641c9..2235991da 100644 --- a/src/Payment/MollieObject.php +++ b/src/Payment/MollieObject.php @@ -585,10 +585,8 @@ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder( if (!$subscription) { return; } - $subscription->update_meta_data( - '_mollie_payment_id', - $payment->id - ); + $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) { diff --git a/src/Subscription/MollieSubscriptionGateway.php b/src/Subscription/MollieSubscriptionGateway.php index a4d666693..b90d6329d 100644 --- a/src/Subscription/MollieSubscriptionGateway.php +++ b/src/Subscription/MollieSubscriptionGateway.php @@ -292,6 +292,7 @@ public function scheduled_subscription_payment($renewal_total, WC_Order $renewal $paymentMethodUsed = 'mollie_wc_gateway_' . $payment->method; if ($paymentMethodUsed !== $renewalOrderMethod) { $renewal_order->set_payment_method($paymentMethodUsed); + $renewal_order->save(); } //update the valid mandate for this order @@ -761,12 +762,7 @@ protected function usePreviousMandate( ); $mandate = $mollieApiClient->customers->get($customer_id)->getMandate($mandateId); - $bothDirectDebit = $mandate->method === self::DIRECTDEBIT - && $isRenewalMethodDirectDebit; - $bothCreditcard = $mandate->method !== self::DIRECTDEBIT - && !$isRenewalMethodDirectDebit; - $samePaymentMethodAsMandate = $bothDirectDebit || $bothCreditcard; - if ($mandate->status === 'valid' && $samePaymentMethodAsMandate) { + if ($mandate->status === 'valid') { $data['method'] = $mandate->method; $data['mandateId'] = $mandateId; $validMandate = true; From 648dc9ef907953da1bc5e0396b6fe4b392b77006 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 12 Jul 2023 11:21:51 +0200 Subject: [PATCH 33/41] Prevent adding double fee on block --- src/Shared/GatewaySurchargeHandler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Shared/GatewaySurchargeHandler.php b/src/Shared/GatewaySurchargeHandler.php index 633737239..ef747618e 100644 --- a/src/Shared/GatewaySurchargeHandler.php +++ b/src/Shared/GatewaySurchargeHandler.php @@ -178,6 +178,9 @@ public function updateSurchargeCheckoutBlock() public function add_engraving_fees($cart) { + if (is_admin() || !mollieWooCommerceIsCheckoutContext()) { + return; + } $gateway = $this->chosenGateway(); if (!$gateway) { return; From cfaeb206a364715e8c407a576960936c572968b6 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 12 Jul 2023 13:57:23 +0200 Subject: [PATCH 34/41] Update tests --- tests/php/Functional/Payment/PaymentServiceTest.php | 3 ++- tests/php/Functional/Shared/SurchargeHandlerTest.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/php/Functional/Payment/PaymentServiceTest.php b/tests/php/Functional/Payment/PaymentServiceTest.php index 2326d4d63..b8c536b38 100644 --- a/tests/php/Functional/Payment/PaymentServiceTest.php +++ b/tests/php/Functional/Payment/PaymentServiceTest.php @@ -93,7 +93,8 @@ public function processPayment_Order_success(){ 'wc_get_product' => $this->wcProduct(), 'wc_get_payment_gateway_by_order' => $gateway, 'add_query_arg' => 'https://webshop.example.org/wc-api/mollie_return?order_id=1&key=wc_order_hxZniP1zDcnM8', - 'WC' => $this->wooCommerce() + 'WC' => $this->wooCommerce(), + 'wc_clean' => null, ] ); $gateway->expects($this->once()) diff --git a/tests/php/Functional/Shared/SurchargeHandlerTest.php b/tests/php/Functional/Shared/SurchargeHandlerTest.php index fce40e599..bbf43be09 100644 --- a/tests/php/Functional/Shared/SurchargeHandlerTest.php +++ b/tests/php/Functional/Shared/SurchargeHandlerTest.php @@ -62,6 +62,7 @@ public function addsSurchargeFeesInCheckout(){ expect('mollieWooCommerceIsCheckoutContext')->andReturn(true); expect('wc_tax_enabled')->andReturn(false); expect('WC')->andReturn($this->wooCommerce()); + expect('is_admin')->andReturn(false); $cart->expects(self::once())->method('add_fee')->with($expectedLabel, $expectedAmount, true, 'standard'); $testee->add_engraving_fees($cart); From 654e9f9b50268afa4016fbbdb36323283139fc87 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Wed, 12 Jul 2023 14:38:32 +0200 Subject: [PATCH 35/41] Fix cs --- src/Payment/MollieObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Payment/MollieObject.php b/src/Payment/MollieObject.php index 2235991da..0f362bcf2 100644 --- a/src/Payment/MollieObject.php +++ b/src/Payment/MollieObject.php @@ -586,7 +586,7 @@ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder( return; } $subscription->update_meta_data('_mollie_payment_id', $payment->id); - $subscription->set_payment_method('mollie_wc_gateway_'.$payment->method); + $subscription->set_payment_method('mollie_wc_gateway_' . $payment->method); $subscription->save(); $subcriptionParentOrder = $subscription->get_parent(); if ($subcriptionParentOrder) { From 88117a56d06417a7050b290ce743148f7b0744fa Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 20 Jul 2023 16:41:13 +0200 Subject: [PATCH 36/41] Isolate components in blocks --- resources/js/mollie-components-blocks.js | 497 +++++++++++++++++++++++ resources/js/mollie-components.js | 41 +- src/Assets/AssetsModule.php | 94 +++-- 3 files changed, 557 insertions(+), 75 deletions(-) create mode 100644 resources/js/mollie-components-blocks.js diff --git a/resources/js/mollie-components-blocks.js b/resources/js/mollie-components-blocks.js new file mode 100644 index 000000000..806bba0b8 --- /dev/null +++ b/resources/js/mollie-components-blocks.js @@ -0,0 +1,497 @@ +const SELECTOR_TOKEN_ELEMENT = '.cardToken' +const SELECTOR_MOLLIE_COMPONENTS_CONTAINER = '.mollie-components' +const SELECTOR_FORM = 'form' +const SELECTOR_MOLLIE_GATEWAY_BLOCK_CONTAINER = '.wc-block-components-radio-control' + +const SELECTOR_MOLLIE_NOTICE_CONTAINER = '#mollie-notice' + +function returnFalse () +{ + return false +} +function returnTrue () +{ + return true +} + +/* ------------------------------------------------------------------- + Containers + ---------------------------------------------------------------- */ +function gatewayContainer (container) +{ + let blockContainer = container ? container.querySelector(SELECTOR_MOLLIE_GATEWAY_BLOCK_CONTAINER) : null + return blockContainer +} + +function containerForGateway (gateway, container) +{ + if(!container) { + return null + } + let parentInBlock = container.querySelector('label[for="radio-control-wc-payment-method-options-mollie_wc_gateway_creditcard"]'); + return parentInBlock ? parentInBlock.closest('div') : null +} + +function noticeContainer (container) +{ + return container ? container.querySelector(SELECTOR_MOLLIE_NOTICE_CONTAINER) : null +} + +function componentsContainerFromWithin (container) +{ + return container ? container.querySelector(SELECTOR_MOLLIE_COMPONENTS_CONTAINER) : null +} + +function cleanContainer (container) +{ + if (!container) { + return + } + + container.innerText = '' +} + +/* ------------------------------------------------------------------- + Notice + ---------------------------------------------------------------- */ +function renderNotice ({ content, type }) +{ + return ` +
+ ${content} +
+ ` +} + +function printNotice (jQuery, noticeData) +{ + const container = gatewayContainer(document) + const formContainer = closestFormForElement(container).parentNode || null + const mollieNotice = noticeContainer(document) + const renderedNotice = renderNotice(noticeData) + + mollieNotice && mollieNotice.remove() + + if (!formContainer) { + alert(noticeData.content) + return + } + + formContainer.insertAdjacentHTML('beforebegin', renderedNotice) + + scrollToNotice(jQuery) +} + +function scrollToNotice (jQuery) +{ + var scrollToElement = noticeContainer(document) + + if (!scrollToElement) { + scrollToElement = gatewayContainer(document) + } + + jQuery.scroll_to_notices(jQuery(scrollToElement)) +} + +/* ------------------------------------------------------------------- + Token + ---------------------------------------------------------------- */ +function createTokenFieldWithin (container) +{ + container && container.insertAdjacentHTML( + 'beforeend', + '' + ) +} + +function tokenElementWithin (container) +{ + return container.querySelector(SELECTOR_TOKEN_ELEMENT) +} + +async function retrievePaymentToken (mollie) +{ + const { token, error } = await mollie.createToken(SELECTOR_TOKEN_ELEMENT) + + if (error) { + throw new Error(error.message || '') + } + + return token +} + +function setTokenValueToField (token, tokenFieldElement) +{ + if (!tokenFieldElement) { + return + } + + tokenFieldElement.value = token + tokenFieldElement.setAttribute('value', token) +} + +/* ------------------------------------------------------------------- + Form + ---------------------------------------------------------------- */ +function closestFormForElement (element) +{ + return element ? element.closest(SELECTOR_FORM) : null +} + +function turnMollieComponentsSubmissionOff ($form) +{ + $form.off('checkout_place_order', returnFalse) + $form.off('submit', submitForm) +} + +function turnBlockListenerOff (target) +{ + target.off('click', submitForm) +} + +function isGatewaySelected (gateway) +{ + const gatewayContainer = containerForGateway(gateway, document) + const gatewayInput = gatewayContainer + ? gatewayContainer.querySelector(`#radio-control-wc-payment-method-options-mollie_wc_gateway_${gateway}`) + : null + + if (!gatewayInput) { + return false + } + + return gatewayInput.checked || false +} + +async function submitForm (evt) +{ + let token = '' + const { jQuery, mollie, gateway, gatewayContainer, messages } = evt.data + const form = closestFormForElement(gatewayContainer) + const $form = jQuery(form) + const $document = jQuery(document.body) + + if (!isGatewaySelected(gateway)) { + // Let other gateway to submit the form + turnMollieComponentsSubmissionOff($form) + $form.submit() + return + } + + evt.preventDefault() + evt.stopImmediatePropagation() + + try { + token = await retrievePaymentToken(mollie) + } catch (error) { + const content = { message = messages.defaultErrorMessage } = error + content && printNotice(jQuery, { content, type: 'error' }) + + $form.removeClass('processing').unblock() + $document.trigger('checkout_error') + return + } + + turnMollieComponentsSubmissionOff($form) + + token && setTokenValueToField(token, tokenElementWithin(gatewayContainer)) + if(evt.type === 'click'){ + turnBlockListenerOff(jQuery(evt.target)) + let readyToSubmitBlock = new Event("mollie_components_ready_to_submit", {bubbles: true}); + document.documentElement.dispatchEvent(readyToSubmitBlock); + return + } + + $form.submit() +} + +/* ------------------------------------------------------------------- + Component + ---------------------------------------------------------------- */ +function componentElementByNameFromWithin (name, container) +{ + return container ? container.querySelector(`.mollie-component--${name}`) : null +} + +function createComponentLabelElementWithin (container, { label }) +{ + container.insertAdjacentHTML( + 'beforebegin', + `${label}` + ) +} + +function createComponentsErrorContainerWithin (container, { name }) +{ + container.insertAdjacentHTML( + 'afterend', + `` + ) +} + +function componentByName (name, mollie, settings, mollieComponentsMap) +{ + let component + + if (mollieComponentsMap.has(name)) { + component = mollieComponentsMap.get(name) + } + if (!component) { + component = mollie.createComponent(name, settings) + } + + return component +} + +function unmountComponents (mollieComponentsMap) +{ + console.log(mollieComponentsMap) + mollieComponentsMap.forEach(component => { + try { + component.unmount() + } catch (err) { + } + }) +} + +function mountComponent ( + mollie, + componentSettings, + componentAttributes, + mollieComponentsMap, + baseContainer +) +{ + const { name: componentName } = componentAttributes + const component = componentByName(componentName, mollie, componentSettings, mollieComponentsMap) + const mollieComponentsContainer = componentsContainerFromWithin(baseContainer) + + mollieComponentsContainer.insertAdjacentHTML('beforeend', `
`) + component.mount(`#${componentName}`) + + const currentComponentElement = componentElementByNameFromWithin(componentName, baseContainer) + if (!currentComponentElement) { + console.warn(`Component ${componentName} not found in the DOM. Probably had problem during mount.`) + return + } + + createComponentLabelElementWithin(currentComponentElement, componentAttributes) + createComponentsErrorContainerWithin(currentComponentElement, componentAttributes) + let componentError = document.querySelector('#' + componentName + '-errors') + component.addEventListener('change', event => { + if (event.error && event.touched) { + componentError.textContent = event.error + } else { + componentError.textContent = '' + } + }) + + !mollieComponentsMap.has(componentName) && mollieComponentsMap.set(componentName, component) +} + +function mountComponents ( + mollie, + componentSettings, + componentsAttributes, + mollieComponentsMap, + baseContainer +) +{ + componentsAttributes.forEach( + componentAttributes => { + try { + mountComponent( + mollie, + componentSettings, + componentAttributes, + mollieComponentsMap, + baseContainer + ) + } catch (err) { + console.log(err) + } + + } + ) +} + +/* ------------------------------------------------------------------- + Init + ---------------------------------------------------------------- */ + +/** + * Unmount and Mount the components if them already exists, create them if it's the first time + * the components are created. + */ +function initializeComponents ( + jQuery, + mollie, + { + options, + merchantProfileId, + componentsSettings, + componentsAttributes, + enabledGateways, + messages + }, + mollieComponentsMap +) +{ + + /* + * WooCommerce update the DOM when something on checkout page happen. + * Mollie does not allow to keep a copy of the mounted components. + * + * We have to mount every time the components but we cannot recreate them. + */ + //unmountComponents(mollieComponentsMap) + + enabledGateways.forEach(gateway => + { + const gatewayContainer = containerForGateway(gateway, document) + const mollieComponentsContainer = componentsContainerFromWithin(gatewayContainer) + const form = closestFormForElement(gatewayContainer) + const $form = jQuery(form) + + if (!gatewayContainer) { + console.warn(`Cannot initialize Mollie Components for gateway ${gateway}.`) + return + } + + if (!form) { + console.warn('Cannot initialize Mollie Components, no form found.') + return + } + + // Remove old listener before add new ones or form will not be submitted + turnMollieComponentsSubmissionOff($form) + + /* + * Clean container for mollie components because we do not know in which context we may need + * to create components. + */ + if (!mollieComponentsContainer) { + return + } + cleanContainer(mollieComponentsContainer) + createTokenFieldWithin(mollieComponentsContainer) + + mountComponents( + mollie, + componentsSettings[gateway], + componentsAttributes, + mollieComponentsMap, + gatewayContainer + ) + + $form.on('checkout_place_order', returnFalse) + $form.on( + 'submit', + null, + { + jQuery, + mollie, + gateway, + gatewayContainer, + messages + }, + submitForm + ) + //waiting for the blocks to load, this should receive an event to look for the button instead + setTimeout(function (){ + submitButton = jQuery(".wc-block-components-checkout-place-order-button") + + jQuery(submitButton).click( + { + jQuery, + mollie, + gateway, + gatewayContainer, + messages + }, + submitForm + ) + },500) + }) +} + +( + function ({ _, Mollie, mollieComponentsSettings, jQuery }) { + if (_.isEmpty(mollieComponentsSettings) || !_.isFunction(Mollie)) { + return + } + + try { + let eventName = 'updated_checkout' + const mollieComponentsMap = new Map() + const $document = jQuery(document) + const {merchantProfileId, options, isCheckoutPayPage} = mollieComponentsSettings + const mollie = new Mollie(merchantProfileId, options) + + + if (isCheckoutPayPage) { + eventName = 'payment_method_selected' + $document.on( + eventName, + () => initializeComponents( + jQuery, + mollie, + mollieComponentsSettings, + mollieComponentsMap + ) + ) + return + } + + document.addEventListener("mollie_creditcard_component_selected", function (event) { + setTimeout(function () { + initializeComponents( + jQuery, + mollie, + mollieComponentsSettings, + mollieComponentsMap + ) + }, 500); + }); + + + function checkInit() { + return function () { + let copySettings = JSON.parse(JSON.stringify(mollieComponentsSettings)) + mollieComponentsSettings.enabledGateways.forEach(function (gateway, index) { + const gatewayContainer = containerForGateway(gateway, document) + if (!gatewayContainer) { + copySettings.enabledGateways.splice(index, 1) + const $form = jQuery('form[name="checkout"]') + $form.on('checkout_place_order', returnTrue) + } + }) + if (_.isEmpty(copySettings.enabledGateways)) { + return + } + initializeComponents( + jQuery, + mollie, + copySettings, + mollieComponentsMap + ) + }; + } + + $document.on( + eventName, + checkInit() + ) + $document.on( + 'update_checkout', + checkInit() + ) + + } catch (err) { + + } + } +) +( + window +) diff --git a/resources/js/mollie-components.js b/resources/js/mollie-components.js index 2fb1aa62b..c48b40a45 100644 --- a/resources/js/mollie-components.js +++ b/resources/js/mollie-components.js @@ -2,7 +2,6 @@ const SELECTOR_TOKEN_ELEMENT = '.cardToken' const SELECTOR_MOLLIE_COMPONENTS_CONTAINER = '.mollie-components' const SELECTOR_FORM = 'form' const SELECTOR_MOLLIE_GATEWAY_CONTAINER = '.wc_payment_methods' -const SELECTOR_MOLLIE_GATEWAY_BLOCK_CONTAINER = '.wc-block-components-radio-control' const SELECTOR_MOLLIE_NOTICE_CONTAINER = '#mollie-notice' @@ -20,20 +19,12 @@ function returnTrue () ---------------------------------------------------------------- */ function gatewayContainer (container) { - let checkoutContainer = container ? container.querySelector(SELECTOR_MOLLIE_GATEWAY_CONTAINER) : null - let blockContainer = container ? container.querySelector(SELECTOR_MOLLIE_GATEWAY_BLOCK_CONTAINER) : null - return checkoutContainer ? checkoutContainer : blockContainer + return container ? container.querySelector(SELECTOR_MOLLIE_GATEWAY_CONTAINER) : null } function containerForGateway (gateway, container) { - if(!container) { - return null - } - let parentInBlock = container.querySelector('label[for="radio-control-wc-payment-method-options-mollie_wc_gateway_creditcard"]'); - parentInBlock = parentInBlock ? parentInBlock.closest('div') : null - const parentInClassic = container.querySelector(`.payment_method_mollie_wc_gateway_${gateway}`) - return parentInBlock || parentInClassic + return container ? container.querySelector(`.payment_method_mollie_wc_gateway_${gateway}`) : null } function noticeContainer (container) @@ -116,6 +107,7 @@ function tokenElementWithin (container) async function retrievePaymentToken (mollie) { const { token, error } = await mollie.createToken(SELECTOR_TOKEN_ELEMENT) + if (error) { throw new Error(error.message || '') } @@ -158,11 +150,6 @@ function isGatewaySelected (gateway) const gatewayInput = gatewayContainer ? gatewayContainer.querySelector(`#payment_method_mollie_wc_gateway_${gateway}`) : null - //if we are in blocks then the input is different - const gatewayBlockInput = document.getElementById("radio-control-wc-payment-method-options-mollie_wc_gateway_creditcard") - if(gatewayBlockInput){ - return gatewayBlockInput.checked || false - } if (!gatewayInput) { return false @@ -203,12 +190,6 @@ async function submitForm (evt) turnMollieComponentsSubmissionOff($form) token && setTokenValueToField(token, tokenElementWithin(gatewayContainer)) - if(evt.type === 'click'){ - turnBlockListenerOff(jQuery(evt.target)) - let readyToSubmitBlock = new Event("mollie_components_ready_to_submit", {bubbles: true}); - document.documentElement.dispatchEvent(readyToSubmitBlock); - return - } $form.submit() } @@ -338,11 +319,8 @@ function initializeComponents ( * Mollie does not allow to keep a copy of the mounted components. * * We have to mount every time the components but we cannot recreate them. - * But only unmount if they exists. */ - if (jQuery("#cardHolder").length > 0) { - unmountComponents(mollieComponentsMap) - } + unmountComponents(mollieComponentsMap) enabledGateways.forEach(gateway => { @@ -438,17 +416,6 @@ function initializeComponents ( return } - document.addEventListener("mollie_creditcard_component_selected", function(event) { - setTimeout(function(){ - initializeComponents( - jQuery, - mollie, - mollieComponentsSettings, - mollieComponentsMap - ) - },500); - }); - function checkInit() { return function () { let copySettings = JSON.parse(JSON.stringify(mollieComponentsSettings)) diff --git a/src/Assets/AssetsModule.php b/src/Assets/AssetsModule.php index 6247f50b3..274654faf 100644 --- a/src/Assets/AssetsModule.php +++ b/src/Assets/AssetsModule.php @@ -261,6 +261,13 @@ protected function registerFrontendScripts(string $pluginUrl, string $pluginPath (string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollie-components.min.js')), true ); + wp_register_script( + 'mollie-components-blocks', + $this->getPluginUrl($pluginUrl, '/public/js/mollie-components-blocks.min.js'), + ['underscore', 'jquery', 'mollie', 'babel-polyfill'], + (string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollie-components-blocks.min.js')), + true + ); wp_register_style( 'unabledButton', @@ -367,49 +374,60 @@ public function enqueueComponentsAssets(Settings $settingsHelper): void } wp_enqueue_style('mollie-components'); - wp_enqueue_script('mollie-components'); - - wp_localize_script( - 'mollie-components', - 'mollieComponentsSettings', - [ - 'merchantProfileId' => $merchantProfileId, - 'options' => [ - 'locale' => $locale, - 'testmode' => $settingsHelper->isTestModeEnabled(), + $object_name = 'mollieComponentsSettings'; + $data = [ + 'merchantProfileId' => $merchantProfileId, + 'options' => [ + 'locale' => $locale, + 'testmode' => $settingsHelper->isTestModeEnabled(), + ], + 'enabledGateways' => $gatewayNames, + 'componentsSettings' => $mollieComponentsStylesGateways, + 'componentsAttributes' => [ + [ + 'name' => 'cardHolder', + 'label' => esc_html__('Name on card', 'mollie-payments-for-woocommerce'), ], - 'enabledGateways' => $gatewayNames, - 'componentsSettings' => $mollieComponentsStylesGateways, - 'componentsAttributes' => [ - [ - 'name' => 'cardHolder', - 'label' => esc_html__('Name on card', 'mollie-payments-for-woocommerce'), - ], - [ - 'name' => 'cardNumber', - 'label' => esc_html__('Card number', 'mollie-payments-for-woocommerce'), - ], - [ - 'name' => 'expiryDate', - 'label' => esc_html__('Expiry date', 'mollie-payments-for-woocommerce'), - ], - [ - 'name' => 'verificationCode', - 'label' => esc_html__( - 'CVC/CVV', - 'mollie-payments-for-woocommerce' - ), - ], + [ + 'name' => 'cardNumber', + 'label' => esc_html__('Card number', 'mollie-payments-for-woocommerce'), + ], + [ + 'name' => 'expiryDate', + 'label' => esc_html__('Expiry date', 'mollie-payments-for-woocommerce'), ], - 'messages' => [ - 'defaultErrorMessage' => esc_html__( - 'An unknown error occurred, please check the card fields.', + [ + 'name' => 'verificationCode', + 'label' => esc_html__( + 'CVC/CVV', 'mollie-payments-for-woocommerce' ), ], - 'isCheckout' => is_checkout(), - 'isCheckoutPayPage' => is_checkout_pay_page(), - ] + ], + 'messages' => [ + 'defaultErrorMessage' => esc_html__( + 'An unknown error occurred, please check the card fields.', + 'mollie-payments-for-woocommerce' + ), + ], + 'isCheckout' => is_checkout(), + 'isCheckoutPayPage' => is_checkout_pay_page(), + ]; + if (has_block("woocommerce/checkout")){ + wp_enqueue_script('mollie-components-blocks'); + wp_localize_script( + 'mollie-components-blocks', + $object_name, + $data + ); + return; + } + + wp_enqueue_script('mollie-components'); + wp_localize_script( + 'mollie-components', + $object_name, + $data ); } From b2bd9fcee7912778d75a6b569c12f489fed15846 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 20 Jul 2023 16:41:40 +0200 Subject: [PATCH 37/41] Fix tax surcharges in blocks --- resources/js/blocks/molliePaymentMethod.js | 13 ++++- src/Gateway/Surcharge.php | 23 +-------- src/Payment/PaymentService.php | 3 +- src/Shared/GatewaySurchargeHandler.php | 55 ++++++++++++++++++---- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index 96368d1c4..a68a30991 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -25,10 +25,18 @@ const MollieComponent = (props) => { let total = jQuery('.wc-block-components-totals-footer-item .wc-block-formatted-money-amount:first') total.replaceWith(totalSpan) } + function updateTaxesLabel(newTotal, currency) { + let feeText = newTotal + " " + currency + + let totalSpan = "" + feeText + "" + let total = jQuery('div.wp-block-woocommerce-checkout-order-summary-taxes-block.wc-block-components-totals-wrapper > div > span.wc-block-formatted-money-amount.wc-block-components-formatted-money-amount.wc-block-components-totals-item__value:first') + total.replaceWith(totalSpan) + } function hideFee(fee, response) { fee?.hide() - updateTotalLabel(response.data.newTotal, ''); + updateTotalLabel(response.data.newTotal.toFixed(2).replace('.', ','), response.data.currency); + updateTaxesLabel(response.data.totalTax.toFixed(2).replace('.', ','), response.data.currency); } function feeMarkup(response) { @@ -47,12 +55,14 @@ const MollieComponent = (props) => { function replaceFee(fee, newFee, response) { fee.replaceWith(newFee) updateTotalLabel(response.data.newTotal.toFixed(2).replace('.', ','), response.data.currency); + updateTaxesLabel(response.data.totalTax.toFixed(2).replace('.', ','), response.data.currency); } function insertNewFee(newFee, response) { const subtotal = jQuery('.wc-block-components-totals-item:first') subtotal.after(newFee) updateTotalLabel(response.data.newTotal.toFixed(2).replace('.', ','), response.data.currency); + updateTaxesLabel(response.data.totalTax.toFixed(2).replace('.', ','), response.data.currency); } function handleFees(response) { @@ -86,6 +96,7 @@ const MollieComponent = (props) => { }, success: (response, textStatus, jqXHR) => { handleFees(response) + console.log(response.data.cart) }, error: (jqXHR, textStatus, errorThrown) => { console.warn(textStatus, errorThrown) diff --git a/src/Gateway/Surcharge.php b/src/Gateway/Surcharge.php index 038bb0240..17340bf45 100644 --- a/src/Gateway/Surcharge.php +++ b/src/Gateway/Surcharge.php @@ -111,8 +111,7 @@ public function calculateFeeAmount(WC_Cart $cart, array $gatewaySettings): float if (!method_exists($this, $methodName)) { return 0.0; } - $amount = $this->$methodName($cart, $gatewaySettings); - return $this->subtractTaxesFromValue($amount); + return $this->$methodName($cart, $gatewaySettings); } /** @@ -135,7 +134,7 @@ public function calculateFeeAmountOrder(WC_Order $order, array $gatewaySettings) $amount = $this->calculate_fixed_fee_percentage_order($order, $gatewaySettings); break; } - return $this->subtractTaxesFromValue($amount); + return $amount; } /** @@ -240,24 +239,6 @@ protected function addMaxLimit(float $fee, array $gatewaySettings): float return $fee; } - /** - * Return amount without the tax, so it can be included within the value - * @param float $amount - * @return float - */ - protected function subtractTaxesFromValue(float $amount): float - { - if (!wc_tax_enabled() || $amount === 0.0) { - return $amount; - } - $taxRates = \WC_Tax::get_rates(); - $wcStandardTax = \WC_Tax::calc_inclusive_tax($amount, $taxRates); - foreach ($wcStandardTax as $tax) { - $amount -= $tax; - } - return $amount; - } - /** * @param $paymentMethod * @return false|string diff --git a/src/Payment/PaymentService.php b/src/Payment/PaymentService.php index 9fd2e2099..c627d9e98 100644 --- a/src/Payment/PaymentService.php +++ b/src/Payment/PaymentService.php @@ -208,8 +208,7 @@ protected function orderAddFee($order, $amount, $surchargeName) $item_fee->set_name($surchargeName); $item_fee->set_amount($amount); $item_fee->set_total($amount); - $item_fee->set_tax_status('none'); - + $item_fee->set_tax_status('taxable'); $order->add_item($item_fee); $order->calculate_totals(); } diff --git a/src/Shared/GatewaySurchargeHandler.php b/src/Shared/GatewaySurchargeHandler.php index ef747618e..afc40b84d 100644 --- a/src/Shared/GatewaySurchargeHandler.php +++ b/src/Shared/GatewaySurchargeHandler.php @@ -131,14 +131,19 @@ public function updateSurchargeOrderPay() public function updateSurchargeCheckoutBlock() { $gateway = $this->canProcessGateway(); - $cart = WC()->cart; + WC()->cart; $gatewaySettings = $this->gatewaySettings($gateway); - $cart->calculate_totals(); + $this->cartRemoveFee(); + WC()->cart->calculate_totals(); + $newTotal = (float) WC()->cart->get_totals()['total']; + $totalTax = WC()->cart->get_totals()['total_tax']; $noSurchargeData = [ + 'amount' => false, 'name' => '', 'currency' => get_woocommerce_currency_symbol(), - 'newTotal' => $cart->get_total(), + 'newTotal' => $newTotal, + 'totalTax' => $totalTax, ]; if (!$gatewaySettings) { wp_send_json_success($noSurchargeData); @@ -153,26 +158,40 @@ public function updateSurchargeCheckoutBlock() return; } - $isRecurringCart = ! empty($cart->recurring_cart_key); + $isRecurringCart = ! empty(WC()->cart->recurring_cart_key); if ($isRecurringCart) { wp_send_json_success($noSurchargeData); return; } - $cartAmount = (float) $cart->get_total('edit'); + $cartAmount = (float) WC()->cart->get_total('edit'); if ($this->surcharge->aboveMaxLimit($cartAmount, $gatewaySettings)) { wp_send_json_success($noSurchargeData); return; } - $feeAmount = $this->surcharge->calculateFeeAmount($cart, $gatewaySettings); - $feeAmountTaxed = $feeAmount + $cart->get_fee_tax(); - $cart->add_fee($this->gatewayFeeLabel, $feeAmount, true, 'standard'); - $newTotal = (float) $cart->get_total('edit') + $feeAmountTaxed; + $feeAmount = $this->surcharge->calculateFeeAmount(WC()->cart, $gatewaySettings); + + $label = $this->gatewayFeeLabel; + add_action( 'woocommerce_cart_calculate_fees', function() use ($label, $feeAmount) { + global $woocommerce; + $woocommerce->cart->add_fee($label, $feeAmount, true, 'standard'); + }); + WC()->cart->calculate_totals(); + $feeAmountTaxed = (float) WC()->cart->get_totals()['fee_total']; + $taxDisplayMode = get_option( 'woocommerce_tax_display_shop' ); + if ($taxDisplayMode === 'incl') { + $feeAmountTaxed = $feeAmountTaxed + (float) WC()->cart->get_totals()['fee_tax']; + } + $newTotal = (float) WC()->cart->get_totals()['total']; + $totalTax = WC()->cart->get_totals()['total_tax']; $data = [ 'amount' => $feeAmountTaxed, 'name' => $this->gatewayFeeLabel, 'currency' => get_woocommerce_currency_symbol(), 'newTotal' => $newTotal, + 'totalTax' => $totalTax, + 'cart' => WC()->cart->get_totals() ]; + wp_send_json_success($data); } @@ -259,7 +278,23 @@ protected function orderRemoveFee($order) } } } - + /** + * + *@throws \Exception + */ + protected function cartRemoveFee() + { + $label = $this->gatewayFeeLabel; + add_action( 'woocommerce_before_calculate_totals', function () use ($label) { + $fees = WC()->cart->get_fees(); + foreach ($fees as $key => $fee) { + if($fees[$key]->name === $label) { + unset($fees[$key]); + } + } + WC()->cart->fees_api()->set_fees($fees); + } ); + } protected function orderAddFee($order, $amount, $surchargeName) { $item_fee = new WC_Order_Item_Fee(); From b1bec754dfc0c9decb2293400284844ace28ca80 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 20 Jul 2023 16:42:54 +0200 Subject: [PATCH 38/41] Remove log in script --- resources/js/blocks/molliePaymentMethod.js | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index a68a30991..f71b8f080 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -96,7 +96,6 @@ const MollieComponent = (props) => { }, success: (response, textStatus, jqXHR) => { handleFees(response) - console.log(response.data.cart) }, error: (jqXHR, textStatus, errorThrown) => { console.warn(textStatus, errorThrown) From 7e1ec080e8379ce1faed4e0ed85f6c5b199514eb Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Sat, 22 Jul 2023 08:59:44 +0200 Subject: [PATCH 39/41] Fix components block checkout --- resources/js/blocks/molliePaymentMethod.js | 2 +- resources/js/mollie-components-blocks.js | 27 +++++++--------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/resources/js/blocks/molliePaymentMethod.js b/resources/js/blocks/molliePaymentMethod.js index f71b8f080..39303c616 100644 --- a/resources/js/blocks/molliePaymentMethod.js +++ b/resources/js/blocks/molliePaymentMethod.js @@ -237,7 +237,7 @@ const MollieComponent = (props) => { return <>{fields}; } - return + return

} diff --git a/resources/js/mollie-components-blocks.js b/resources/js/mollie-components-blocks.js index 806bba0b8..2b14a1a33 100644 --- a/resources/js/mollie-components-blocks.js +++ b/resources/js/mollie-components-blocks.js @@ -25,11 +25,7 @@ function gatewayContainer (container) function containerForGateway (gateway, container) { - if(!container) { - return null - } - let parentInBlock = container.querySelector('label[for="radio-control-wc-payment-method-options-mollie_wc_gateway_creditcard"]'); - return parentInBlock ? parentInBlock.closest('div') : null + return container ? container.querySelector(`.payment_method_mollie_wc_gateway_${gateway}`) : null } function noticeContainer (container) @@ -98,7 +94,7 @@ function scrollToNotice (jQuery) ---------------------------------------------------------------- */ function createTokenFieldWithin (container) { - container && container.insertAdjacentHTML( + container.insertAdjacentHTML( 'beforeend', '' ) @@ -151,16 +147,10 @@ function turnBlockListenerOff (target) function isGatewaySelected (gateway) { - const gatewayContainer = containerForGateway(gateway, document) - const gatewayInput = gatewayContainer - ? gatewayContainer.querySelector(`#radio-control-wc-payment-method-options-mollie_wc_gateway_${gateway}`) - : null - - if (!gatewayInput) { - return false + const gatewayBlockInput = document.getElementById("radio-control-wc-payment-method-options-mollie_wc_gateway_creditcard") + if(gatewayBlockInput) { + return gatewayBlockInput.checked || false } - - return gatewayInput.checked || false } async function submitForm (evt) @@ -245,7 +235,6 @@ function componentByName (name, mollie, settings, mollieComponentsMap) function unmountComponents (mollieComponentsMap) { - console.log(mollieComponentsMap) mollieComponentsMap.forEach(component => { try { component.unmount() @@ -308,7 +297,6 @@ function mountComponents ( baseContainer ) } catch (err) { - console.log(err) } } @@ -344,7 +332,7 @@ function initializeComponents ( * * We have to mount every time the components but we cannot recreate them. */ - //unmountComponents(mollieComponentsMap) + unmountComponents(mollieComponentsMap) enabledGateways.forEach(gateway => { @@ -416,7 +404,8 @@ function initializeComponents ( } ( - function ({ _, Mollie, mollieComponentsSettings, jQuery }) { + function ({ _, Mollie, mollieComponentsSettings, jQuery }) + { if (_.isEmpty(mollieComponentsSettings) || !_.isFunction(Mollie)) { return } From eaa6d75dd1e2fcf81b480f2ec497ba1433f65b3e Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Sat, 22 Jul 2023 09:00:09 +0200 Subject: [PATCH 40/41] Minify components block script --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.config.js b/webpack.config.js index f86e58715..becfe49d9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,6 +26,7 @@ function configJavaScript ({ basePath }) .addEntry('advancedSettings.min', './resources/js/advancedSettings.js') .addEntry('gatewaySurcharge.min', './resources/js/gatewaySurcharge.js') .addEntry('mollie-components.min', './resources/js/mollie-components.js') + .addEntry('mollie-components-blocks.min', './resources/js/mollie-components-blocks.js') .addEntry('mollieBlockIndex.min', './resources/js/mollieBlockIndex.js') .addEntry('paypalButtonBlockComponent.min', './resources/js/paypalButtonBlockComponent.js') .addEntry('applepayButtonBlockComponent.min', './resources/js/applepayButtonBlockComponent.js') From fd290d700d106f3576be27165fcfba43fda52680 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Sat, 22 Jul 2023 09:00:43 +0200 Subject: [PATCH 41/41] 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 53a3050a6..64024de5f 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.3.10-beta + * Version: 7.3.10 * Author: Mollie * Author URI: https://www.mollie.com * Requires at least: 5.0