How plugins_loaded works?

Use your class definition in a separate file, say in /your-plugin-dir/classes/my-gateway.php like usual:

    <?php
        class my_gateway extends WC_Payment_Gateways {
            //code
        }
    ?>

Then use this CODE to include the file on plugins_loaded action from your main plugin file:

    add_action('plugins_loaded', 'WC_test_gateway_plugin');
    function WC_test_gateway_plugin() {
        require_once plugin_dir_path( __FILE__ ) . 'classes/my-gateway.php';
        // instantiate your class here or in your class file or anywhere after this function is called.
    }

Now you’ll get access to WC_Payment_Gateways because by now WC_Payment_Gateways is defined, since WordPress fires plugin_loaded action hook only after all the plugins have loaded their main files.