If competition is good for consumers, then the phone trade-in market is looking up. Best Buy, Walmart, Gazelle, and your mobile provider all accept trade-ins on old iPhones, giving you money to upgrade to a new phone. Now Apple is launching its own trade-in program at select Apple Stores starting on August 30, with a larger expansion of the program coming in September.
Apple decides the value of your iPhone based on information entered into the standard EasyPay system. The system takes into account the quality of your phone -- button quality, damage, if the display is scratched, if you engraved "I love Slayer" on the back, etc -- and then calculates your trade-in amount.
Apple Store employees will help you back up your iPhone before turning it in, and will hand over your old SIM card (the iPhone 5 uses the new nano-SIM card format). iPhones of all generations are eligible for trade-in, though obviously you'll receive less money for an iPhone 3G than an iPhone 5. As of now, the program is only available in the United States.