Calculate the value of the integral of a series 
let $$P(r,\varphi):= \dfrac{1}{2\pi} \sum_{n \in \mathbb{Z}} r^{|n|}e^{in\varphi} $$
  with $\varphi \in \mathbb{R}$ and $ 0< r <1$. Prove that $$\int_{0}^{2\pi}P(r,\varphi)d\varphi =1$$

My attempt:
The infinite sum above it's a Laurent series, and it converges to $\dfrac{1}{2\pi} \cdot \dfrac{1-r^2}{1-2r \cos(\varphi) + r^2 } $ (the sum of the geometric series for positive and negative $n$). Since the series converge uniformly (by comparison with the geometric series $\sum_n r^n$), I have two ways of calculating this integral. First, $$ \int_{0}^{2\pi} \dfrac{1}{2\pi} \cdot \dfrac{1-r^2}{1-2r \cos(\varphi) + r^2 } d\varphi$$ and second $$ \dfrac{1}{2\pi} \sum_{n \in \mathbb{Z}}  r^{|n|} \int_{0}^{2\pi}e^{in\varphi} d\varphi$$.
But using the usual substitution $u = \tan \left( \frac{\varphi}{2} \right)$, and splitting the first integral (I have a problem in $\varphi = \pi$ with the substitution), and doing the limits (checked with mathematica), I obtain $0$ (the two integral are the same quantity but with different sign). 
If I calculate the integral in the second, I obtain a sum of zeros, in fact, according to my calculations $\int_0^{2\pi} e^{in\varphi} d\varphi =0$.  But Mathematica evaluate correctly the integral, so I must be wrong somewhere.
Can someone help me figure out the problem? Or the reasoning is correct and I need to triple-check the calculations?
Edit Thanks to Daniel Fischer for pointing out that the second method works (just evaluate for $n=0$), So, why the first doesn't work? just miscalculations?

Here's an alternative computation to the ones you tried above, relying on complex analysis.
For $n\ge0$, let $z=re^{i\varphi}$, so that we obtain:
$$\frac{1}{2\pi}\sum_{n=0}^\infty r^{|n|}e^{in\varphi}=\frac{1}{2\pi}\sum_{n=0}^\infty z^n=\frac{1}{2\pi}\frac{1}{1-z}=f(z)$$
which is holomorphic in the open unit ball in $\mathbb{C}$. For $n<0$ let instead $w=re^{-i\varphi}$, so that:
$$\frac{1}{2\pi}\sum_{n=-\infty}^{-1}r^{|n|}e^{in\varphi}=\frac{1}{2\pi}\sum_{n=1}^\infty w^n=\frac{1}{2\pi}\frac{w}{1-w}=g(w)$$
which again si a holomorphic function in the unit ball. Now notice that your integral splits into the integral of $f(z)$ over the circle with radius $r$ in the anticlockwise direction plus the integral of $g(w)$ over the circle with radius $r$ in the clockwise direction, and those can be easily computed using the residue theorem.
Namely we have:
$$\int_0^{2\pi}\frac{1}{2\pi}\sum_{n=0}^\infty r^{|n|}e^{in\varphi}d\varphi=\int_{\gamma_1}\frac{1}{2i\pi}\frac{1}{z(1-z)}dz=1$$
$$\int_0^{2\pi}\frac{1}{2\pi}\sum_{n=-\infty}^{-1} r^{|n|}e^{in\varphi}d\varphi=\int_{\gamma_2}\frac{1}{-2i\pi}\frac{1}{1-w}dw=0$$
