West Ham United burst out of the blocks against Cardiff City, but were made to work hard for a 3-2 win and a place in the fourth round of the Capital One Cup.