Solution (source code)

= Solution

Fix the evaluation point $r'$ inside $V$ and put $\psi(r)=G(r,r')$ in <Green's second identity>. The two $k^2$ terms cancel because $\nabla^2\phi=-k^2\phi$ and $\nabla^2G=\delta^{(3)}-k^2G$. The remaining volume integral is $\int\phi(r)\delta^{(3)}(r-r')dV=\phi(r')$. Thus
$$
\phi(r')=\int_S[\phi(r)\partial_{n_r}G(r,r')-G(r,r')\partial_n\phi(r)]dS.
$$
The <Dirac delta> has a positive sign in this problem's Green-function equation, fixing the order of the two terms. All boundary derivatives act on the integration variable $r$.