1919use WooCommerce \PayPalCommerce \StoreSync \Setting \AgenticSettingsModule ;
2020use WooCommerce \PayPalCommerce \StoreSync \Registration \RegistrationService ;
2121use WooCommerce \PayPalCommerce \StoreSync \Registration \RegistrationEligibility ;
22+ use WooCommerce \PayPalCommerce \StoreSync \Registration \ReconciliationService ;
2223use WooCommerce \PayPalCommerce \StoreSync \Setting \AgenticSettingsDataModel ;
2324use WooCommerce \PayPalCommerce \StoreSync \CartValidation \CartValidationProcessor ;
2425use WooCommerce \PayPalCommerce \StoreSync \CartValidation \ValidatorInterface ;
@@ -78,6 +79,9 @@ public function run( ContainerInterface $container ): bool {
7879 $ ingestion_manager = $ container ->get ( 'agentic.ingestion-manager ' );
7980 assert ( $ ingestion_manager instanceof IngestionManager );
8081
82+ $ reconciler = $ container ->get ( 'agentic.registration.reconciler ' );
83+ assert ( $ reconciler instanceof ReconciliationService );
84+
8185 // Settings extension always available (merchants need to see the toggle).
8286 $ settings_module = $ container ->get ( 'agentic.settings.module ' );
8387 assert ( $ settings_module instanceof AgenticSettingsModule );
@@ -89,6 +93,18 @@ public function run( ContainerInterface $container ): bool {
8993 // Sync eligibility cache on init (when WC is available).
9094 $ this ->sync_eligibility_cache ( $ agentic_settings , $ eligibility_check );
9195
96+ // Reconcile the registration state whenever the agentic settings are saved.
97+ add_action (
98+ 'woocommerce_paypal_payments_settings_saved ' ,
99+ static function ( $ model ) use ( $ reconciler ): void {
100+ if ( ! $ model instanceof AgenticSettingsDataModel ) {
101+ return ;
102+ }
103+
104+ $ reconciler ->reconcile ();
105+ }
106+ );
107+
92108 // Early exit if features should not be initialized.
93109 if ( ! $ agentic_settings ->should_initialize_features () ) {
94110 return true ;
0 commit comments