Hero of Alexandria (10-70 CE) was a Greek engineer and mathematician who lived in Roman-ruled Egypt. He invented many gadgets and wrote at length about them. In his book Pneumatics, he described an early vending machine. It dispensed holy water only when a coin was inserted. Here's a selection from an English translation of the book:

If into certain sacrificial vessels a coin of five drachms be thrown, water shall flow out and surround them. Let A B C D (fig. 21) be a sacrificial vessel or treasure chest, having an opening in its mouth, A; and in the chest let there be a vessel, F G H K, containing water, and a small box, L, from which a pipe, L M, conducts out of the chest. Near the vessel place a vertical rod, N X, about which a lever, O P, widening at O into the plate R parallel into the bottom of the vessel, while at the extremity P is suspended a lid, s, which fits into the box L, so that no water can flow through the tube L M: this lid, however, must be heavier than the plate R, but lighter than the plate and coin combined. When the coin is thrown through the mouth A, it will fall upon the plate R and, preponderating, it will turn the beam O P, and raise the lid of the box so that water will flow; but if the coin falls off, the lid will descend and close the box so that the discharge ceases. (37)

Really interesting stuff, since finding this, the design team keep talking about how they would make a vending surround for the machine if they only had the materials available at the time, slightly trickier than our normal products!