With some exceptions not relevant here (e.g. people holding Federal Firearms Licenses), it is unlawful to buy a handgun in a state where one is not a resident. No gun store will sell or transfer a handgun to a non-resident. And if the state in question allows face to face private transactions, federal law requires the seller determine if the buyer is a resident of the state.
The last part isn't accurate. There is no law that requires this from non-licensees.
As a practical matter, I won't sell to someone I can't verify is a legal resident of my state and has a CCW permit, that way I know they're not a prohibited person -- but there's no law that requires me to do so.
Your correction is incorrect for at least some states. Texas requires a good faith belief (but not evidence per se) that the transferee is a legal resident of Texas (and they recommend but don't require asking for some kind of ID).
It sounds like you said what I said... Except that the discussion was specifically about federal law, there are various states that have additional laws.