As to all lands, except those mentioned in section 896 of this title, which have been so erroneously certified or patented as aforesaid, and which have been sold by the grantee company to citizens of the United States, or to persons who have declared their intention to become such citizens, the person or persons so purchasing in good faith, his heirs or assigns, shall be entitled to the land so purchased, upon making proof of the fact of such purchase at the proper land office, within such time and under such rules as may be prescribed by the Secretary of the Interior, after the grants respectively shall have been adjusted; and patents of the United States shall issue therefor, and shall relate back to the date of the original certification or patenting, and the Secretary of the Interior, on behalf of the United States, shall demand payment from the company which has so disposed of such lands of an amount equal to the Government price of similar lands; and in case of neglect or refusal of such company to make payment as hereafter specified, within ninety days after the demand shall have been made, the Attorney General shall cause suit or suits to be brought against such company for the said amount: Provided, That nothing in sections 894 to 899 of this title shall prevent any purchaser of lands erroneously withdrawn, certified, or patented as aforesaid from recovering the purchase money therefor from the grantee company, less the amount paid to the United States by such company as by said sections required: And provided, That a mortgage or pledge of said lands by the company shall not be considered as a sale for the purpose of said sections, nor shall said sections be construed as a declaration of forfeiture of any portion of any land grant for conditions broken, or as authorizing an entry for the same, or as a waiver of any rights that the United States may have on account of any breach of said conditions. Provided further, That where such purchasers, their heirs or assigns, have paid only a portion of the purchase price to the company, which is less than the Government price of similar lands, they shall be required, before the delivery of patent for their lands, to pay to the Government a sum equal to the difference between the portion of the purchase price so paid and the Government price, and in such case the amount demanded from the company shall be the amount paid to it by such purchaser.