Stirling Albion beat Peterhead 3-1 at Forthbank to finish second but it wasn't quite enough to qualify. Hearts, who are already through as group winners, host Inverness CT on Sunday, live on Premier Sports at 5.15pm.
Dundee United had already won the group and Arbroath joined them in the last 16 after claiming second spot with a 3-2 home win over Kelty Hearts. Elgin City defeated East Fife 3-2 at Bayview in the other game.
Dundee defeated Forfar Athletic 5-2 at the Kilmac Stadium to secure top spot and Ross County saw off Montrose 4-1 in Dingwall.
Raith Rovers finished top following a 0-0 draw against Alloa Athletic and a win in the shoot-out. Livingston are through as one of the best runners-up after a 3-1 home win over Cowdenbeath.
Ayr United were confirmed group winners with a default 3-0 win over Falkirk, who couldn't fulfil the fixture. Hamilton Accies finished second after a 2-2 draw with Albion Rovers - Accies won the shoot-out but it wasn't enough to qualify.
Motherwell defeated Annan Athletic 2-0 at Fir Park to top the section while Ally Roy hit a hat-trick as Queen of the South beat Airdrieonians 4-1 at Palmerston.
Kilmarnock edged a tight section thanks to a 2-1 home win over Stranraer while Morton beat Clyde by the same score at Cappielow.
Dunfermline Athletic booked a last-16 spot with a 4-1 win against Stenhousemuir. St Mirren host Partick Thistle on Sunday, live on Premier Sports. A draw will be enough for Saints to top the group.