Do you pay the person when you are completely satisfied with their work (as stated in the website)? Or as long as they did the work for you, you will pay them no matter how well they did?

Because Im completely dissatisfied with this freelancer, gave me a program with library problems, wasting my time to debug whats going on. Code has some bugs and underlines which I am so completely lazy to go through everything. Cos time is running out and if it doesnt work on my com, it doesnt work on my group member's com which defeats the purpose as i will get a big fat 0 if that happens.

I used upwork and a person did a good program for me within a day, without any problems and paid him willingly. What should i do with that particular freelancer??