Since you say that you sold that person the goods before you even possessed them, and after that you went and bought them from the market, this agreement is invalid, as you sold what you did not possess. The Prophet (peace be upon him) said,
"Do not sell what you do not possess."
Ibn Majah and others)
May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.