A strong finish to the innings saw New Zealand set South Africa a target of 261.
South Africa started well, reaching 83 without loss before Quinton de Kock was bowled out by Franklin for 31.
Smith led the Proteas with the bat, hitting a century to steady the side as his teammates lost their wickets steadily throughout his innings, eventually being caught for 116.
A mis-judged shot from Phangiso brought Dale Steyn to the crease, with South Africa still needing eight to win the match off the last over.
Steyn faced six balls before being caught, bringing out Lonwabo Tsotsobe to face the last ball of the innings, and McLaren duly hit a six.
Despite the win, New Zealand still take the series, having won the first two fixtures in the three-match series.