We develop a numerical scheme to construct the scattering (S) matrix for optical microcavities, including the special cases with parity-time and other non-Hermitian symmetries. This scheme incorporates the explicit form of a nonlocal boundary condition, with the incident light represented by an inho