The momentum of a photon is given by the equation p = E/c, where p represents momentum, E represents energy, and c represents the speed of light. Since the energy of a photon is directly related to its frequency or inversely related to its wavelength, any change in the photon's energy will result in a corresponding change in its momentum.
When a photon passes near a massive object, it simultaniously gains and loses energy (and thus momentum) due to gravitational interactions. This exchange of momentum causes the photon's path to be curved or deflected in the presence of a gravitational field.
Despite the exchange of momentum, a photon continues to travel at the speed of light (c) and covers the same distance (d) relative to its constant speed. The curvature of the photon's path is a result of the gravitational interaction and exchange of momentum.