I saw my first vending machine today that had a touch screen for 3 digit product entry, so a real keypad isn't a requirement. It also seems to allow multiple transactions before giving you change.
Check out the Anaren Atmosphere package:
https://www.anaren.com/iot/
I've done 4 position sensing using a Small PCB with hall sensors on them and studs with magnets on them (Forgot who made them). this was a 4 position filter wheel. The edge contained holes for a roller microswitch. So, I could do is filter moving; Move filter; Is filter moving; remove control and it would stop on it's own and I could determine the position.
You might be able to get away with using grey code and essentially that is read while the tray is in motion. Grey has one bit changing at a time. For a valid "next position" one bit has to change. Once you have the desired position-1 found, put the system in auto-stop mode and then check after it's stopped.
Re-think your carosel:
4 bit grey encoded input, 1 move motor output, 1 motor out of index mark. e.g. the system will move to the next index mark if the microswitch moves out of the index mark briefly. The computer doesn't have to stop the carosel.
Move to next position is different than move to pos #20.
I used a synchronous motor which stops instantly.
Are you sure you want "product in it" or "product dispensed" or both. I recent saw a vending machine with that option too. No product dispensed. Refund.