If money shall be paid to an agent by mistake and he in good faith shall pay it over to his principal, he shall not thereafter be personally liable therefor. In all other cases he shall be liable for its repayment. If money shall be paid by an agent by mistake, he may recover it in his own name.