Non-contact sensor in soap dispenser
A slightly different solution for consumer market, are the electronic soap dispensers for the home. These do work slightly different from the ones I think you refer to, but still valuable to know. 

For the Dettol soap dispenser there is an IR beam that you break with your hand. The IR transmitter is easy to spot if you look under the arm. If you look closely you'll notice that the lens is slightly pointing toward the body of the dispenser. The IR photodiode is looking up under an angle behind the red glass, aiming at the LED in the arm.



To save energy and improve reliability the LED is flashing and the receiver will look for these flashes. Once it misses the flashes from the LED the pump is activated. 

Apart from a chip on board, a single TO-92 transistor (power stage to the pump motor) and a hand full (SMD) components: resistors, couple small caps and a transistor there is very little (to hack) in there.