Understanding real estate commissions

How are fees determined?