We present a self-consistent real space formulation of spin-fluctuation mediated d-wave pairing. By calculating all relevant inhomogeneous spin and charge susceptibilities in real space within the random phase approximation (RPA), we obtain the effective pairing interaction and study its spatial dependence near both local potential and hopping impurities. A remarkably large enhancement of the pairing interaction may be obtained near the impurity site. We discuss the relevance of our result to inhomogeneities observed by scanning tunneling spectroscopy on the surface of cuprate superconductors.