They ask for a commitment from the worker's side and at the end, is not the worker that is going to pay directly. You pay to the company and they are going to make the whole process for you. So, until this perspective, is not illegal. At least is that what they promiss. Since you are working with them, they pay you back, but until now I see no guarantee that they are really going to either get the H1-B for you or reinburse the money if you get the VISA.
If anyone has a success history about it, please, I also would like to know.