Only paid in tips?

So i work for a company and im a delivery driver. I do normal work until a delivery pops up then i have to take it. But when i go to take it they stop paying my my hourly and i only get paid in tip. I was just wondering if thats legal or not because sometimes i go on deliveries and i get no tip so i essentially worked that time for free.