David Miller's magnificent century saw South Africa chase down 372 to beat Australia by four wickets and secure the ODI series victory with two games to spare.