Skip to content

Commit

Permalink
Improve consistency of Manage button for different WooPayments KYC st…
Browse files Browse the repository at this point in the history
…ates (#8900)

Co-authored-by: oaratovskyi <oleksandr.aratovskyi@automattic.com>
  • Loading branch information
oaratovskyi and oaratovskyi authored Jun 12, 2024
1 parent 9838904 commit 04b0465
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Improve consistency of Manage button for different WooPayments KYC states
25 changes: 22 additions & 3 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 04b0465

Please sign in to comment.