Why this is a Fourier expansion if the Fourier inversion doesn't contain any $e^{-ikx}$ term? I'm studying Quantum Field Theory and in the book the author states the following:

To connect special relativity to the simple harmonic oscilator we note that the simplest possible Lorentz-invariant equation of motion that a field can satisfy is $\Box \ \phi = 0$. That is:
$$\Box \ \phi = (\partial_t^2-\nabla^2)\phi=0.$$
The classical solutions are plane waves. For example, one solution is:
$$\phi(x)=a_p(t)e^{i\mathbf{p}\cdot \mathbf{x}},$$
where
$$(\partial_t^2+\mathbf{p}\cdot \mathbf{p})a_p(t)=0.$$
This is exactly the equation of motion of a harmonic oscilator. A general solution is:
$$\phi(x,t)=\int \dfrac{d^3 p}{(2\pi)^3}[a_p(t)e^{ip\cdot x}+a_p^\ast(t) e^{-ip\cdot x}],$$
with $(\partial_t^2+\mathbf{p}\cdot \mathbf{p})a_p(t)=0$, which is just a Fourier decomposition of the field into plane waves. Or more simply:
$$\phi(x,t)=\int \dfrac{d^3p}{(2\pi)^3}(a_p e^{-ipx}+a_p^\ast e^{ipx})$$
with $a_p$ and $a_p^\ast$ now just numbers and $p_\mu=(\omega_p,\mathbf{p})$ with $\omega_p=|\mathbf{p}|$ and $px = p^\mu x_\mu$.

Now, the Fourier transform of a function $f : \mathbb{R}^3\to \mathbb{C}$ is defined as:
$$\hat{f}(\mathbf{k})=\int f(\mathbf{x})e^{-i\mathbf{k}\cdot\mathbf{x}}d^3{\mathbf{x}}$$
where I am not considering the $2\pi$ factors, nor the question of convergence, which would involve restricting $f\in \mathcal{S}(\mathbb{R}^3)$. Anyway, the Fourier inversion formula is:
$$f(\mathbf{x})=\int \hat{f}(\mathbf{k})e^{i\mathbf{k}\cdot \mathbf{x}}d^3\mathbf{k}.$$
Now, here comes the thing. The way I know to solve $\Box \ \phi = 0$ with Fourier transform is to take the Fourier transform on both sides. This leads to:
$$\partial_t^2\hat{\phi}(p,t)+|p|^2\hat{\phi}(p,t)=0$$
This determines $\hat{\phi}(p,t)$. Then Fourier inversion leads to:
$$\phi(x,t)=\int \dfrac{d^3p}{(2\pi)^3}\hat{\phi}(p,t)e^{i p\cdot x}$$
To solve the DE we notice that $\mathbf{p}$ is just a parameter, so that
$$\hat{\phi}(\mathbf{p},t)=A_p e^{-i|p|t}+B_p e^{i|p|t}$$
From which we get
$$\phi(\mathbf{x},t)=\int \dfrac{d^3 \mathbf{p}}{(2\pi)^3}(A_p e^{-i|p|t}+B_p e^{i|p|t})e^{i\mathbf{x}\cdot\mathbf{p}}=\int \dfrac{d^3 \mathbf{p}}{(2\pi)^3}(A_p e^{-i|p|t}e^{i\mathbf{x}\cdot\mathbf{p}}+B_p e^{i|p|t}e^{i\mathbf{x}\cdot\mathbf{p}}).$$
This is different than the book. Indeed, in the Fourier transform I know, we integrate $\hat{\phi}(\mathbf{p},t)e^{i\mathbf{p}\cdot\mathbf{x}}$. On the book a term with $e^{-i\mathbf{p}\cdot \mathbf{x}}$ appears in the inversion formula which I don't know where it came from.
In summary, what inside the integral is got is:
$$A_p e^{-i|p|t}e^{i\mathbf{x}\cdot\mathbf{p}}+B_p e^{i|p|t}e^{i\mathbf{x}\cdot\mathbf{p}}$$
while the book presents:
$$a_p e^{-ipx}+a_p^\ast e^{ipx}$$
how this result from the book relates to the solution with Fourier transform that I know? How this $a_p^\ast$ appeared? And how the $e^{-i\mathbf{p}\cdot\mathbf{x}}$ got there? Why am I getting a different result and how to bridge the gap between the two?
 A: If you write $\hat{\phi}(\mathbf{p},t) = A(\mathbf{p}) \exp(i t \vert \mathbf{p} \vert) + B(\mathbf{p}) \exp(-i t \vert \mathbf{p} \vert)$
and demand that $\phi$ is real, you find that you need to have $B(\mathbf{p}) = A^{*}(-\mathbf{p})$. Thus (up to the Fourier transformation coefficient)
\begin{align} \phi(\mathbf{x},t) &= \int\limits_{\mathbb{R}^{3}}  (A(\mathbf{p}) e^{-i t \vert \mathbf{p} \vert} + B(\mathbf{p}) e^{i t \vert \mathbf{p} \vert}) \, e^{i \langle \mathbf{p}, \mathbf{x} \rangle} \, \mathrm{d} \mathbf{p} \\ &=\int\limits_{\mathbb{R}^{3}}  (A(\mathbf{p}) e^{-i t \vert \mathbf{p} \vert} + A^{*}(-\mathbf{p}) e^{i t \vert \mathbf{p} \vert}) \, e^{i \langle \mathbf{p}, \mathbf{x} \rangle} \, \mathrm{d} \mathbf{p} \\ &= \int\limits_{\mathbb{R}^{3}}  A(\mathbf{p}) e^{-i t \vert \mathbf{p} \vert} \, e^{i \langle \mathbf{p}, \mathbf{x} \rangle} + A^{*}(\mathbf{p}) e^{i t \vert \mathbf{p} \vert} \, e^{-i \langle \mathbf{p}, \mathbf{x} \rangle} \, \mathrm{d} \mathbf{p}, \end{align}
where in the last step I performed the substitution $\mathbf{q} = -\mathbf{p}$ in the second summand and relabeled $\mathbf{q}$ to $\mathbf{p}$ again (!). This expression may be rewritten to the expression stated by the book by means of the Minkowski Pseudo Inner Product.
A: You are misunderstanding the notation $px$ used in the textbook. It refers to the "Minkowski inner product" or "Lorentzian inner product" which includes both the space component and the time component. This is exactly what is needed to match up your answers. 
