I think it would work exactly the same. You would buy the card, then move it where it tells you to. Then you would fail to gain it. Possession and Trader would fail to interfere with it.
No, when you buy a card, you gain it. After buying, you gain - it's automatic (barring any triggered effect interrupting and changing it). You don't go to the next instruction before gaining it.
Look at Black Market: "You may buy one of [the cards] immediately. Put the unbought cards on the bottom of the Black Market deck in any order."
You don't put the unbought cards on the bottom of the deck before you gain the bought card. (Not that it would matter, I think.) You follow and complete each instruction in order.
I see what you're saying. It might be a difference between "buy a card. Put it on top of your deck", and "buy a card, putting it on top of your deck." When a card uses "putting it _______" as part of gaining, then it's not a separate instruction. It modifies the normal rules for gaining. Even Nomad Camp, which unfortunately uses the "when you gain this" wording, is intended to modify the normal rules of gaining.
I think the best thing here is to say that "buy a card, putting it on top of your deck" is an instruction that makes no sense and couldn't be used. Because "putting it on top of your deck" implies "instead of where it would normally go". But with "buying", there is no "where it would normally go" to replace, because buying doesn't move a card anywhere.
So with "buy a card. Put it on top of your deck", I think you would actually just always lose track. When you bought the card, it was in the supply. When you go to put it on top of your deck, you've already gained it, so it's no longer there. You can't find the card. The instruction "buy a card" doesn't "know" that it will end up in your discard pile. That knowledge is reserved for "gain".