It is safe to buy Apple products online, but it depends on which seller you’re buying from, My advice is cellbuddy because my past 3 year experience with cellbuddy is good, I got satisfied products from them.
Just be careful when you’re choosing your seller, and don’t swayed by huge discount because that is not a normal offer on something as expensive as an iPhone.
Hope this helps you, and have a good time shopping!