mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
✨ Sync onboarding completion with connection state
This commit is contained in:
parent
b3e766d08a
commit
a9c2a8e8fe
2 changed files with 35 additions and 7 deletions
|
@ -398,11 +398,15 @@ class AuthenticationManager {
|
|||
$this->common_settings->set_merchant_data( $connection );
|
||||
$this->common_settings->save();
|
||||
|
||||
/**
|
||||
* Broadcast that the plugin connected to a new PayPal merchant account.
|
||||
* This is the right time to initialize merchant relative flags for the
|
||||
* first time.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_authenticated_merchant' );
|
||||
if ( $this->common_settings->is_merchant_connected() ) {
|
||||
$this->logger->info( 'Merchant successfully connected to PayPal' );
|
||||
|
||||
/**
|
||||
* Broadcast that the plugin connected to a new PayPal merchant account.
|
||||
* This is the right time to initialize merchant relative flags for the
|
||||
* first time.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_authenticated_merchant' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,9 @@ declare( strict_types = 1 );
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\Settings\Endpoint\RestEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Settings\Ajax\SwitchSettingsUiEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Settings\Data\OnboardingProfile;
|
||||
use WooCommerce\PayPalCommerce\Settings\Endpoint\RestEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Settings\Handler\ConnectionListener;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
|
||||
|
@ -203,6 +204,29 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
|||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_merchant_disconnected',
|
||||
static function () use ( $container ) : void {
|
||||
$onboarding_profile = $container->get( 'settings.data.onboarding' );
|
||||
assert( $onboarding_profile instanceof OnboardingProfile );
|
||||
|
||||
$onboarding_profile->set_completed( false );
|
||||
$onboarding_profile->set_step( 0 );
|
||||
$onboarding_profile->save();
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_authenticated_merchant',
|
||||
static function () use ( $container ) : void {
|
||||
$onboarding_profile = $container->get( 'settings.data.onboarding' );
|
||||
assert( $onboarding_profile instanceof OnboardingProfile );
|
||||
|
||||
$onboarding_profile->set_completed( true );
|
||||
$onboarding_profile->save();
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue