diff --git a/changelog/fix-WOOPMNT-5223-activate-payments-notice-on-live-account b/changelog/fix-WOOPMNT-5223-activate-payments-notice-on-live-account new file mode 100644 index 00000000000..1893bef6acb --- /dev/null +++ b/changelog/fix-WOOPMNT-5223-activate-payments-notice-on-live-account @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Show Activate payments notice in WooPayments Settings only for test accounts. diff --git a/includes/admin/class-wc-payments-admin-settings.php b/includes/admin/class-wc-payments-admin-settings.php index 13cdc367a60..494fe5d9839 100644 --- a/includes/admin/class-wc-payments-admin-settings.php +++ b/includes/admin/class-wc-payments-admin-settings.php @@ -17,6 +17,13 @@ class WC_Payments_Admin_Settings { */ private $gateway; + /** + * Instance of WC_Payments_Account + * + * @var WC_Payments_Account + */ + private $account; + /** * Set of parameters to build the URL to the gateway's settings page. * @@ -32,9 +39,11 @@ class WC_Payments_Admin_Settings { * Initialize class actions. * * @param WC_Payment_Gateway_WCPay $gateway Payment Gateway. + * @param WC_Payments_Account $account The account service. */ - public function __construct( WC_Payment_Gateway_WCPay $gateway ) { + public function __construct( WC_Payment_Gateway_WCPay $gateway, WC_Payments_Account $account ) { $this->gateway = $gateway; + $this->account = $account; } /** @@ -43,44 +52,132 @@ public function __construct( WC_Payment_Gateway_WCPay $gateway ) { * @return void */ public function init_hooks() { - add_action( 'woocommerce_woocommerce_payments_admin_notices', [ $this, 'display_test_mode_notice' ] ); + add_action( 'woocommerce_woocommerce_payments_admin_notices', [ $this, 'maybe_show_test_mode_notice' ] ); + add_action( 'woocommerce_woocommerce_payments_admin_notices', [ $this, 'maybe_show_test_account_notice' ] ); + add_action( 'woocommerce_woocommerce_payments_admin_notices', [ $this, 'maybe_show_sandbox_account_notice' ] ); add_filter( 'plugin_action_links_' . plugin_basename( WCPAY_PLUGIN_FILE ), [ $this, 'add_plugin_links' ] ); } /** - * Add notice explaining test mode when it's enabled. + * Add notice about payments being in test mode when using a live account. + * + * This notice is mutually exclusive with the test account and sandbox account notices. + * + * @see self::maybe_show_test_account_notice() + * @see self::maybe_show_sandbox_account_notice() */ - public function display_test_mode_notice() { - if ( WC_Payments::mode()->is_test() ) { - ?> -
- + public function maybe_show_test_mode_notice() { + // If there is no valid account connected, bail. + if ( ! $this->gateway->is_connected() || ! $this->account->is_stripe_account_valid() ) { + return; + } + + // If this is not a live account, bail since we will inform the user about the test account instead. + if ( ! $this->account->get_is_live() ) { + return; + } + + // If the test mode is not enabled, bail. + if ( ! WC_Payments::mode()->is_test() ) { + return; + } + + // Output the notice. + ?> +
+ Learn more', 'woocommerce-payments' ), - ), - esc_url( 'https://woocommerce.com/document/woopayments/startup-guide/#sign-up-process' ) + /* translators: %s: WooPayments */ + esc_html__( '%s is in test mode — all transactions are simulated!', 'woocommerce-payments' ) . ' ', + 'WooPayments' ); ?> -
+ + ', + '' + ); + ?> + ++ + is_dev() ) { + printf( + /* translators: %s: URL to learn more */ + esc_html__( 'Provide additional details about your business so you can begin accepting real payments. %1$sLearn more%2$s', 'woocommerce-payments' ), + '', + '' + ); + } else { + esc_html_e( '⚠️ Development mode is enabled for the store! There can be no live onboarding process while using development, testing, or staging WordPress environments!', 'woocommerce-payments' ); + echo ''; + printf( + /* translators: 1: Anchor opening tag; 2: Anchor closing tag; 3: Anchor opening tag; 4: Anchor closing tag */ + esc_html__( 'To begin accepting real payments, please go to the live store or change your %1$sWordPress environment%2$s to a production one. %3$sLearn more%4$s', 'woocommerce-payments' ), + '', + '', + '', + '' + ); + } + ?> +
+ is_dev() ) { ?> -