How does the system know that the ticket was already used?
The thing with plane and long-distance train tickets is that you buy them for a specific route. So all the checking only needs to be done at your departure station/airport, the code for which is encoded in the ticket, and the rest of the system doesn't need to know anything about it. But you can't do that with city transport. When there aren't multi-use tickets, people would often buy multiple single-use ones at a time and use them as the need arises, without knowing in advance when, where, and from where they'll be going.
Fair enough. I went through qr code of my previous metro ticket to see what info they encode. It is non standard so there were
- some hashes
- type of ticket, in my case single use,
- time of issue,
- valid upto time, approx 10hrs, approx journey time was only 30 min
- ticket id
- I could not directly see source/destination address, but it is my hunch that atleast the destination address is encoded
Now this one time ticket needs to generated before entering the metro station and the qr code is scanned at * both entry and exit*.
I think the entire system works on daily rotating ticket id validated using unique hashes where a ticket validity period is tracked. I think this should be enough to ensure non-reuse of same ticket.
The caveat is, I have always only bough one time ticket which is the only mode allowed in qr. For daily traveller's, they need to buy token/card which is NFC based.
Thinking of it, QR codes make sense for when you buy a single-use ticket at the station with the intention to use it immediately.
We actually have this for suburban trains, it's just a receipt with a 1D barcode on it. You use the barcode to open the turnstile (on some stations where they are installed), but otherwise the tickets are checked by controllers that occasionally go through trains.
For getting around a city though, I don't see much of a good use case. In my city, if you're here for at least several days, you're expected to buy the refillable card. If you're only here briefly and only need to use the metro a couple times, it's 1.5x more expensive but you'd buy tokens or tap with your bank card.
The system can just keep track of whether the ticket has already been used before. You don't have to store the information on the ticket itself. You can store the information on a central server, connected to all the gates.
The ticket itself just has to encode an ID, and then the central database contains an entry for that ID that is checked by the gate in real time. When the ticket is scanned at a gate, the database gets updated.
That server would have to process thousands of requests per second during a rush hour with very little delay. In addition to QR codes just being much more finicky than tapping a card or sticking something into a slot.
This is indeed how systems around the world do it for NFC tickets. The problem with QR codes is that they're very easy to copy, so the potential for abuse with this approach is much higher. What's to stop people from using the same ticket on two different stations within the sync period?
The QR code can encode (or the system can track, or both) any combination of origin, destination, expiration (or purchase time + validity period), ticket number, etc. Check with the local server that the ID exists with the given information and that the ticket isn't expired, then allow the user through, and the server marks that ticket number as used. If the origin doesn't match the current station, the ticket is expired, or the ticket is used, don't let the user in.
So you would have to buy a ticket every time you go somewhere. That would work for tourists, sure, assuming there are vending machines that can print those QR codes. But it would not work for locals (imagine everyone buying tickets during a rush hour), and even for some tourists, it would be a nuisance. If you're visiting a city and you know you're going to take the subway N times, you would just buy N tickets, but with this system no such thing is possible.
And what about all those transfer discounts some cities have? Like if you're taking the subway and a bus within some timeframe, you still only pay once.
The thing with plane and long-distance train tickets is that you buy them for a specific route. So all the checking only needs to be done at your departure station/airport, the code for which is encoded in the ticket, and the rest of the system doesn't need to know anything about it. But you can't do that with city transport. When there aren't multi-use tickets, people would often buy multiple single-use ones at a time and use them as the need arises, without knowing in advance when, where, and from where they'll be going.