But we do not want to harm our existing SEO while we are doing this.
What you might be concerned here with is Cloaking - that is, serving different content to a user's browser than to search engine robots.
Providing that you use IP delivery, which is using the requestor's location to deliver content specifically written for that country, versus redirecting based on user agent, you should be fine as indicated here:
Many of the top 1000 sites, including sites like Amazon (amazon.com),
actively use IP delivery. None of these have been banned from search
engines as their intent is not deceptive.
You should probably also be aware of issues related to serving duplicate content between your international and country-specific website, should they contain the same content, which can be addressed with canonicalization and geotargeting your content.
To accomplish redirection with IP delivery, it would be wise to use a service that provides GeoIP databases which are routinely updated, such as MaxMind's GeoIP Country Database. You can implement that using server-side APIs in the following languages:
- PHP
- Python
- Perl
- Ruby
- Java
- C#
- C
...
Many of these have easy to use open source modules too. For example, I use this PHP extension: Geo IP Location, as well as this Perl module: GEO-IP.
There's a free version of the database, GeoLite, which is updated once a month, and a more accurate paid version, GeoIP Country, that gets updated more frequently.
There's also a JavaScript Client API, available in a paid and free version (the free version only requires an attribution statement on your website). This combines both W3C Geolocation and their GeoIP2 Web Service, which first attempts to get the visitor's location from their browser, and if not available or inaccurate, it then uses a GeoIP lookup.
In addition to the sample code, there's a tutorial on how to use the API here: GeoIP2 JavaScript Tutorial
Do we have to use 302 server side redirection or a client-side redirection with JavaScript?
A 302 redirect would indicate the page was "Moved Temporarily", which is not really the case here. Implementing either the server-side APIs or JavaScript above would be sufficient.
As to which to use, the server-side versus client-side JavaScript, that depends on whether you want to perform actions on your server related to the redirection, such as displaying country-specific content, ads, etc... The benefit with JavaScript is that it reduces server resources, however, if JavaScript is disabled in the user's browser, the redirection can't occur unless their location is provided by their browser (see above). It's always wise to provide a "Country" link in your website's navigation for that reason.