I am currently in US in NYC and need to buy an iphone 3GS - 32 GB. I was thinking of buying it at the Apple Store for 299 USD with the AT&T contract and then cancel the contract immediately after the purchase at the AT&T store and pay the penalty of USD 175. So totally the phone would only cost me 475 USD. Has anyone done this before and has it worked?

Also once I have the phone what is the easiest and safest method to unlock the phone and make it usable for a service provider from India.

Thanks for all your help.