"I am going to buy an iPhone for myself" is correct. Others will no doubt be able to supply a more technical answer, but I think that it is because the subject of the sentence and the person for whom the iPhone is to be bought are the same, so you need the reflexive pronoun. By comparison, you would say "I am going to buy an iPhone for her" but "She is going to buy an iPhone for herself".
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.