An anecdote I share, recognizing the risk of downvoting: I've been an anarchist for years, and so do not normally cast votes.
I have offered to sell my vote to anyone in my area (a swing area of New Hampshire) who wants another vote for their side in any election at any level. I've never even set a price.
Not one person has ever offered a cent for it.
I mention this just by way of making the point that small-scale vote buying, which would be the hardest kind to detect, isn't happening.
Theoretically at least, detecting and preventing vote-buying at a scale significant enough to change the outcome of an election should be much easier.
Would-be buyers have to get word out to enough people for it to matter, but if most people assume this is unethical (or even just undesirable), it shouldn't be hard to get nearly everyone else to be willing to rat out the buyers.
I don't think the problem is nearly as hard to solve as you're thinking it is.
The odds of your vote swinging an election at any level are lower than the risk of being struck by lightning twice. Nobody wants to buy one vote. They need to buy hundreds or thousands before it will matter, and that makes them easier to catch.