If it is ascertained in any action brought on any contract, that a rate of interest has been contracted for greater than is authorized by this chapter, whether directly or indirectly, in money, property, or other valuable thing, or that any gift or donation of money, property, or other valuable thing has been made or promised to be made to a lender or creditor, or to any person for him, the design of which is to obtain for money loaned or for debts due or to become due, a rate of interest greater than that specified by the provisions of this chapter, the same shall be usurious and shall work a forfeiture of the entire interest on the debt. The court before which such action is prosecuted shall render judgment for the amount due on the sum loaned or the debt contracted, without interest, against the defendant, and for the costs of the action, against the plaintiff, whether such action is contested or not.