You can try to derive the general case and then use n=3.
\(\displaystyle \L\\\int{sec^{n}(x)dx=\frac{1}{n-1}sec^{n-2}(x)tan(x)+\frac{n-2}{n-1}\int{sec^{n-2}(x)}dx\)
Write \(\displaystyle sec^{n}(x)=sec^{n-2}(x)sec^{2}(x)\), intgerate by parts with
\(\displaystyle u=sec^{n-2}(x)\) and \(\displaystyle dv=sec^{2}(x)dx\), and use the trig formula \(\displaystyle tan^{2}(x)+1=sec^{2}(x)\)
To the derive the case when n=3, as you have, let \(\displaystyle u=sec(x), \;\ dv=sec^{2}(x)dx, \;\ du=sec(x)tan(x)dx, \;\ v=tan(x)\)