diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 6a122d7aa..940e1c7c7 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -328,10 +328,11 @@ return array( } ), 'wcgateway.notice.connect' => static function ( ContainerInterface $container ): ConnectAdminNotice { - $state = $container->get( 'onboarding.state' ); - $settings = $container->get( 'wcgateway.settings' ); - $is_current_country_send_only = $container->get( 'wcgateway.is-send-only-country' ); - return new ConnectAdminNotice( $state, $settings, $is_current_country_send_only ); + return new ConnectAdminNotice( + $container->get( 'settings.flag.is-connected' ), + $container->get( 'wcgateway.settings' ), + $container->get( 'wcgateway.is-send-only-country' ) + ); }, 'wcgateway.notice.currency-unsupported' => static function ( ContainerInterface $container ): UnsupportedCurrencyAdminNotice { $state = $container->get( 'onboarding.state' ); diff --git a/modules/ppcp-wc-gateway/src/Notice/ConnectAdminNotice.php b/modules/ppcp-wc-gateway/src/Notice/ConnectAdminNotice.php index 60085a992..c667277c6 100644 --- a/modules/ppcp-wc-gateway/src/Notice/ConnectAdminNotice.php +++ b/modules/ppcp-wc-gateway/src/Notice/ConnectAdminNotice.php @@ -10,7 +10,6 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\WcGateway\Notice; use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message; -use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; @@ -20,11 +19,11 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; class ConnectAdminNotice { /** - * The state. + * Whether the merchant completed the onboarding and is connected to PayPal. * - * @var State + * @var bool */ - private $state; + private bool $is_connected; /** * The settings. @@ -43,12 +42,16 @@ class ConnectAdminNotice { /** * ConnectAdminNotice constructor. * - * @param State $state The state. + * @param bool $is_connected Whether onboarding was completed. * @param ContainerInterface $settings The settings. * @param bool $is_current_country_send_only Whether the current store's country is classified as a send-only country. */ - public function __construct( State $state, ContainerInterface $settings, bool $is_current_country_send_only ) { - $this->state = $state; + public function __construct( + bool $is_connected, + ContainerInterface $settings, + bool $is_current_country_send_only + ) { + $this->is_connected = $is_connected; $this->settings = $settings; $this->is_current_country_send_only = $is_current_country_send_only; } @@ -77,9 +80,13 @@ class ConnectAdminNotice { /** * Whether the message should display. * + * Only display the "almost ready" message for merchants that did not complete + * the onboarding wizard. Also, ensure their store country is eligible for + * collecting PayPal payments. + * * @return bool */ protected function should_display(): bool { - return $this->state->current_state() !== State::STATE_ONBOARDED && $this->is_current_country_send_only === false; + return ! $this->is_connected && ! $this->is_current_country_send_only; } }