Generally the rule is that you have to receive an invitation to visit the country, which can only be issued by a licensed agent once you have arranged your accommodation and travel in advance. An additional fee must then be paid for the visa.
Some agents will issue a visa for a fee without you having the necessary itinerary in advance but in theory this is illegal. Once this back-and-forth has been fully set up by the agency in question most travellers should find they qualify for a 30-day visa. Shorter term transit visas are available too but are equally as complicated to arrange and cost just a little less.