We first prove that ord$_P$ is a discrete valuation satisfying ord$_P(p) = 1$. We write ord instead of ord$_P$ for simplicity.
Let $\varphi: \mathbb{Z} \rightarrow \mathbb{Z}/p\mathbb{Z}$ be the canonical homomorphism. Let $g(X) \in \mathbb{Z}[X]$. We denote by $\bar g(X)$ the reduction of $g(X)$ (mod $p$).
Lemma 1 Let $\Omega$ be the algbraic closure of $\mathbb{Z}/p\mathbb{Z}$. Let $i$ be an integer such that $1 \leq i \leq e$. Let $\omega_i$ be a root of $\bar g_i(X)$ in $\Omega$. Then there exists a homomorphism $\psi_i:A \rightarrow \Omega$ extending $\varphi$ such that $\psi_i(\theta) = \omega_i$. Moreover Ker($\psi_i$) = $P_i$, where $P_i = (p, g_i(\theta))$.
Proof: Let $h(X) \in \mathbb{Z}[X]$. Suppose $h(\theta) = 0$. Since $f(X)$ is irreducible, there exists $r(X) \in \mathbb{Q}[X]$ such that $h(X) = f(X)r(X)$. Since $f(X)$ is monic, $r(X) \in \mathbb{Z}[X]$. Hence $\bar h(X) = \bar f(X)\bar r(X)$. Hence $\bar h(\omega_i) = \bar f(\omega_i)\bar r(\omega_i) = 0$. Therefore there exists a homomorphism $\psi_i:A \rightarrow \Omega$ extending $\varphi$ such that $\psi_i(\theta) = \omega_i$.
Suppose $h(\theta) \in$ Ker($\psi_i$), where $h(X) \in \mathbb{Z}[X]$. There exists $r(X) \in \mathbb{Z}[X]$ such that $\bar h(X) = \bar g_i(X) \bar r(X)$. Hence there exists $U(X) \in \mathbb{Z}[X]$ such that $h(X) = g_i(X)r(X) + pU(x)$. Hence $h(\theta) = g_i(\theta)r(\theta) + pU(\theta)$. Therefore $h(\theta) \in (p, g_i(\theta))$. Hence Ker($\psi_i) \subset (p, g_i(\theta))$.
Conversely suppose $h(\theta) \in (p, g_i(\theta))$, where $h(X) \in \mathbb{Z}[X]$. There exist $U(X), r(X) \in \mathbb{Z}[X]$ such that $h(\theta) = pU(\theta) + g_i(\theta)r(\theta)$. Hence $\psi_i(h(\theta)) = p\bar U(\omega_i) + \bar g_i(\omega_i)\bar r(\omega_i) = 0$. Hence $h(\theta) \in$ Ker($\psi_i$). Hence $(p, g_i(\theta)) \subset$ Ker($\psi_i$). QED
Let $\omega_i$ be a root of $\bar g_i(X)$ in $\Omega$ for $i = 1,\dots,e$. By Lemma 1, there exists a homomorphism $\psi_i:A \rightarrow \Omega$ extending $\varphi$ such that $\psi_i(\theta) = \omega_i$ for $i = 1,\dots,e$.
Lemma 2 Let $h(X) \in \mathbb{Z}[X]$. Suppose $\psi_i(h(\theta)) = 0$ for $i = 1,\dots,e$. Then $h(\theta) \equiv 0$ (mod $pA$).
Proof: Since $\bar h(\omega_i)$ for $i = 1,\dots,e$, $\bar h(X)$ is divisible by $\bar g_i(X)$. Hence $\bar h(X)$ is divisible by $\bar f(X)$. Hence $h(X) = f(X)H(X) + pR(X)$ for some $H(X), R(X) \in \mathbb{Z}[X]$. Therefore $h(\theta) = pR(\theta)$. QED
Lemma 3 Let $\alpha \in A$. $\Psi(θ) \alpha \equiv 0$ (mod $pA$) if and only if $\alpha \in P$.
Proof: Let $\psi_1:A \rightarrow \Omega$ be the homomorphism of Lemma 1. Suppose $\Psi(θ) \alpha \equiv 0$ (mod $pA$). $\psi_1(\Psi(θ) \alpha) = \bar \Psi(\omega_1) \psi(\alpha) = 0$. Since $\bar \Psi(\omega_1) = \bar g_2(\omega_1)...\bar g_e(\omega_1) \neq 0$, $\psi_1(\alpha) = 0$. Hence $\alpha \in$ Ker($\psi_1$). By Lemma 1, $\alpha \in P$.
Conversely suppose $\alpha \in P$. Since $\psi_1(\alpha) = 0$, $\psi_1(\Psi(\theta)\alpha) = 0$. If $i \neq 1$, $\psi_i(\Psi(\theta)) = \bar\Psi(\omega_i) = 0$. Hence $\psi_i(\Psi(\theta)\alpha) = 0$. Hence $\psi_i(\Psi(\theta)\alpha) = 0$ for all $i$, $i = 1,\dots,e$. By Lemma 2, $\Psi(\theta)\alpha \equiv 0$ (mod $pA$). QED
Lemma 4 Let $\alpha \in A$. Let $k \geq 0$ be an integer. Suppose $\Psi(\theta)^k\alpha \equiv 0$ (mod $p^kA$). Let $\beta = (\Psi(\theta)^k\alpha)/p^k \in A$. Then ord($\alpha$) = $k$ if and only if $\beta$ is not divisible by $P$.
Proof: $\Psi(\theta)\beta \equiv 0$ (mod $pA$) if and only if $\Psi(\theta)^{k+1}\alpha \equiv 0$ (mod $p^{k+1}A$). Hence the assertion follows immediately from Lemma 3. QED
Lemma 5 Let $k, l \geq 0$ be integers. Let $\alpha, \beta \in A$. Suppose ord($\alpha$) = $k$ and ord($\beta$) = $l$. Then ord($\alpha\beta$) = $k + l$.
Proof: Since $\Psi(\theta)^k\alpha \equiv 0$ (mod $p^k$), there exists $\lambda \in A$ such that $\Psi(\theta)^k\alpha = p^k\lambda$. Similarly there exists $\mu \in A$ such that $\Psi(\theta)^l\beta = p^l\mu$. Then $\Psi(\theta)^{k+l}\alpha\beta = p^{k+l}\lambda\mu$. Since $\lambda\mu$ is not divisible by $P$ by Lemma 4, ord($\alpha\beta$) = $k + l$. QED
Lemma 6 Let $\alpha \neq 0$ be an element of $A$. There exists an integer $k \geq 0$ such that ord($\alpha$) = $k$.
Proof: Suppose $\Psi(\theta)^k\alpha \equiv 0$ (mod $p^kA$) for every integer $k \geq 0$. There exists $\beta_k \in A$ such that $\Psi(\theta)^k\alpha = p^k\beta_k$ for every $k$. Since $\Psi(\theta)^{k+1}\alpha = \Psi(\theta)p^k\beta_k = p^{k+1}\beta_{k+1}$, $\Psi(\theta)\beta_k = p\beta_{k+1}$. Hence $\beta_k = \pi\beta_{k+1}$, where $\pi = p/\Psi(\theta)$. Since $\pi \in PA_P$, $\beta_kA_P \subset \beta_{k+1}A_P$ for every integer $k \geq 0$. Since $A_P$ is Noetherian, there exists an integer r such that $\beta_rA_P = \beta_{r+1}A_P$. Hence there exists $u \in A_P$ such that $\beta_{r+1} = u\beta_r$. Since $\beta_r = \pi\beta_{r+1}$, $\beta_r = u\pi\beta_r$. Hence $(1 - u\pi)\beta_r = 0$. Since $\pi \in PA_P$, $1 - u\pi$ is invertible in $A_P$. Hence $\beta_r = 0$. Since $\Psi(\theta)^r\alpha = p^r\beta_r$, $\alpha = 0$. This is a contradiction. QED
Lemma 7
ord($p$) $= 1$.
Proof: Clearly $\Psi(\theta)p \equiv 0$ (mod $p$). Suppose $\Psi(\theta)^2 p \equiv 0$ (mod $p^2$). Then $\Psi(\theta)^2 \equiv 0$ (mod $p$). Since $p \equiv 0$ (mod $P$), $\Psi(\theta)^2 \equiv 0$ (mod $P$). Hence $\Psi(\theta) \equiv 0$ (mod $P$). Since $\Psi(\theta) = g_2(\theta)\dots g_e(\theta)$, this is a contradiction. QED
Lemma 8 Let $\pi = p/\Psi(\theta)$. Every non-zero element $x$ of $A$ can be uniquely written as $x = \pi^k y$, where $k \geq 0$ is an integer and $y \in A$ and $y$ is not divisible by $P$.
Proof: Let ord($x$) = $k$. Then $\Psi(\theta)^k x \equiv 0$ (mod $p^kA$). Hence there exists $y \in A$ such that $\Psi(\theta)^k x = p^k y$. Hence $x = \pi^k y$. By Lemma 4, $y$ is not divisible by $P$. QED
Lemma 9 Let $x, y$ be non-zero elements of $A$. Then ord($x + y$) $\geq$ min{ord($x$), ord($y$)}.
Proof: We can assume $x + y \neq 0$. Let ord($x$) = $k$, ord($y$) = $l$. We can assume that $k \leq l$. By Lemma 8, we can write $x = \pi^ku$, where $u$ is not divisible by $P$. Similarly $y = \pi^lv$. Then $x + y = \pi^ku + \pi^lv = \pi^k(u + \pi^{l-k}v)$. Hence, by Lemma 5, ord($x + y$) = ord($\pi^k(u + \pi^{l-k}v)$) = $k +$ ord($u + \pi^{l-k}v$) $\geq k$. QED
Lemma 10 Let $\mathbb{Z}_{\infty} = \mathbb{Z} \cup$ {$\infty$}. There exists a unique map ord:$K \rightarrow \mathbb{Z}_{\infty}$ extending ord with the following properties.
(1) ord($K^*$) = $\mathbb{Z}$.
(2) ord($xy$) = ord($x$) + ord($y$) for $x, y \in K^*$.
(3) ord($x + y$) $\geq$ min{ord($x$), ord($y$)}
Proof: Let $x \in K^*$. If $x = a/b$ with $a, b \in A$, we define ord($x$) = ord($a$) - ord($b$). If $x = c/d$ with $c, d \in A$, $x = a/b = c/d$. Since $ad = bc$, ord($a$) + ord($d$) = ord($b$) + ord($c$). Hence ord($a$) - ord($b$) = ord($c$) - ord($d$). Therefore ord($x$) is well defined. Then (1), (2), (3) are clear.
The uniqueness is also clear. QED
Lemma 11 Let $\pi = p/\Psi(\theta)$. Let $U$ = {$s/t$; $s, t \in A - P$}. Let $x$ be a non-zero element of $K$. Then $x$ can be uniquely written as $x = \pi^k u$, where $k$ is an integer and $u \in U$.
Proof: Let ord($x$) = $k$. Let $u = x/\pi^k$. Then ord($u$) = ord($x$) - $k = 0$. Let $u = a/b$ with $a, b \in A$. Let $a = \pi^i s$ by Lemma 8, where $s$ is not divisible by $P$. Similarly let $b = \pi^j t$, where $t$ is not divisible by $P$. Then $u = \pi^{i-j}s/t$. Since ord($u$) = 0, $i = j$. Hence $u = s/t$.
The uniqueness is clear. QED
Proposition The following assertions hold.
(1) ord can be extended to a unique discrete valuation of $K$ and its valuation ring is $A_P$.
(2) ord($p$) = $1$.
Proof: By Lemma 10, ord can be extended to a unique discrete valuation of $K$. By Lemma 7, ord($p$) = $1$.
It remains to prove that $A_P$ is its valuation ring. Let $x \in K^*$. Suppose ord($x$) $\geq 0$. By Lemma 11, $x = \pi^k s/t$, where $s, t \in A - P$. Since $\pi \in PA_P$, $x \in A_P$.
Conversely suppose $x \in A_P$. $x$ can be written as $x = a/s$, where $a \in A$, $s \in A - P$. Then ord($x$) = ord($a$) - ord($s$) = ord($a$) $\geq 0$.
Therefore $A_P$ = {$x \in K$; ord($x$) $\geq 0$} as claimed. QED