It clearly suffices to show that there exists a retraction $r : D^n \times I \to D^n \times \{0\} \cup S^{n-1} \times I$. In fact, the map $\beta$ and the homotopy $\varphi: \beta \circ i \simeq h$ can be pasted to a continuous $\phi : D^n \times \{0\} \cup S^{n-1} \times I \to Z$ and $\phi \circ r$ is what you desire.
Define
$$r(x,t) = \begin{cases} (\frac{2x}{2-t},0) & \lVert x \rVert \le \frac{2-t}{2} \\ (\frac{x}{\lVert x \rVert},2 - \frac{2-t}{\lVert x \rVert}) & \lVert x \rVert \ge \frac{2-t}{2} \end{cases} $$
This is a well-defined continuous map because
$\lVert \frac{2x}{2-t} \rVert \le 1$ for $\lVert x \rVert \le \frac{2-t}{2}$
$1 \ge t \ge 2 - \frac{2-t}{\lVert x \rVert} \ge 0$ for $1 \ge \lVert x \rVert \ge \frac{2-t}{2}$
For $\lVert x \rVert = \frac{2-t}{2}$ both parts yield the same value.
For $t=0$ we get $\frac{2-t}{2} = 1$ and thus $r(x,0) = (x,0)$ for all $x \in D^n$. For $x \in S^n$ we have $r(x,t) = (x,t)$. Thus $r$ is a retraction.
There is a nice geometric interpretation of $r$: For each $(x,t)$ consider the line $L_{x,t}$ through $(0,2)$ and $(x,t)$. This line intersects $D^n \times \{0\} \cup S^{n-1} \times I$ in a single point $r(x,t)$.
Remark:
It is very easy to see that for a closed subspace $A \subset X$ the inclusion $i : A \to X$ is a cofibration if and only if $X \times \{0\} \cup A \times I$ is a retract of $X \times I$. See for example Retraction induces Cofibration . This is also true for non-closed $A \subset X$, but the proof is sophisticated. See
Strøm, Arne. "Note on cofibrations II." Mathematica Scandinavica 22.1 (1969): 130-142.