All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
The way of fertilization mentioned in your question is permitted if the natural process of becoming pregnant is impossible. But one should take precautions, some of which are as below:
1 -This operation should be performed only by trustworthy medical professionals authorized to do so. This is to ensure confidence in the necessity, integrity and safety of the procedure.
2 -The fertilization operation should be performed by a female doctor if possible, or at the very least she should present there.
3 – One should make sure that the sperm injected into the womb of the patient is in fact that of her husband.
Any neglect of these conditions may have serious consequences, and could then be against the Sharee’ah.
Allaah Knows best.