Borrowing a car from someone who does not own it, writing a contract and paying the money in the same meeting
If the reality is as you have mentioned, this sale transaction is Haram (prohibited), because it is actually
selling Dirhams for Dirhams, and this is the Riba that is prohibited by the Qur’an, Sunnah (whatever reported from the Prophet), and Ijma‘ (consensus of scholars). It is obligatory on you to return the Dirhams that you received from him, without any increase, due to the invalidity of the sale.
May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.