What you have is essentially correct... except that you can't talk about $\frac{1}{p}$ unless $p$ lies in $S$, you are correct about that. That's why the problem is phrased the way it is: to show that $\frac{p}{1}$ is a unit. You can't "cancel" in the fraction, because only fractions with denominators in $S$ are allowed in $S^{-1}R$. So what you need to do is show that they are inverses by multiplying them out and showing the result is equal, in $S^{-1}R$, to $1_{S^{-1}R}$.
Indeed, the fact that $p$ is prime is irrelevant.
Proposition. Let $R$ be a commutative ring, not necessarily a domain, let $S$ be a multiplicative subset (not necessarily containing $1$), and let $\varphi\colon R\to S^{-1}R$ be the canonical map (sending $r\in R$ to $\frac{rt}{t}$ for some $t\in S$; this is well-defined and independent of the choice of $t$). If $x\in R$ divides some element of $S$, then $\varphi(x)$ is a unit in $S^{-1}R$.
If $1\in S$, then you can take the map $\varphi$ to be $\varphi(r)=\frac{r}{1}$.
Proof. Let $s\in S$ and $y\in R$ be such that $s=xy$. We show that $\frac{y}{s}\in S^{-1}R$ is the inverse of $\varphi(x)$. Indeed, we have $\varphi(x)\frac{y}{s} = \frac{xs}{s}\frac{y}{s} = \frac{xsy}{ss}$. We prove that this is equal to $\frac{s}{s}\in S^{-1}R$, as $\frac{s}{s}= 1_{S^{-1}R}$.
To show that $\frac{xsy}{ss}=\frac{s}{s}$ we need to show that there exists $s'\in S$ such that $s'(xyss-sss)=0$. But since $xyss=(xy)ss=sss$, we have $xyss-sss=0$, so taking $s'\in S$ arbitrary we have equality. Thus, $\frac{xys}{ss}=\frac{s}{s}=1_{S^{-1}R}$. This proves that $\varphi(x)$ is a unit in $S^{-1}R$, as desired. $\Box$