How to solve one-touch American call

I want to solve the one-touch American call at $t = 0$ with level $B,$ maturity $T$ under the following assumption: $$d S= rSd t + \sigma SdW,\quad S_0<B.$$ We have following formula: $$V(S_0,0) = \left(\dfrac{B}{S_0}\right)^{2r/\sigma^2}N(d_2)+\dfrac{S}{B}N(d_1),$$ where we ormit $d_1,d_2.$

Is there any easy way or reference to obtain above formula? I solve as this the following way, but it is very complicated:

$$S(t)=S_0\exp^{\sigma W(t)+(r-\dfrac{1}{2}\sigma^2)t}=S_0\exp^{\sigma \hat{w}(t)},$$ where $\hat{w}(t) = W(t) + \alpha t,\ \alpha = \dfrac{1}{\sigma}(r-\dfrac{1}{2}\sigma^2).$

Then first passage time is given by $$\tau_m = \min\{t\geq 0; W(t) = B\}=\min\{t\geq 0; \hat{w} = \hat{B}\}$$ and we have the value $$V(S_0,0) = E[e^{-r\tau_m}\textrm{II}_{\{\tau_m\leq T\}}].$$ Here, $\textrm{II}$ is the indicator function. Then change the measure to make $\hat{W}(t)$ be a Brownian motion: $$\hat{E}[\dfrac{1}{\hat{Z(T)}}e^{-r\tau_m}\textrm{II}_{\{\tau_m\leq T\}}] = E[e^{-r\tau_m}\textrm{II}_{\{\tau_m\leq T\}}]$$ Here, $Z(T) = \exp(-\alpha W(t)-\dfrac{1}{2}\alpha^2)$ is the transition function.

And we know the joint CDF of first passage time $\tau_m$ and $\hat{W}(t)$ under $\hat{P}$ ,finally we solve this double integral.

As is often the case, there are at least two solution strategies here.

1. (Probabilistic) You explicitly solve for the expected discount factor at the first passage time $\nu$ of $S$ to the level $B$ under the risk-neutral probability measure $\mathbb{P}^*$, i.e. $$V_0 = \mathbb{E}_{\mathbb{P}^*} \left[ e^{-r \nu} \mathrm{1} \left\{ \nu \leq T \right\} \right],$$ where $\nu$ is the first hitting time of $S$ to $B$.

2. (Differential Equation) The option value $\tilde{V}(S, \tau)$ (as a function of the time-to-maturity $\tau$) satisfies the initial boundary value problem \begin{eqnarray} \mathcal{L} \left\{ \tilde{V} \right\} & = & 0 \qquad \text{for } (S, \tau) : S < B, \tau \in (0, \infty),\\ \tilde{V}(S, 0) & = & 0,\\ \tilde{V}(B, \tau) & = & 1, \qquad \text{for } \tau \in [0, \infty), \end{eqnarray} where $\mathcal{L}$ is the Black-Scholes forward operator.

You attempted the first approach. Note however, that you don't need the joint CDF of the first passage time and the terminal value of the Brownian motion as the payoff doesn't depend on the latter. So you only have a single integral to solve. See this blog post for all details.

Here, I will outline the second solution strategy. Let $U(S)$ be the valuation function of a perpetual pay-at-hit binary option. You can find the derivation of its valuation function in the answer to this other question. We now notice that the solution to $\tilde{V}(S, \tau)$ can be decomposed as

$$\tilde{V}(S, \tau) = U(S) - \tilde{V}^1(S, \tau),$$

where $\tilde{V}^1(S, \tau)$ satisfies the initial boundary value problem

\begin{eqnarray} \mathcal{L} \left\{ \tilde{V}^1 \right\} \left( S, \tau^* \right) & = & 0 \qquad \text{for } \left( S, \tau^* \right) : S < B, \tau^* \in (0, \tau),\\ \tilde{V}^1(S, 0) & = & U(S),\\ \tilde{V}^1 \left( B, \tau^* \right) & = & 0 \qquad \text{for } \tau^* \in [0, \tau]. \end{eqnarray}

I.e. the value of the pay-at-hit binary option with a finite maturity is equal to a long position in the otherwise identical perpetual option plus a short position in a knock-out barrier option on the latter. The advantage of this approach is that you can now apply the method of images to solve the auxiliary problem $\tilde{V}^1(S, \tau)$. See Wilmott et al. (1995) for details.

References

Wilmott, Paul, Sam Howison, and Jeff Dewynne (1995) The Mathematics of Financial Derivatives: Cambridge University Press.