Press the spacebar when the bean is in front of the bean seller. Do not spam the spacebar. You have a reload timer for each time you press it, so press it wisely.
From The Legend of Zelda, Ocarina Of Time.