Got extorted by police in Mexico

Been travelling Latin America for seven months but had a first today. On a bus from Oaxaca to CDMX and the bus got pulled over by police. They took me and my partner off the bus and said they wanted all our money or we were getting taken to the station. Just paid it as the bus had stopped in the middle of nowhere. Lost 500mx so not too bad overall but shaken after it.