Photons can interact with matter at the atomic level (e.g. photoelectric effect and Rayleigh scattering), at the nucleus, or with just an electron. Pair production and the Compton effect occur at the level of the electron. When a high frequency photon scatters due to an interaction with a charged particle, there is a decrease in the energy of the photon (and thus, an increase in its wavelength.) This is the Compton effect. Because of conservation of energy the lost energy from the photon is transferred to the recoiling particle (such an electron would be called a "Compton Recoil electron").