Any public agency selling surplus land to an entity described in Section 54222 for park or recreation purposes, for open-space purposes, for school purposes, or for low- and moderate- income housing purposes may provide for a payment period of up to 20 years in any contract of sale or sale by trust deed for the land. The payment period for surplus land sold for housing for persons and families of low and moderate income may exceed 20 years, but the payment period shall not exceed the term that the land is required to be used for low- or moderate-income housing.