mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Redirect to connection tab after manual credentials input
This commit is contained in:
parent
ec04c02b3d
commit
3ca9b444fe
1 changed files with 23 additions and 6 deletions
|
@ -193,10 +193,7 @@ class SettingsListener {
|
|||
*/
|
||||
do_action( 'woocommerce_paypal_payments_onboarding_before_redirect' );
|
||||
|
||||
/**
|
||||
* The URL opened at the end of onboarding after saving the merchant ID/email.
|
||||
*/
|
||||
$redirect_url = apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ) );
|
||||
$redirect_url = $this->get_onboarding_redirect_url();
|
||||
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
|
||||
$redirect_url = add_query_arg( 'ppcp-onboarding-error', '1', $redirect_url );
|
||||
}
|
||||
|
@ -347,9 +344,17 @@ class SettingsListener {
|
|||
$this->dcc_status_cache->delete( DCCProductStatus::DCC_STATUS_CACHE_KEY );
|
||||
}
|
||||
|
||||
$redirect_url = false;
|
||||
if ( self::CREDENTIALS_ADDED === $credentials_change_status ) {
|
||||
$redirect_url = $this->get_onboarding_redirect_url();
|
||||
}
|
||||
|
||||
if ( isset( $_GET['ppcp-onboarding-error'] ) ) {
|
||||
$url = remove_query_arg( 'ppcp-onboarding-error' );
|
||||
wp_safe_redirect( $url, 302 );
|
||||
$redirect_url = remove_query_arg( 'ppcp-onboarding-error', $redirect_url );
|
||||
}
|
||||
|
||||
if ( $redirect_url ) {
|
||||
wp_safe_redirect( $redirect_url, 302 );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -357,6 +362,18 @@ class SettingsListener {
|
|||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL opened at the end of onboarding.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_onboarding_redirect_url(): string {
|
||||
/**
|
||||
* The URL opened at the end of onboarding after saving the merchant ID/email.
|
||||
*/
|
||||
return apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual used client credentials are stored in 'client_secret', 'client_id', 'merchant_id' and 'merchant_email'.
|
||||
* This method populates those fields depending on the sandbox status.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue