From 8f6b267928fb12bee30cb0ba6d1773e9c24b4ff2 Mon Sep 17 00:00:00 2001 From: Daniel Mallory Date: Sat, 20 Jan 2024 20:47:12 +0000 Subject: [PATCH] Update dev mode to Sandbox mode throughout the plugin (#8004) Co-authored-by: Vlad Olaru --- README.md | 2 +- changelog/update-dev-mode-labels | 4 ++++ .../account-status/account-tools/test/index.test.tsx | 2 +- client/components/test-mode-notice/index.tsx | 4 ++-- .../test-mode-notice/test/__snapshots__/index.tsx.snap | 2 +- client/onboarding/steps/test/mode-choice.tsx | 2 +- client/onboarding/strings.tsx | 2 +- client/overview/index.js | 2 +- client/overview/strings.tsx | 2 +- client/settings/advanced-settings/debug-mode.js | 2 +- client/settings/advanced-settings/test/debug-mode.test.js | 6 +++--- client/settings/general-settings/index.js | 4 ++-- .../general-settings/test/test-mode-confirm-modal.test.js | 4 ++-- client/settings/support-phone-input/index.js | 2 +- .../support-phone-input/test/support-phone-input.test.js | 2 +- client/utils/index.js | 6 +++--- includes/admin/class-wc-payments-admin.php | 2 +- .../admin/class-wc-rest-payments-settings-controller.php | 4 ++-- includes/class-wc-payment-gateway-wcpay.php | 4 ++-- includes/class-wc-payments-account.php | 2 +- includes/core/README.md | 6 +++--- includes/core/class-mode.php | 6 +++--- .../core/server/request/class-get-account-login-data.md | 2 +- includes/core/server/request/class-get-account.md | 2 +- 24 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 changelog/update-dev-mode-labels diff --git a/README.md b/README.md index 72508e1b51a..f43b580b083 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ We currently support the following variables: ## Test account setup -For setting up a test account follow [these instructions](https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/). +For setting up a test account follow [these instructions](https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/). You will need a externally accessible URL to set up the plugin. You can use ngrok for this. diff --git a/changelog/update-dev-mode-labels b/changelog/update-dev-mode-labels new file mode 100644 index 00000000000..df9ff952e45 --- /dev/null +++ b/changelog/update-dev-mode-labels @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Update references to dev mode to use sandbox mode terminology. diff --git a/client/components/account-status/account-tools/test/index.test.tsx b/client/components/account-status/account-tools/test/index.test.tsx index 7c5827b115a..295970da639 100644 --- a/client/components/account-status/account-tools/test/index.test.tsx +++ b/client/components/account-status/account-tools/test/index.test.tsx @@ -31,7 +31,7 @@ describe( 'AccountTools', () => { expect( container ).toMatchSnapshot(); } ); - it( 'should not render in dev mode', () => { + it( 'should not render in sandbox mode', () => { global.wcpaySettings = { devMode: true, }; diff --git a/client/components/test-mode-notice/index.tsx b/client/components/test-mode-notice/index.tsx index 80310707a46..f77dcaff4a7 100644 --- a/client/components/test-mode-notice/index.tsx +++ b/client/components/test-mode-notice/index.tsx @@ -59,7 +59,7 @@ const getNoticeContent = ( mixedString: sprintf( /* translators: %1$s: WooPayments */ __( - '{{strong}}%1$s is in dev mode.{{/strong}} You need to set up a live %1$s account before you can accept real transactions.', + '{{strong}}%1$s is in sandbox mode.{{/strong}} You need to set up a live %1$s account before you can accept real transactions.', 'woocommerce-payments' ), 'WooPayments' @@ -87,7 +87,7 @@ const getNoticeContent = ( // eslint-disable-next-line jsx-a11y/anchor-has-content diff --git a/client/onboarding/steps/test/mode-choice.tsx b/client/onboarding/steps/test/mode-choice.tsx index 4ad0f2996e0..d6400d98936 100644 --- a/client/onboarding/steps/test/mode-choice.tsx +++ b/client/onboarding/steps/test/mode-choice.tsx @@ -27,7 +27,7 @@ declare const global: { }; describe( 'ModeChoice', () => { - it( 'displays test and live radio cards, notice for dev mode', () => { + it( 'displays test and live radio cards, notice for sandbox mode', () => { global.wcpaySettings = { connectUrl: 'https://wcpay.test/connect', devMode: true, diff --git a/client/onboarding/strings.tsx b/client/onboarding/strings.tsx index fdeba48f840..a1578aacb61 100644 --- a/client/onboarding/strings.tsx +++ b/client/onboarding/strings.tsx @@ -8,7 +8,7 @@ import React from 'react'; const documentationUrls = { sandboxMode: - 'https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/', + 'https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/', tos: 'https://wordpress.com/tos/', merchantTerms: 'https://wordpress.com/tos/#more-woopay-specifically', privacyPolicy: 'https://automattic.com/privacy/', diff --git a/client/overview/index.js b/client/overview/index.js index 124805902bc..fca15a172ad 100644 --- a/client/overview/index.js +++ b/client/overview/index.js @@ -152,7 +152,7 @@ const OverviewPage = () => { { label: strings.notice.actions.learnMore, url: - 'https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/', + 'https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/', urlTarget: '_blank', }, ] diff --git a/client/overview/strings.tsx b/client/overview/strings.tsx index 43ab5d47bb5..39ceda5d1e2 100644 --- a/client/overview/strings.tsx +++ b/client/overview/strings.tsx @@ -26,7 +26,7 @@ export default { mixedString: sprintf( /* translators: %1$s: WooPayments */ __( - '{{bold}}%1s is in dev mode.{{bold /}}. You need to set up a live %1s account before you can accept real transactions.', + '{{bold}}%1s is in sandbox mode.{{bold /}}. You need to set up a live %1s account before you can accept real transactions.', 'woocommerce-payments' ), 'WooPayments' diff --git a/client/settings/advanced-settings/debug-mode.js b/client/settings/advanced-settings/debug-mode.js index f1b5a09c7a3..97fcae3e63b 100644 --- a/client/settings/advanced-settings/debug-mode.js +++ b/client/settings/advanced-settings/debug-mode.js @@ -22,7 +22,7 @@ const DebugMode = () => { label={ isDevModeEnabled ? __( - 'Dev mode is active so logging is on by default.', + 'Sandbox mode is active so logging is on by default.', 'woocommerce-payments' ) : __( 'Log error messages', 'woocommerce-payments' ) diff --git a/client/settings/advanced-settings/test/debug-mode.test.js b/client/settings/advanced-settings/test/debug-mode.test.js index 54877787745..749fdaf6c73 100644 --- a/client/settings/advanced-settings/test/debug-mode.test.js +++ b/client/settings/advanced-settings/test/debug-mode.test.js @@ -34,7 +34,7 @@ describe( 'DebugMode', () => { expect( screen.queryByText( - 'Dev mode is active so logging is on by default.' + 'Sandbox mode is active so logging is on by default.' ) ).not.toBeInTheDocument(); expect( loggingCheckbox ).not.toBeChecked(); @@ -45,13 +45,13 @@ describe( 'DebugMode', () => { expect( setDebugLogMock ).toHaveBeenCalledWith( true ); } ); - it( 'prevents toggling the logging checkbox when dev mode is active', () => { + it( 'prevents toggling the logging checkbox when sandbox mode is active', () => { useDevMode.mockReturnValue( true ); render( ); const loggingCheckbox = screen.queryByRole( 'checkbox', { - name: 'Dev mode is active so logging is on by default.', + name: 'Sandbox mode is active so logging is on by default.', } ); expect( diff --git a/client/settings/general-settings/index.js b/client/settings/general-settings/index.js index b85e9e07632..cdfbd054211 100644 --- a/client/settings/general-settings/index.js +++ b/client/settings/general-settings/index.js @@ -115,7 +115,7 @@ const GeneralSettings = () => { mixedString: sprintf( /* translators: %s: WooPayments */ __( - '{{b}}%1$s is in dev mode.{{/b}} You need to set up a live %1$s account before ' + + '{{b}}%1$s is in sandbox mode.{{/b}} You need to set up a live %1$s account before ' + 'you can accept real transactions. {{learnMoreLink}}Learn more{{/learnMoreLink}}', 'woocommerce-payments' ), @@ -128,7 +128,7 @@ const GeneralSettings = () => { ), }, diff --git a/client/settings/general-settings/test/test-mode-confirm-modal.test.js b/client/settings/general-settings/test/test-mode-confirm-modal.test.js index df247142d81..a3a019a5e17 100644 --- a/client/settings/general-settings/test/test-mode-confirm-modal.test.js +++ b/client/settings/general-settings/test/test-mode-confirm-modal.test.js @@ -15,7 +15,7 @@ import TestModeConfirmationModal from '../test-mode-confirm-modal'; const mockOnClose = jest.fn(); const mockOnConfirm = jest.fn(); -describe( 'Dev Mode Confirmation Modal', () => { +describe( 'Sandbox Mode Confirmation Modal', () => { const renderTestModeConfirmationModal = () => { return render( { ); }; - it( 'Dev mode confirmation modal asks confirmation', () => { + it( 'Sandbox mode confirmation modal asks confirmation', () => { renderTestModeConfirmationModal(); expect( screen.queryByText( 'Are you sure you want to enable test mode?' ) diff --git a/client/settings/support-phone-input/index.js b/client/settings/support-phone-input/index.js index 4a9259b62d4..f4741f4ddaf 100644 --- a/client/settings/support-phone-input/index.js +++ b/client/settings/support-phone-input/index.js @@ -51,7 +51,7 @@ const SupportPhoneInput = ( { setInputVallid } ) => { let labelText = __( 'Support phone number', 'woocommerce-payments' ); if ( isDevModeEnabled ) { labelText += __( - ' (+1 0000000000 can be used in dev mode)', + ' (+1 0000000000 can be used in sandbox mode)', 'woocommerce-payments' ); } diff --git a/client/settings/support-phone-input/test/support-phone-input.test.js b/client/settings/support-phone-input/test/support-phone-input.test.js index 37262b03796..a86c66ae12e 100644 --- a/client/settings/support-phone-input/test/support-phone-input.test.js +++ b/client/settings/support-phone-input/test/support-phone-input.test.js @@ -98,7 +98,7 @@ describe( 'SupportPhoneInput', () => { ).toEqual( 'Please enter a valid phone number.' ); } ); - it( 'in dev mode, allow all 0s number', async () => { + it( 'in sandbox mode, allow all 0s number', async () => { useAccountBusinessSupportPhone.mockReturnValue( [ '+10000000000', // test phone number. jest.fn(), diff --git a/client/utils/index.js b/client/utils/index.js index d6e7a1c971d..f10cb308251 100644 --- a/client/utils/index.js +++ b/client/utils/index.js @@ -23,11 +23,11 @@ export const isInTestMode = ( fallback = false ) => { }; /** - * Returns true if WooPayments is in dev mode, false otherwise. + * Returns true if WooPayments is in dev/sandbox mode, false otherwise. * - * @param {boolean} fallback Fallback in case dev mode value can't be found (for example if the wcpaySettings are undefined). + * @param {boolean} fallback Fallback in case dev/sandbox mode value can't be found (for example if the wcpaySettings are undefined). * - * @return {boolean} True if in dev mode, false otherwise. Fallback value if test/dev mode value can't be found. + * @return {boolean} True if in dev/sandbox mode, false otherwise. Fallback value if dev/sandbox mode value can't be found. */ export const isInDevMode = ( fallback = false ) => { if ( typeof wcpaySettings === 'undefined' ) { diff --git a/includes/admin/class-wc-payments-admin.php b/includes/admin/class-wc-payments-admin.php index ff01ef19764..179c1b2ddc6 100644 --- a/includes/admin/class-wc-payments-admin.php +++ b/includes/admin/class-wc-payments-admin.php @@ -829,7 +829,7 @@ private function get_js_settings(): array { try { $dev_mode = WC_Payments::mode()->is_dev(); } catch ( Exception $e ) { - Logger::log( sprintf( 'WooPayments JS settings: Could not determine if WCPay should be in dev mode! Message: %s', $e->getMessage() ), 'warning' ); + Logger::log( sprintf( 'WooPayments JS settings: Could not determine if WCPay should be in sandbox mode! Message: %s', $e->getMessage() ), 'warning' ); } $connect_url = WC_Payments_Account::get_connect_url(); diff --git a/includes/admin/class-wc-rest-payments-settings-controller.php b/includes/admin/class-wc-rest-payments-settings-controller.php index aed37660980..97c5087e46d 100644 --- a/includes/admin/class-wc-rest-payments-settings-controller.php +++ b/includes/admin/class-wc-rest-payments-settings-controller.php @@ -677,7 +677,7 @@ private function update_is_manual_capture_enabled( WP_REST_Request $request ) { * @param WP_REST_Request $request Request object. */ private function update_is_test_mode_enabled( WP_REST_Request $request ) { - // avoiding updating test mode when dev mode is enabled. + // Avoid updating test mode when dev mode is enabled. if ( WC_Payments::mode()->is_dev() ) { return; } @@ -697,7 +697,7 @@ private function update_is_test_mode_enabled( WP_REST_Request $request ) { * @param WP_REST_Request $request Request object. */ private function update_is_debug_log_enabled( WP_REST_Request $request ) { - // avoiding updating test mode when dev mode is enabled. + // Avoid updating test mode when dev mode is enabled. if ( WC_Payments::mode()->is_dev() ) { return; } diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 3c4fc105483..7d165269b4c 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -2357,12 +2357,12 @@ public function generate_checkbox_html( $key, $data ) { if ( 'test_mode' === $key && $in_dev_mode ) { $data['custom_attributes']['disabled'] = 'disabled'; - $data['label'] = __( 'Dev mode is active so all transactions will be in test mode. This setting is only available to live accounts.', 'woocommerce-payments' ); + $data['label'] = __( 'Sandbox mode is active so all transactions will be in test mode. This setting is only available to live accounts.', 'woocommerce-payments' ); } if ( 'enable_logging' === $key && $in_dev_mode ) { $data['custom_attributes']['disabled'] = 'disabled'; - $data['label'] = __( 'Dev mode is active so logging is on by default.', 'woocommerce-payments' ); + $data['label'] = __( 'Sandbox mode is active so logging is on by default.', 'woocommerce-payments' ); } return parent::generate_checkbox_html( $key, $data ); diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index 3043b06d8a0..db60f3df5d3 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -907,7 +907,7 @@ public function maybe_redirect_onboarding_flow_to_overview(): bool { // We check it here after refreshing the cache, because merchant might have clicked back in browser (after Stripe KYC). // That will mean that no redirect from Stripe happened and user might be able to go through onboarding again if no webhook processed yet. - // That might cause issues if user selects dev onboarding after live one. + // That might cause issues if user selects sandbox onboarding after live one. // Shouldn't be called with force disconnected option enabled, otherwise we'll get current account data. if ( ! WC_Payments_Utils::force_disconnected_enabled() ) { $this->refresh_account_data(); diff --git a/includes/core/README.md b/includes/core/README.md index 45fd0a68c42..59465c1b73e 100644 --- a/includes/core/README.md +++ b/includes/core/README.md @@ -59,13 +59,13 @@ This is a singular `WCPay\Core\Mode` object, accessible through `WC_Payments::mo During initialization, the following logic is used: -1. Dev mode would be entered if: +1. Sandbox mode would be entered if: - Either [WordPress's environment type](https://developer.wordpress.org/reference/functions/wp_get_environment_type/#description) is either `development` or `staging`. - or `WCPAY_DEV_MODE` is defined and set to boolean true. 2. Test mode is entered if: - - Either Dev mode is already enabled. + - Either Sandbox mode is already enabled. - or the gateway's test mode setting is on. -3. If the gateway is neither in dev or test mode, live mode is entered. +3. If the gateway is neither in sandbox or test mode, live mode is entered. To alter this behavior, you can use the `wcpay_dev_mode` and `wcpay_test_mode` filters, for example: diff --git a/includes/core/class-mode.php b/includes/core/class-mode.php index f80fc72d2d5..721b8ea689d 100644 --- a/includes/core/class-mode.php +++ b/includes/core/class-mode.php @@ -66,9 +66,9 @@ private function maybe_init() { ); /** - * Allows WooCommerce to enter dev mode. + * Allows WooPayments to enter dev (aka sandbox) mode. * - * @see https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/ + * @see https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/ * @param bool $dev_mode The pre-determined dev mode. */ $this->dev_mode = (bool) apply_filters( 'wcpay_dev_mode', $dev_mode ); @@ -80,7 +80,7 @@ private function maybe_init() { $test_mode = $this->dev_mode || $test_mode_setting; /** - * Allows WooCommerce to enter test mode. + * Allows WooPayments to enter test mode. * * @see https://woo.com/document/woopayments/testing-and-troubleshooting/testing/#enabling-test-mode * @param bool $test_mode The pre-determined test mode. diff --git a/includes/core/server/request/class-get-account-login-data.md b/includes/core/server/request/class-get-account-login-data.md index 4ea6a6f37e9..3f3675207e4 100644 --- a/includes/core/server/request/class-get-account-login-data.md +++ b/includes/core/server/request/class-get-account-login-data.md @@ -5,7 +5,7 @@ ## Description The `WCPay\Core\Server\Request\Get_Account_Login_Data` class is used to construct the request for getting one-time dashboard login url. -Note that this request sends the test_mode flag only when the site is in the dev mode. +Note that this request sends the test_mode flag only when the site is in sandbox mode. ## Parameters diff --git a/includes/core/server/request/class-get-account.md b/includes/core/server/request/class-get-account.md index 7cdd3cd4330..48606f63de9 100644 --- a/includes/core/server/request/class-get-account.md +++ b/includes/core/server/request/class-get-account.md @@ -5,7 +5,7 @@ ## Description The `WCPay\Core\Server\Request\Get_Account` class is used to construct the request for retrieving account data. -Note that this request sends the test_mode flag only when the site is in the dev mode. +Note that this request sends the test_mode flag only when the site is in sandbox mode. ## Parameters