From 85e3c2306b1c9e1b1230276072978c6970d7a73c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:53:20 +0000 Subject: [PATCH 1/3] Update version and add changelog entries for release 8.2.2 --- changelog.txt | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 5 ++++- woocommerce-payments.php | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index a0ab5a31932..4c5f0afc62a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ *** WooPayments Changelog *** += 8.2.2 - 2024-09-24 = + = 8.2.1 - 2024-09-13 = * Fix - Create div container element with JS dynamically. diff --git a/package-lock.json b/package-lock.json index fb0a1965e2a..0c5635e6817 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "8.2.1", + "version": "8.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "8.2.1", + "version": "8.2.2", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index fd6d97fe3f9..5b525252554 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "8.2.1", + "version": "8.2.2", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index c4f1b121e3c..c5871b25f3c 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment Requires at least: 6.0 Tested up to: 6.6 Requires PHP: 7.3 -Stable tag: 8.2.1 +Stable tag: 8.2.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,9 @@ Please note that our support for the checkout block is still experimental and th == Changelog == += 8.2.2 - 2024-09-24 = + + = 8.2.1 - 2024-09-13 = * Fix - Create div container element with JS dynamically. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index dde0e058b69..72ffe1f62b7 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -11,7 +11,7 @@ * WC tested up to: 9.2.0 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 8.2.1 + * Version: 8.2.2 * Requires Plugins: woocommerce * * @package WooCommerce\Payments From decc6eb14a3daef77dd199c0df2b9669aaa59494 Mon Sep 17 00:00:00 2001 From: Alefe Souza Date: Wed, 18 Sep 2024 21:32:34 -0300 Subject: [PATCH 2/3] Fix WooPay pre-checking place order bug when buying a subscription (#9450) --- ...opay-pre-checking-save-my-info-place-order | 4 + .../hooks/use-selected-payment-method.js | 73 +++++++++---------- 2 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 changelog/fix-woopay-pre-checking-save-my-info-place-order diff --git a/changelog/fix-woopay-pre-checking-save-my-info-place-order b/changelog/fix-woopay-pre-checking-save-my-info-place-order new file mode 100644 index 00000000000..4e98d24ab30 --- /dev/null +++ b/changelog/fix-woopay-pre-checking-save-my-info-place-order @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix WooPay pre-checking place order bug when buying a subscription. diff --git a/client/components/woopay/hooks/use-selected-payment-method.js b/client/components/woopay/hooks/use-selected-payment-method.js index 608fe247ffb..f94289715f5 100644 --- a/client/components/woopay/hooks/use-selected-payment-method.js +++ b/client/components/woopay/hooks/use-selected-payment-method.js @@ -2,40 +2,22 @@ * External dependencies */ import { useEffect, useState } from 'react'; +import { useSelect } from '@wordpress/data'; +import { PAYMENT_STORE_KEY } from '@woocommerce/block-data'; // eslint-disable-line import/no-unresolved -const getWCPayRadioButtonStatus = ( isBlocksCheckout ) => - isBlocksCheckout - ? document.querySelector( - '#radio-control-wc-payment-method-options-woocommerce_payments' - )?.checked - : document.querySelector( '#payment_method_woocommerce_payments' ) - ?.checked; - -const getNewPaymentTokenRadioButtonStatus = ( isBlocksCheckout ) => - isBlocksCheckout - ? document.querySelector( - '#radio-control-wc-payment-method-options-woocommerce_payments' - )?.checked - : document.querySelector( '#wc-woocommerce_payments-payment-token-new' ) - ?.checked || - ! document.querySelector( - '[type=radio][name="wc-woocommerce_payments-payment-token"]' - ); +const getWCPayRadioButtonStatus = () => { + return document.querySelector( '#payment_method_woocommerce_payments' ) + ?.checked; +}; -const getPaymentMethods = ( isBlocksCheckout ) => { - if ( isBlocksCheckout ) { - // For blocks checkout there is no common selector to find all the payment methods including the - // saved tokens. Thus need to concate them here to make a whole list. - return [ - ...document.querySelectorAll( - '[type=radio][name="radio-control-wc-payment-method-options"]' - ), - ...document.querySelectorAll( - '[type=radio][name="radio-control-wc-payment-method-saved-tokens"]' - ), - ]; - } - // for classic checkout +const getNewPaymentTokenRadioButtonStatus = () => + document.querySelector( '#wc-woocommerce_payments-payment-token-new' ) + ?.checked || + ! document.querySelector( + '[type=radio][name="wc-woocommerce_payments-payment-token"]' + ); + +const getPaymentMethods = () => { return document.querySelectorAll( '[type=radio][name="payment_method"]' ); }; @@ -51,15 +33,28 @@ const getPaymentTokens = ( isBlocksCheckout ) => { // hook for checking if WCPay is selected. const useSelectedPaymentMethod = ( isBlocksCheckout ) => { + // For blocks checkout, we use the store to get the active payment method. + const { isWCPayChosenOnBlocksCheckout } = useSelect( ( select ) => { + const store = select( PAYMENT_STORE_KEY ); + return { + isWCPayChosenOnBlocksCheckout: + store.getActivePaymentMethod() === 'woocommerce_payments', + }; + } ); + const [ isWCPayChosen, setIsWCPayChosen ] = useState( - getWCPayRadioButtonStatus( isBlocksCheckout ) + ! isBlocksCheckout && getWCPayRadioButtonStatus() ); const [ isNewPaymentTokenChosen, setNewPaymentTokenChosen ] = useState( - getNewPaymentTokenRadioButtonStatus( isBlocksCheckout ) + ! isBlocksCheckout && getNewPaymentTokenRadioButtonStatus() ); useEffect( () => { + if ( isBlocksCheckout ) { + return; + } + // hides the `Save payment information to my account for future purchases` checkbox. const hideCheckbox = () => { const checkbox = document.querySelector( @@ -87,7 +82,7 @@ const useSelectedPaymentMethod = ( isBlocksCheckout ) => { ); }; - const paymentMethods = getPaymentMethods( isBlocksCheckout ); + const paymentMethods = getPaymentMethods(); paymentMethods.forEach( ( paymentMethod ) => { paymentMethod.addEventListener( 'change', updateIsWCPayChosen ); @@ -119,8 +114,12 @@ const useSelectedPaymentMethod = ( isBlocksCheckout ) => { }, [ isBlocksCheckout ] ); return { - isWCPayChosen, - isNewPaymentTokenChosen, + isWCPayChosen: isBlocksCheckout + ? isWCPayChosenOnBlocksCheckout + : isWCPayChosen, + isNewPaymentTokenChosen: isBlocksCheckout + ? isWCPayChosenOnBlocksCheckout + : isNewPaymentTokenChosen, }; }; From 86fb43be3def838e5a79b23e05a9090e058f0573 Mon Sep 17 00:00:00 2001 From: botwoo Date: Tue, 24 Sep 2024 07:00:01 +0000 Subject: [PATCH 3/3] Amend changelog entries for release 8.2.2 --- changelog.txt | 1 + changelog/fix-woopay-pre-checking-save-my-info-place-order | 4 ---- readme.txt | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 changelog/fix-woopay-pre-checking-save-my-info-place-order diff --git a/changelog.txt b/changelog.txt index 4c5f0afc62a..4f1bdeb437b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** WooPayments Changelog *** = 8.2.2 - 2024-09-24 = +* Fix - Fix WooPay pre-checking place order bug when buying a subscription. = 8.2.1 - 2024-09-13 = * Fix - Create div container element with JS dynamically. diff --git a/changelog/fix-woopay-pre-checking-save-my-info-place-order b/changelog/fix-woopay-pre-checking-save-my-info-place-order deleted file mode 100644 index 4e98d24ab30..00000000000 --- a/changelog/fix-woopay-pre-checking-save-my-info-place-order +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix WooPay pre-checking place order bug when buying a subscription. diff --git a/readme.txt b/readme.txt index c5871b25f3c..219da74fc9a 100644 --- a/readme.txt +++ b/readme.txt @@ -95,6 +95,7 @@ Please note that our support for the checkout block is still experimental and th == Changelog == = 8.2.2 - 2024-09-24 = +* Fix - Fix WooPay pre-checking place order bug when buying a subscription. = 8.2.1 - 2024-09-13 =