That's basically what hotels already do for in-room minibars. They have sensors on the shelves, and you can get charged automatically if you just touch something.

How It Works - BarTech | Minibar Solutions | Las Vegas Hotels and RoomsHow it works is that Bartech Bartech Systems utilizes three types of product-detection technology:infrared, microswitches, and magnetic.bartech.com