Immigration lawyers typically do not work on a contingency basis (where your obligation to pay is conditioned on the lawyer winning your case). Instead, you pay an immigration lawyer to exercise his best efforts, and from there on out you simply take your chances. An immigration attorney may charge an hourly rate or a flat fee, and some offer monthly payment plans.
Immigration lawyers are more likely to charge a flat fee for a visa application rather than for immigration court proceedings because the time it takes to file a visa application is more predictable than the time that might be required to, say, fight deportation proceedings. In any case, you will need to read and fully understand the fee agreement before you sign it. Pay particular attention to any upfront retainers you might be required to pay.