main_gateway = $main_gateway; $this->all_registered_gateways = $all_registered_gateways; } /** * Checks whether we should trigger the event. */ public function maybe_sync() { $previous_version = get_option( 'woocommerce_woocommerce_payments_version' ); if ( version_compare( self::VERSION_SINCE, $previous_version, '>' ) ) { $this->sync(); } } /** * Syncs gateway setting objects. */ private function sync() { $enabled_payment_methods = $this->main_gateway->get_option( 'upe_enabled_payment_method_ids', [] ); foreach ( $this->all_registered_gateways as $gateway ) { // Skip the main gateway as it's settings are already in sync. if ( 'card' !== $gateway->get_stripe_id() ) { if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) { $gateway->enable(); $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); } else { $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); } } } } }