Either 'to buy' (purpose) or 'buying' (activity) will work. Either 'but then' or 'and then' is fine, but be sure to precede but/and with a comma.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
wangqh2696122My summer travel started terribly . I was at the Shanghai Railway Station [trying to] buy a ticket to Hang Zhou. I was going to visit a friend there and after that I would go to Xiamen for a long holiday. I bought my ticket and turned around to pick up my bag.