Confusions in discretizing a momentum delta integral
I have an integral of the following form:
$$\int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\delta\left(\sqrt{k_{x}^{2}+k_{y}^{2}+k_{z}^{2}}-p\right)f(k)$$ There are two ways to convert it into discrete form: $$ \int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\delta\left(\sqrt{k_{x}^{2}+k_{y}^{2}+k_{z}^{2}}-p\right)f(k) = \int d\phi d\theta d|k|k^{2}sin(\theta)\frac{1}{(2\pi)^{3}}\delta\left(|k|-p\right)f(k) = \int d\phi d\theta p^{2}sin(\theta)\frac{1}{(2\pi)^{3}}f(k)|{|k|=p} = \sum{k_{x}k_{y}k_{z}\ where|k|=p}\frac{1}{L^{2}}\frac{1}{2\pi}f(k)|_{|k|=p}$$
where $\int d\phi d\theta p^{2}sin(\theta)\frac{1}{(2\pi)^{2}}=\int dS\frac{1}{(2\pi)^{2}}\rightarrow\frac{1}{L^{2}}\sum_{k_{x}k_{y}k_{z}\ where|k|=p}$
The second way is: $$ \int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\delta\left(\sqrt{k_{x}^{2}+k_{y}^{2}+k_{z}^{2}}-p\right)f(k) = \int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\delta\left(\sqrt{k_{x}^{2}+k_{y}^{2}+k_{z}^{2}}-p\right)f(k) = \int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\delta\left(g(k_{z})\right)f(k) = \int dk_{x}dk_{y}dk_{z}\frac{1}{(2\pi)^{3}}\sum_{i}\frac{\delta(k_{z}-k_{zi})}{|g'(k_{zi})|}f(k) = \int dk_{x}dk_{y}\frac{1}{(2\pi)^{3}}\sum_{i}(\frac{1}{|g'(k_{zi})|}f(k)|{k{z}=k_{zi}}) = \sum_{k_{x}k_{y}}\frac{1}{2\pi}\frac{1}{L^{2}}\sum_{i}(\frac{1}{|g'(k_{zi})|}f(k)|{k{z}=k_{zi}}) $$
I am confused about which is the correct way, especially about the usage of L. 402