All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
A Fatwa is not enough for this question. Rather, it is a number of issues, each of which can be the subject of an independent research or a scientific letter.
In any case, what we can say in brief, is that if there is a dispute between the parties in the contract, then either they solve the problem with mutual agreement, or they take the matter to an Islamic court, which is responsible for solving disputes.
Allah knows best.