In cases where assignments of real estate mortgages are made after the passage of this act, if such assignments are not recorded, the mortgagor, his or her heirs, personal representatives, or assigns, may pay all matured interest or the principal debt itself prior to the recording of such assignment to the mortgagee, or if an assignment of such mortgage has been made that duly appears of record, then such payment may be made to the last assignee whose assignment is recorded in accordance with the provisions of this act, and such payment shall be effectual to extinguish all claims against such mortgagor, his or her heirs, personal representatives, and assigns, for or on account of such interest or such principal indebtedness; and no transfer of any note, bond or other evidence of indebtedness, by endorsement or otherwise, where such indebtedness is secured by mortgage on real estate within this state, shall prevent or operate to defeat the defense of payment of such interest or principal by the mortgagor, his or her heirs, personal representatives, or assigns, where such payment has been made to the mortgagee or to the assignee whose assignment appears last of record under the provisions of this act: Provided, however, That in all such cases the assignee who may hold such unrecorded assignment shall have a right of action against his or her assignor to recover the amount of any such payment of interest or principal made to such assignor as upon an account for money had and received for the use of such assignee.
K.S.A. 58-2321