Skip to content

Commit

Permalink
Update dev mode to Sandbox mode throughout the plugin (#8004)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Olaru <[email protected]>
  • Loading branch information
dmallory42 and vladolaru authored Jan 20, 2024
1 parent 21a024b commit 8f6b267
Show file tree
Hide file tree
Showing 24 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions changelog/update-dev-mode-labels
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Update references to dev mode to use sandbox mode terminology.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions client/components/test-mode-notice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -87,7 +87,7 @@ const getNoticeContent = (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<Link
href={
'https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/'
'https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/'
}
target="_blank"
rel="noreferrer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ exports[`Test mode notification Returns valid component for overview page 1`] =
All transactions will be simulated.
<a
data-link-type="wc-admin"
href="https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/"
href="https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/"
rel="noreferrer"
target="_blank"
>
Expand Down
2 changes: 1 addition & 1 deletion client/onboarding/steps/test/mode-choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion client/onboarding/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down
2 changes: 1 addition & 1 deletion client/overview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]
Expand Down
2 changes: 1 addition & 1 deletion client/overview/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion client/settings/advanced-settings/debug-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down
6 changes: 3 additions & 3 deletions client/settings/advanced-settings/test/debug-mode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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( <DebugMode /> );

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(
Expand Down
4 changes: 2 additions & 2 deletions client/settings/general-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
),
Expand All @@ -128,7 +128,7 @@ const GeneralSettings = () => {
<a
target="_blank"
rel="noreferrer"
href="https://woo.com/document/woopayments/testing-and-troubleshooting/dev-mode/"
href="https://woo.com/document/woopayments/testing-and-troubleshooting/sandbox-mode/"
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<TestModeConfirmationModal
Expand All @@ -25,7 +25,7 @@ describe( 'Dev Mode Confirmation Modal', () => {
);
};

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?' )
Expand Down
2 changes: 1 addition & 1 deletion client/settings/support-phone-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions client/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-wc-payments-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/class-wc-rest-payments-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions includes/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions includes/core/class-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion includes/core/server/request/class-get-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8f6b267

Please sign in to comment.