Yes, but that land would not have been "sold" if they hadn't lost the war. The war was fought to conquer land, and the payment was for war "reparations".
The U.S. agreed to pay $15 million for the physical damage of the war and assumed $3.25 million of debt already owed by the Mexican government to U.S. citizens