May I know which passport do you have, if it's a South Asian passport, the immigration officers at the border might make problems when you do a border bounce, better to take a flight and re-enter from Airport immigration. Flights from Thailand are quite affordable to neighbouring countries.
you can purchase it online but I would recommend you to use a broker, they don't charge you any commission and will assist you with everything even in emergency situations