It is impermissible for the merchant to sell what he does not have or own because the Prophet (peace be upon him) forbade this.
Hakim ibn Hizam (may Allah be pleased with him) said: I approached the Prophet (peace be upon him) and said: "People sometimes come up to me and ask to buy what I do not have. I go and buy what some person needs from the market and sell it to him." The Prophet (peace be upon him) replied, "Do not sell what you do not own."
Al-Nasa'y). As for the profits made by the merchant from these transactions while he was ignorant of the ruling, we hope that there is no sin on him in this regard.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.