diff --git a/client/data/settings/action-types.js b/client/data/settings/action-types.js
index 1ab9b296bb6..9b4986ff0d6 100644
--- a/client/data/settings/action-types.js
+++ b/client/data/settings/action-types.js
@@ -6,5 +6,6 @@ export default {
SET_ENABLED_PAYMENT_METHOD_IDS: 'SET_ENABLED_PAYMENT_METHOD_IDS',
SET_IS_SAVING_SETTINGS: 'SET_IS_SAVING_SETTINGS',
SET_IS_MANUAL_CAPTURE_ENABLED: 'SET_IS_MANUAL_CAPTURE_ENABLED',
+ SET_IS_TEST_MODE_ENABLED: 'SET_IS_TEST_MODE_ENABLED',
SET_ACCOUNT_STATEMENT_DESCRIPTOR: 'SET_ACCOUNT_STATEMENT_DESCRIPTOR',
};
diff --git a/client/data/settings/actions.js b/client/data/settings/actions.js
index d5bc29d874e..a9ef75f3557 100644
--- a/client/data/settings/actions.js
+++ b/client/data/settings/actions.js
@@ -48,6 +48,13 @@ export function updateIsManualCaptureEnabled( isEnabled ) {
};
}
+export function updateIsTestModeEnabled( isEnabled ) {
+ return {
+ type: ACTION_TYPES.SET_IS_TEST_MODE_ENABLED,
+ isEnabled,
+ };
+}
+
export function updateAccountStatementDescriptor( accountStatementDescriptor ) {
return {
type: ACTION_TYPES.SET_ACCOUNT_STATEMENT_DESCRIPTOR,
diff --git a/client/data/settings/hooks.js b/client/data/settings/hooks.js
index e67cc303fcb..8249f324622 100644
--- a/client/data/settings/hooks.js
+++ b/client/data/settings/hooks.js
@@ -26,6 +26,32 @@ export const useEnabledPaymentMethodIds = () => {
);
};
+export const useTestMode = () => {
+ const { updateIsTestModeEnabled } = useDispatch( STORE_NAME );
+
+ return useSelect(
+ ( select ) => {
+ const { getIsTestModeEnabled } = select( STORE_NAME );
+
+ return {
+ isEnabled: getIsTestModeEnabled(),
+ updateIsTestModeEnabled,
+ };
+ },
+ [ updateIsTestModeEnabled ]
+ );
+};
+
+export const useDevMode = () => {
+ return useSelect( ( select ) => {
+ const { getIsDevModeEnabled } = select( STORE_NAME );
+
+ return {
+ isEnabled: getIsDevModeEnabled(),
+ };
+ }, [] );
+};
+
export const useGeneralSettings = () => {
const { updateAccountStatementDescriptor } = useDispatch( STORE_NAME );
const { updateIsManualCaptureEnabled } = useDispatch( STORE_NAME );
diff --git a/client/data/settings/reducer.js b/client/data/settings/reducer.js
index 8a8bcc88acd..47896c00b1b 100644
--- a/client/data/settings/reducer.js
+++ b/client/data/settings/reducer.js
@@ -46,6 +46,7 @@ export const receiveSettings = (
is_wcpay_enabled: action.isEnabled,
},
};
+
case ACTION_TYPES.SET_IS_MANUAL_CAPTURE_ENABLED:
return {
...state,
@@ -55,6 +56,17 @@ export const receiveSettings = (
is_manual_capture_enabled: action.isEnabled,
},
};
+
+ case ACTION_TYPES.SET_IS_TEST_MODE_ENABLED:
+ return {
+ ...state,
+ data: {
+ ...state.data,
+ // eslint-disable-next-line camelcase
+ is_test_mode_enabled: action.isEnabled,
+ },
+ };
+
case ACTION_TYPES.SET_ACCOUNT_STATEMENT_DESCRIPTOR:
return {
...state,
diff --git a/client/data/settings/selectors.js b/client/data/settings/selectors.js
index fbf00a377ca..c887f7c3eab 100644
--- a/client/data/settings/selectors.js
+++ b/client/data/settings/selectors.js
@@ -38,3 +38,11 @@ export const getAccountStatementDescriptor = ( state ) => {
export const getIsManualCaptureEnabled = ( state ) => {
return getSettings( state ).is_manual_capture_enabled || false;
};
+
+export const getIsTestModeEnabled = ( state ) => {
+ return getSettings( state ).is_test_mode_enabled || false;
+};
+
+export const getIsDevModeEnabled = ( state ) => {
+ return getSettings( state ).is_dev_mode_enabled || false;
+};
diff --git a/client/settings/settings-manager/index.js b/client/settings/settings-manager/index.js
index d3b7143078b..f1c9ac43fd8 100644
--- a/client/settings/settings-manager/index.js
+++ b/client/settings/settings-manager/index.js
@@ -99,7 +99,9 @@ const SettingsManager = ( { accountStatus = {} } ) => {
-
+
+
+