You can pay using the Viva Viagem card, which is super handy for all public transportation in Lisbon, or you can buy a 24-hour transport ticket, or you can simply pay cash as you board the bus. Most buses run until 11:00 PM, and there are even night buses that cover specific routes.