New Zealand beat South Africa by six runs in second ODI