Vending machines are actually quite ancient. Heron of Alexandria invented them a couple thousand years ago. Tobacco dispensing machines came about in the 1600s. Put a coin in the slot, the machine opens a valve and dispenses a product.
End of story, really.
There is no mathematical or engineering or fabrication reason why your medieval-esque society could not do something similar.
The only issue I foresee is in counterfeit detection. In medieval times, I think counterfeit detection by weight will be your only viable alternative, if magic or a money changer is not available. If they have magnets of some kind, then they could be added to weed out iron slugs at least.
If the coin is determined to be too heavy or too light (and thereby either actually fake or else clipped (a common practice in the days of precious metal money)), then it would be dumped into a return slot. A coin (or slug) of correct weight and dimensions will be accepted. Whether real or fake!
A fairly foolproof system. Faking coins is, of course, big business and back in the day carried a hefty penalty for those caught doing it. A relatively simple detector will keep all but the most advanced counterfeiters from using the machine.
A final note: unless your vending machine is dispensing title deeds to large plots of land or luxury waggons, chances are gold coins will never see the inside of one. Probably not silver either. Most likely copper or brass will be used to buy relatively inexpensive items or services.