In order for prayer to be valid, it is stipulated that one should face towards the qiblah. If one does not pray facing towards the qiblah when one is able to do so, then the prayer is invalid, because Allah, may He be exalted, says (interpretation of the meaning):
“so turn your face in the direction of Al-Masjid- al-Haram (at Makkah). And wheresoever you people are, turn your faces (in prayer) in that direction”
And the Prophet (blessings and peace of Allah be upon him) said, in the hadeeth about the one who prayed badly: “Then turn towards the qiblah and say Allahu akbar.”
Narrated by al-Bukhaari, 6667.
Ibn Qudaamah (may Allah have mercy on him) said: Six things are stipulated with regard to the prayer – among which he mentioned facing towards the qiblah. If any of these conditions are not met, with no excuse, then his prayer is not valid.
End quote from al-Mughni, 1/369
The scholars (may Allah have mercy on them) stated that if a person prays without facing towards the qiblah because he forgot, then he should repeat his prayer, because he has omitted one of the conditions of prayer.
Ibn Hazm (may Allah have mercy on him) said: If a person prays without facing towards the qiblah when he was able to work out its direction – whether he does that deliberately or because he forgot, then his prayer is invalid and he should repeat it so long as there is still time to do so, if he did that deliberately. And he should repeat it at any time if he forgot.
End quote from al-Muhalla, 2/259
The scholars of the Standing Committee for Issuing Fatwas were asked: What is the ruling on a person who goes to another city and prays without facing the qiblah by mistake, even though he knows the direction of the qiblah, then he remembers that after the time for the prayer that he offered has ended?
They replied: If a person offers a prayer without facing towards the qiblah out of negligence, in that he did not ask and he did not look at the signs that point to the direction of the qiblah, then he should repeat the prayer, because facing towards the qiblah is one of the conditions of prayer being valid when one is able to do it. So he has to repeat the prayer. The same also applies to one who prays without facing towards the qiblah by mistake. He has to repeat the prayer because he failed to fulfil one of its conditions. And Allah is the source of strength.
End quote from Fataawa al-Lajnah ad-Daa’imah, vol. 2, 5/294
Based on that, you have to repeat this prayer now that you offered without facing the direction of the qiblah.
And Allah knows best.