Commit 9a5925e91eb for woocommerce

commit 9a5925e91eb8c181b301905be483cbcfbe14a27c
Author: Luigi Teschio <gigitux@gmail.com>
Date:   Fri Nov 20 15:57:40 2026 +0100

    Require consent before payment and tax setup actions (#71237)

    (cherry picked from commit 968b83f820c2f3c9bc030f27371f4199cd126cfd)

    Co-authored-by: Ján Mikláš <neosinner@gmail.com>

diff --git a/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/Setup.js b/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/Setup.js
index 64ff72ac5aa..96c0d2391c5 100644
--- a/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/Setup.js
+++ b/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/Setup.js
@@ -2,6 +2,7 @@
  * External dependencies
  */
 import { __, sprintf } from '@wordpress/i18n';
+// eslint-disable-next-line @wordpress/use-recommended-components -- Keep the existing task card layout.
 import { Card, CardBody } from '@wordpress/components';
 import {
 	optionsStore,
@@ -45,21 +46,30 @@ export const Setup = ( { markConfigured, paymentGateway } ) => {
 		PAYMENT_GATEWAYS_STORE_NAME
 	);

-	const { isOptionUpdating, isPaymentGatewayResolving, needsPluginInstall } =
-		useSelect( ( select ) => {
-			const { isOptionsUpdating } = select( optionsStore );
-			const { isResolving } = select( PAYMENT_GATEWAYS_STORE_NAME );
-			const activePlugins = select( pluginsStore ).getActivePlugins();
-			const pluginsToInstall = plugins.filter(
-				( m ) => ! activePlugins.includes( m )
-			);
+	const {
+		isOptionUpdating,
+		isPaymentGatewayResolving,
+		needsPluginInstall,
+		isPluginInstalling,
+	} = useSelect( ( select ) => {
+		const { isOptionsUpdating } = select( optionsStore );
+		const { isResolving } = select( PAYMENT_GATEWAYS_STORE_NAME );
+		const activePlugins = select( pluginsStore ).getActivePlugins();
+		const pluginsToInstall = plugins.filter(
+			( m ) => ! activePlugins.includes( m )
+		);

-			return {
-				isOptionUpdating: isOptionsUpdating(),
-				isPaymentGatewayResolving: isResolving( 'getPaymentGateways' ),
-				needsPluginInstall: !! pluginsToInstall.length,
-			};
-		} );
+		return {
+			isOptionUpdating: isOptionsUpdating(),
+			isPaymentGatewayResolving: isResolving( 'getPaymentGateways' ),
+			needsPluginInstall: !! pluginsToInstall.length,
+			isPluginInstalling:
+				select( pluginsStore ).isPluginsRequesting(
+					'installPlugins'
+				) ||
+				select( pluginsStore ).isPluginsRequesting( 'activatePlugins' ),
+		};
+	} );

 	useEffect( () => {
 		if ( needsPluginInstall ) {
@@ -105,7 +115,6 @@ export const Setup = ( { markConfigured, paymentGateway } ) => {
 							onError={ ( errors, response ) =>
 								createNoticesFromResponse( response )
 							}
-							autoInstall
 							pluginSlugs={ plugins }
 						/>
 					),
@@ -134,10 +143,10 @@ export const Setup = ( { markConfigured, paymentGateway } ) => {
 	);

 	const stepperPending =
-		needsPluginInstall ||
+		isPluginInstalling ||
 		isOptionUpdating ||
 		isPaymentGatewayResolving ||
-		! isPluginLoaded;
+		( ! needsPluginInstall && ! isPluginLoaded );

 	const defaultStepper = (
 		<Stepper
diff --git a/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/test/setup.js b/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/test/setup.js
index 15564b970b3..db9b84809fe 100644
--- a/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/test/setup.js
+++ b/plugins/woocommerce/client/admin/client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/test/setup.js
@@ -1,12 +1,15 @@
 /**
  * External dependencies
  */
-import { render } from '@testing-library/react';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
+import { dispatch } from '@wordpress/data';
+import { pluginsStore } from '@woocommerce/data';
+import { setLocaleData, resetLocaleData } from '@wordpress/i18n';

 /**
  * Internal dependencies
  */
-import { Setup } from '..';
+import { Setup } from '../Setup';
 import { enqueueScript } from '~/utils/enqueue-script';

 jest.mock( '@woocommerce/components', () => {
@@ -14,13 +17,30 @@ jest.mock( '@woocommerce/components', () => {

 	return {
 		DynamicForm: () => <div />,
-		Plugins: () => <div />,
+		Plugins: originalModule.Plugins,
 		Stepper: originalModule.Stepper,
 	};
 } );

 jest.mock( '@woocommerce/settings' );
 jest.mock( '~/utils/enqueue-script' );
+jest.mock( '~/lib/notices', () => ( {
+	createNoticesFromResponse: jest.fn(),
+} ) );
+
+let installAndActivatePlugins;
+
+beforeEach( () => {
+	installAndActivatePlugins = jest
+		.spyOn( dispatch( pluginsStore ), 'installAndActivatePlugins' )
+		.mockResolvedValue( {
+			data: { activated: [ 'woocommerce-gateway-stripe' ] },
+		} );
+} );
+
+afterEach( () => {
+	resetLocaleData( {}, 'woocommerce' );
+} );

 const mockGateway = {
 	id: 'mock-gateway',
@@ -37,6 +57,37 @@ const defaultProps = {
 };

 describe( 'Setup', () => {
+	it.each( [ 'Install & enable', 'تثبيت وتفعيل 日本語 🛒' ] )(
+		'waits for a click before installing a gateway with button text %s',
+		async ( buttonText ) => {
+			setLocaleData(
+				{ 'Install & enable': [ buttonText ] },
+				'woocommerce'
+			);
+			render(
+				<Setup
+					{ ...defaultProps }
+					paymentGateway={ {
+						...mockGateway,
+						title: 'Platby Žluťoučký kôň العربية 日本語 🛒',
+						plugins: [ 'woocommerce-gateway-stripe' ],
+					} }
+				/>
+			);
+
+			expect( installAndActivatePlugins ).not.toHaveBeenCalled();
+			fireEvent.click(
+				screen.getByRole( 'button', { name: buttonText } )
+			);
+			await waitFor( () => {
+				expect( installAndActivatePlugins ).toHaveBeenCalledTimes( 1 );
+			} );
+			expect( installAndActivatePlugins ).toHaveBeenCalledWith( [
+				'woocommerce-gateway-stripe',
+			] );
+		}
+	);
+
 	it( 'should show a configure step', () => {
 		const { queryByText } = render( <Setup { ...defaultProps } /> );

@@ -74,8 +125,10 @@ describe( 'Setup', () => {
 		render( <Setup { ...props } /> );

 		expect( enqueueScript ).toHaveBeenCalledTimes( 1 );
-		expect( enqueueScript ).toHaveBeenCalledWith(
-			'mock-post-install-script'
+		await waitFor( () =>
+			expect( enqueueScript ).toHaveBeenCalledWith(
+				'mock-post-install-script'
+			)
 		);
 	} );
 } );
diff --git a/plugins/woocommerce/client/admin/client/task-lists/fills/tax/index.tsx b/plugins/woocommerce/client/admin/client/task-lists/fills/tax/index.tsx
index 64a82a344ef..a108c7ca00b 100644
--- a/plugins/woocommerce/client/admin/client/task-lists/fills/tax/index.tsx
+++ b/plugins/woocommerce/client/admin/client/task-lists/fills/tax/index.tsx
@@ -2,6 +2,7 @@
  * External dependencies
  */
 import { __ } from '@wordpress/i18n';
+// eslint-disable-next-line @wordpress/use-recommended-components -- Keep the existing task card layout.
 import { Card, CardBody, Spinner } from '@wordpress/components';
 import { useDispatch, useSelect } from '@wordpress/data';
 import { getAdminLink } from '@woocommerce/settings';
@@ -185,13 +186,6 @@ export const Tax = ( { onComplete, query, task }: TaxProps ) => {
 		// eslint-disable-next-line react-hooks/exhaustive-deps -- the partner list shouldn't be changing in the middle of interaction. for some reason the country is becoming null in a re-render and causing unexpected behaviour
 	}, [] );

-	const { auto } = query;
-	useEffect( () => {
-		if ( auto === 'true' ) {
-			void onAutomate();
-		}
-	}, [ auto, onAutomate ] );
-
 	useEffect( () => {
 		if ( query.partner ) {
 			return;
diff --git a/plugins/woocommerce/client/admin/client/task-lists/fills/tax/test/index.tsx b/plugins/woocommerce/client/admin/client/task-lists/fills/tax/test/index.tsx
index 19c54a73ed4..af46e540851 100644
--- a/plugins/woocommerce/client/admin/client/task-lists/fills/tax/test/index.tsx
+++ b/plugins/woocommerce/client/admin/client/task-lists/fills/tax/test/index.tsx
@@ -1,10 +1,11 @@
 /**
  * External dependencies
  */
-import { render, screen, fireEvent } from '@testing-library/react';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
 import { TaskType } from '@woocommerce/data';
-import { useSelect } from '@wordpress/data';
+import { useDispatch, useSelect } from '@wordpress/data';
 import { recordEvent } from '@woocommerce/tracks';
+import { setLocaleData, resetLocaleData } from '@wordpress/i18n';

 /**
  * Internal dependencies
@@ -14,6 +15,7 @@ import { Tax } from '..';
 jest.mock( '@wordpress/data', () => ( {
 	...jest.requireActual( '@wordpress/data' ),
 	useSelect: jest.fn(),
+	useDispatch: jest.fn(),
 } ) );

 jest.mock( '@woocommerce/tracks', () => ( {
@@ -37,11 +39,19 @@ beforeEach( () => {
 		woocommerceTaxCountries: [ 'US' ],
 	};

-	( useSelect as jest.Mock ).mockImplementation( () => ( {
+	( useSelect as jest.Mock ).mockReturnValue( {
 		generalSettings: {
 			woocommerce_default_country: 'US',
 		},
-	} ) );
+	} );
+	( useDispatch as jest.Mock ).mockReturnValue( {
+		updateAndPersistSettingsForGroup: jest.fn().mockResolvedValue( {} ),
+		createNotice: jest.fn(),
+	} );
+} );
+
+afterEach( () => {
+	resetLocaleData( {}, 'woocommerce' );
 } );

 const assertWooCommerceTaxIsNotRecommended = () => {
@@ -56,6 +66,49 @@ const assertWooCommerceTaxIsNotRecommended = () => {
 	).toBeInTheDocument();
 };

+it.each( [ 'Yes please', 'نعم من فضلك 日本語 🛒' ] )(
+	'requires a click to enable automated taxes with button text %s',
+	async ( buttonText ) => {
+		setLocaleData( { 'Yes please': [ buttonText ] }, 'woocommerce' );
+		const updateSettings = jest.fn().mockResolvedValue( {} );
+		const onComplete = jest.fn();
+		( useSelect as jest.Mock ).mockReturnValue( {
+			generalSettings: {
+				woocommerce_default_country: 'US',
+				woocommerce_store_address: 'Žltá ulica 123 العربية 日本語 🛒',
+				woocommerce_store_postcode: '90210',
+			},
+			isJetpackConnected: true,
+			pluginsToActivate: [],
+		} );
+		( useDispatch as jest.Mock ).mockReturnValue( {
+			updateAndPersistSettingsForGroup: updateSettings,
+			createNotice: jest.fn(),
+		} );
+
+		render(
+			<Tax
+				onComplete={ onComplete }
+				query={ { auto: 'true', partner: 'woocommerce-tax' } }
+				task={ fakeTask as TaskType }
+			/>
+		);
+
+		expect( updateSettings ).not.toHaveBeenCalled();
+		fireEvent.click( screen.getByRole( 'button', { name: buttonText } ) );
+		await waitFor( () => expect( onComplete ).toHaveBeenCalledTimes( 1 ) );
+		expect( updateSettings ).toHaveBeenCalledTimes( 2 );
+		expect( updateSettings ).toHaveBeenCalledWith( 'general', {
+			general: expect.objectContaining( {
+				woocommerce_calc_taxes: 'yes',
+			} ),
+		} );
+		expect( updateSettings ).toHaveBeenCalledWith( 'tax', {
+			tax: { wc_connect_taxes_enabled: 'yes' },
+		} );
+	}
+);
+
 it( 'renders WooCommerce Tax (powered by WCS&T)', () => {
 	render(
 		<Tax
diff --git a/plugins/woocommerce/client/admin/eslint-suppressions.json b/plugins/woocommerce/client/admin/eslint-suppressions.json
index b9e5d0d11fa..ce705652b25 100644
--- a/plugins/woocommerce/client/admin/eslint-suppressions.json
+++ b/plugins/woocommerce/client/admin/eslint-suppressions.json
@@ -289,11 +289,6 @@
       "count": 2
     }
   },
-  "client/task-lists/fills/PaymentGatewaySuggestions/components/Setup/Setup.js": {
-    "@wordpress/use-recommended-components": {
-      "count": 2
-    }
-  },
   "client/task-lists/fills/PaymentGatewaySuggestions/components/WCPayBNPL/Suggestion.js": {
     "@wordpress/use-recommended-components": {
       "count": 3
@@ -319,11 +314,6 @@
       "count": 3
     }
   },
-  "client/task-lists/fills/tax/index.tsx": {
-    "@wordpress/use-recommended-components": {
-      "count": 2
-    }
-  },
   "client/task-lists/setup-task-list/components/task-list-completed-header.tsx": {
     "@wordpress/use-recommended-components": {
       "count": 2