We stopped in Ecuador and went through Immigration while the bus crossed and waited. We also changed money.. Then we walked across and went through Peruvian border controls (two different buildings - one each side of road)