Any defendant may plead in general terms that the contract or assurance on which the action is brought was for the payment of interest at a greater rate than is allowed by law, to which plea the plaintiff shall reply generally, but may give in evidence upon the issue made up thereon any matter which could be given in evidence under a special replication. Under the plea aforesaid, the defendant may give in evidence any fact showing, or tending to show, that the contract, or assurance, or other writing upon which the action was brought, was for an usurious consideration. Upon such plea the court shall direct a special issue to try and ascertain:
(a) Whether or not the contract, assurance or other writing is usurious; (b) if usurious, to what extent; (c) whether or not interest has been paid on such contract, assurance or other writing, above the legal rate, and if so, to what extent; (d) if a verdict be found for the defendant upon the plea of usury, a judgment shall be rendered for the plaintiff for the principal sum due, with interest at the legal rate, and, if any interest has been paid above the legal rate, the excess over and above that rate, shall be entered as a credit on the sum due; but if nothing be found due after applying all credits and all excesses of interest paid above the legal rate, judgment shall be entered for the defendant; and if the total of such credits and interest paid exceed the principal sum due with legal interest thereon, the defendant shall have judgment for the difference. The provisions of this section shall not apply in any case where suit is brought on a contract, assurance or writing, and the defendant undertakes to show that the contract, assurance or writing is for the payment of interest at a rate which is prohibited by the terms of the following article.