Whenever any person or corporation of this Commonwealth has erroneously or inadvertently paid or caused to be paid into the treasury of a political subdivision, directly or indirectly, and money for a municipal improvement for which a lien was threatened to be filed or was subsequently filed, under an assumption that such municipal assessment or lien was due and owing, when in fact such municipal assessment and/or lien or a part thereof was not due and owing to the political subdivision, or such municipal assessment or lien was not legal and valid at the time payment was made, or was subsequently declared illegal and invalid by a court of competent jurisdiction, then in such cases the corporate authorities of the political subdivision, upon due proof of any such erroneous or inadvertent payments being made within a period of two years from the time of payment thereof, are hereby authorized to draw their warrant on the treasurer in favor of such person or corporation to make refund of such money to which the political subdivision has no valid claim out of the public funds.
53 P.S. § 1261