Any surety on the original contract, or on stay of execution, or on appeal, or in any other way, or the representative of a deceased surety, who shall have paid off or discharged the judgment or execution in whole or in part and shall have the fact of such payment by him entered on such execution by the plaintiff or his attorney or the collecting officer, shall have the control of such execution and the judgment upon which it is founded, to the same extent as if he were the original plaintiff therein, and be subrogated to all the rights of such plaintiff, for the purpose of reimbursing himself from his principal.