diff --git a/changelog/fix-8813-consistency-of-woopayments-manage-settings-button b/changelog/fix-8813-consistency-of-woopayments-manage-settings-button new file mode 100644 index 00000000000..887ffad262b --- /dev/null +++ b/changelog/fix-8813-consistency-of-woopayments-manage-settings-button @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Improve consistency of Manage button for different WooPayments KYC states diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index 4b4a2fec01c..cc980eb9e45 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -1054,6 +1054,7 @@ public function maybe_handle_onboarding() { } if ( isset( $_GET['wcpay-connect'] ) && check_admin_referer( 'wcpay-connect' ) ) { + $wcpay_connect_param = sanitize_text_field( wp_unslash( $_GET['wcpay-connect'] ) ); $incentive = ! empty( $_GET['promo'] ) ? sanitize_text_field( wp_unslash( $_GET['promo'] ) ) : ''; $progressive = ! empty( $_GET['progressive'] ) && 'true' === $_GET['progressive']; $create_builder_account = ! empty( $_GET['create_builder_account'] ) && 'true' === $_GET['create_builder_account']; @@ -1095,7 +1096,27 @@ public function maybe_handle_onboarding() { WC_Payments_Onboarding_Service::set_test_mode( false ); } - $this->redirect_to_onboarding_flow_page( $connect_page_source ); + if ( WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE === $connect_page_source ) { + $this->redirect_to_onboarding_welcome_page(); + } else { + $this->redirect_to_onboarding_flow_page( $connect_page_source ); + } + } elseif ( WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE === $connect_page_source && ! $this->is_details_submitted() ) { + try { + $this->init_stripe_onboarding( + $wcpay_connect_param, + [ + 'promo' => $incentive, + 'progressive' => $progressive, + ] + ); + } catch ( Exception $e ) { + Logger::error( 'Init Stripe onboarding flow failed. ' . $e ); + $this->redirect_to_onboarding_welcome_page( + __( 'There was a problem redirecting you to the account connection page. Please try again.', 'woocommerce-payments' ) + ); + } + return; } else { // Accounts with Stripe account connected will be redirected to the overview page. $this->redirect_to( static::get_overview_page_url() ); @@ -1160,8 +1181,6 @@ public function maybe_handle_onboarding() { ); } - $wcpay_connect_param = sanitize_text_field( wp_unslash( $_GET['wcpay-connect'] ) ); - try { $this->maybe_init_jetpack_connection( $wcpay_connect_param,