"Poor quality code" is a matter of opinion. You can't decide not to pay someone because they've delivered what you consider poor quality code. The best defense from that is to track development (with milestone deliverables), and evaluate code quality (or pay someone to evaluate code quality) as you go along, so you can end the relationship early before you've wasted too much money.
Waiting until they're done and deciding that it's crap and refusing to pay in full is not the way to deal with bad developers.