How to integrate the following geometric brownian motion in Black-Scholes framework As my previous questions make it obvious, I am very new to this field of mathematics and wondering if I am doing things right in the following question.

Let $T \in (0, \infty)$ and consider a Black-Scholes market for a stock $(S_t)_{t \in [0,T]}$(A geometric Brownian motion with drift $r$ and volatility $\sigma$). Consider the all or nothing option contract with the payoff at time $T$ defined by 
$$
\begin{array}{cc}
  g(x)=\{ & 
    \begin{array}{cc}
      P & \text{ if }x \geq K \\
      0 & \text{ if } x< K
    \end{array}
\end{array}
$$ 
where $P>0,K>0$ are given real constants. Compute the price $\Pi(0;g(S_T))$ of the contract $g(S_T)$. Namely, find the expression of $\Pi(0;g(S_T))|_{S_0}=e^{-rT}\mathbb{E}[g(S_T)]$

My attempt was simply find $e^{-rT}\mathbb{E}[g(S_T)]$. So, for the $\mathbb{E}$ bit, I need to calculate
$$\mathbb{E}[g(S_T)]=\int_K^\infty S_T \cdot P\cdot dS_T$$
(I am not sure if this $dS_T$ i.e. integrate wrp to $S_T$ is correct or not) which is due to the general definition of a continuous random variable expected value $\mathbb{E}[x]=\int_{-\infty}^{\infty}xf(x)dx$. But I am not sure how to proceed, i.e. how to integrate this geometric brownian motion...wrp to a geoertic brownian motion(which yes, sounds wrong actually...).
It would be great if someone can guide me here, I hope my basic attempt overall shouldn't be entirely wrong. I think I am not very sure about the details.
Would someone please help me? It would be great if I can get some explanations in the details along rather than just a brief answer, sorry for asking a lot. Thank you very much in advance
Update
I have made some progress hopefully, so please tell me if it looks okay or not.
I have seen that, given some random variable $X$, with pdf $f(x)$, the expected value of a new variable $Y=g(x)$ for some function $g$ is $\mathbb{E}[Y]=\int_{-\infty}^{\infty}g(x)f(x)dx$. I have based my calculations on this.\
So in my case, 
\begin{align*}
\mathbb{E}[g(S_T)] &=\int_{-\infty}^{\infty}g(S_T:=x)f(S_T:=x)dx\\
&=\int_{0}^{K}0f(x)dx+\int_{K}^{\infty}Pf(x)dx$\\
\end{align*}
Now since my $S_T$, a geometric brownian motion is lognormally distributed with mean $S_0e^{rt}$ and variance $S_0^2e^{2rt}(e^{\sigma^2t}-1)$, I will substitute these in to the PDF of a lognormal function as my $f(x)$. So,
$$\mathbb{E}[g(S_T)] = \frac{1}{S_0e^{rt} \sqrt{2 \pi(e^{\sigma^2 t}-1)}} \int_{K}^{\infty} \frac{1}{x}e^{- \frac{(lnx-S_0e^{rt})^2}{2S_0^2e^{2rt}(e^{\sigma^2t}-1)}} dx$$
It looks ugly, so I did an interchange of variables introducing $z=lnx-S_0e^{rt}$. Thus I have $x$ from $K \rightarrow \infty|$ then $z$ from $lnK-S_0e^{rt} \rightarrow \infty$ and $dx = e^{z+S_0e^{rt}}dz$. So substituting these, I get something better,
$$\mathbb{E}[g(S_T)] = \frac{1}{S_0e^{rt} \sqrt{2 \pi(e^{\sigma^2 t}-1)}} \int_{lnK-S_0e^{rt}}^{\infty} e^{- \frac{z^2}{c}}dz$$
where $c=2S_0^2e^{2rt}(e^{\sigma ^2t}-1)$
My question is, the integral now involves (Gauss') error function which is well, complicated. I can fortunately compute the error function's value for the one up to $\infty$ which is $\frac{\sqrt{\pi}}{2}$ I think but not for the one up to $lnK-S_0e^{rt}$. All I can think of is expressing it as a Taylor expansion of the error function.
But is this correct? This is the best I can do so far...
Please please help! Thank you again.
 A: You have the right start in that you want to compute
$$
e^{-rT}E_Q(g(S_T))
$$
where $Q$ is the risk-neutral probability measure and, under $Q$,
$$
S_T = S_0e^{\left(r - \frac{\sigma^2}{2}\right)T + \sigma W_T}.
$$
So we have 
$$
e^{-rT}E_Q(g(S_T)) = e^{-rT}E_Q(P\cdot \mathbb{I}_{S_T \geq K}) = Pe^{-rT}Q(S_T \geq K),
$$
where the last equality is because
$$
E_Q(\mathbb{I}_{S_T \geq K}) = Q(S_T \geq K).
$$
A simplifying step often done in texts is to use only the normal distribution, instead of the more cumbersome lognormal, as follows.  Note
\begin{align}
S_T \geq K & \iff S_0e^{\left(r - \frac{\sigma^2}{2}\right)T + \sigma W_T} \geq K \\
& \iff \left(r - \frac{\sigma^2}{2}\right)T + \sigma W_T \geq \log \frac{K}{S_0} \\
& \iff W_T \geq \frac{1}{\sigma}\left(\log\frac{K}{S_0} - \left(r - \frac{\sigma^2}{2}\right)T\right) \\
& \iff \frac{W_T}{\sqrt{T}} =: Z  \geq \frac{1}{\sigma\sqrt{T}}\left(\log\frac{K}{S_0} - \left(r - \frac{\sigma^2}{2}\right)T\right) =: -d_2.
\end{align}
Note I'm suggestively calling the RHS $-d_2$, and $Z \sim \mathcal{N}(0,1)$.  Hence, letting $\phi$ be the standard normal pdf and $\Phi$ the standard normal cdf,
\begin{align}
Pe^{-rT}Q(S_T \geq K) & = Pe^{-rT}Q(Z \geq -d_2) \\
& = Pe^{-rT}\int_{-d_2}^\infty \phi(x)\, dx \\
& = Pe^{-rT}\int_{-\infty}^{d_2}\phi(x)\, dx \\
& = Pe^{-rT}\Phi(d_2).
\end{align}
