To get a language course visa for Germany you’ll need a confirmation from a language school in Germany. That’s what I explained to you in my post “How do you get a visa for Germany?”.
So how can you apply for a German course in Germany, if you’re still in your home country?
Nowadays this is quite easy, because most language schools for international students offer online inscription and payment. So you just have to choose an adequate course for your German level, fill out an online form and pay the course. The most popular payment option are credit cards. After payment you’ll receive a confirmation of your inscription.
Can you trust? If you check out my post “Where can you learn German in Germany?” you’ll find some links to well known and reliable addresses in Germany. But there are definitely more trustworthy places around there.
What if you don’t know the level of your German language skills? Usually you’ll take an entrance exam, before you start your course in Germany. So it is no problem if you do not know your level of German. Just register for a course that roughly corresponds to your German level.
Anyhow according to my experience you should calculate that your German level in Germany is one level lower than the level you have reached in your home country. That means for example B1 in your country is A2 in Germany. Exceptions confirm the rule. ;-) If you (only) know some words and phrases your level is A1.