You can have this drawn up as a formal agreement by a solicitor who would probably charge between £500 and £1000 for the agreement.
Alternatively and probably a better option is a simple letter from the friend to you stating exactly what is going to be paid over how long and what will happen if it does not get paid such as if it does not get paid, the whole amount becomes due immediately.
If someone does not pay you either because they don't want to repay you or because they cannot repay you, all the agreements and all the terms and conditions in the world will not get the money from them.
You need to do to make a binding agreement is to have an offer and acceptance. If there is an offer and an acceptance there is an agreement which is legally binding. The reason for having it in writing is so that the terms of the agreement are not in dispute.
It is also important to have something in writing with regard to the intention to repay so that at some stage in the future he does not allege that it was a gift.
So a simple letter will do this but you do need to put in, in simple terms, exactly what has been agreed between you.
There is one thing that you need to do and that is to include the following phrase: "this is a formal agreement intending to create legal relations and to be enforceable through the court if necessary"
The reason for including the last bit is that the courts are reluctant to enforce informal arrangements between family members or friends.
Can I clarify anything for you?