As I understand it, they don't get paid for prescribing stuff. Rather, they get paid for persuading other physicians to prescribe stuff. Through speaking fees, payments for putting their name on favorable publications, and so on.
In Brazil they are forbidden by regulation to take money directly for prescribing stuff but pharmaceutical companies are allowed to sponsor their trip for a medical conference in Hawai and other subtle bribery. How they know who deserves that? There are companies devoted to gather this kind of information - source: used to be IT manager for a pharmaceutical company.
> As I understand it, they don't get paid for prescribing stuff.
Yes, this kind of practice has now been outlawed in many developed countries, but there are tons of indirect ways a doctor can get "favors" from a company. Free lunches, invitation to seminars, scholarships, speaking fees as you mention (which can be pretty, pretty generous), publications, reviews, advisory boards, etc...
So, let's not be naive. Patients should be aware of all this kind of things because they can clearly influence doctors in their choice of drugs.
Somewhat interesting: My sister is a PA and she said the ethics at the clinics she's worked at at forbid you from taking the lunch offers. Apparently those sort of ethics are more and more common.
So instead they invite you out to expensive dinners which is of course during off hours.