Hi there :) I have experience with this!
So there are three different places to buy an iPhone.
- From an offline Apple Store
- From an online Apple Store (apple.com)
- From an Apple authorized reseller
For the first and the third option, when you visit the store make sure to bring your passport with you. When making the payment, make sure to tell the staff or the cashier that you want to get a VAT refund. They will print out all the necessary documents for you. With all these documents, when you leave the EU you go to the customs and get a stamp on the paper confirming that the good has been exported. The form will have instructions on how to send in the form and get a refund. Apple Stores in Europe normally partner up with Global Blue, a VAT refund agency, and they probably have a office at the airport and will give you the refund there. Otherwise, you can send it to the provided address via mail or whatever the instructions say. Authorized resellers may or may not offer this service and if they do it can be provided by a different agent. Keep in mind that these VAT refund service companies charge a commission so you won't get the full VAT back.
For the second option, when you buy an Apple product on apple.com, make sure that you put your name correctly when you place the order so that the name on the invoice matches the name on your passport. After receiving the device, print out the invoice and get that invoice stamped at customs. Scan the paper and send it to vat.refunds@apple.com together with a copy of your passport and a document that can prove that you don't live in the EU. Things like internet bill or utility bill that has your name on it should work in most cases. Once approved, you will get the VAT back to the card you used when buying the device.
IMPORTANT: YOU SHOULDN'T OPEN THE BOX UNTIL YOU GET THE STAMP. So you can buy it in the EU, but you cannot use it in the EU. Only after getting the stamp, you may open up the box and start using your new device.