TL;DR: To prevent your iPhone from switching to Apple Pay at train station gates when scanning your ticket’s code, use Guided Access mode. This can be turned on in the accessibility settings and activated by triple-clicking the side button of your phone.
Recently, when travelling to FOSDEM from Amsterdam to Brussels via railway, I ran into the following problem. The Aztec Code for my train was saved on my iPhone. When I pulled out the phone to scan it at the entrance gates of Amsterdam Centraal, my phone kept opening the wallet for Apple Pay, making the Aztec Code no longer visible. These type of check-in gates (with the built-in card readers) are used at almost every train station in the Netherlands. This can also occur at airports with the automated gates that read the boarding pass before the security check and during the boarding process.
This can happen when you have a ticket with an Aztec code from the EuroStar, Deutsche Bahn, or other railway company. The reason for the phenomenon is that the gate has both an optical Aztec Code reader but it also handles contactless payment cards via near-field communication (NFC). The NFC field of the latter triggers Apple Pay, essentially hijacking the session from the current application. While certain transport applications stop this from happening, some regular applications (e.g. file sharing apps) do not handle this, so the code is not going to be visible for the optical reader. Also, the Camera/Photos app switch to the Wallet, therefore, simply taking of the code is not sufficient – the iPhone will still change to the wallet.
Searching around the internet led into some dead ends but I found a solution on the r/iphone subreddit. This solution suggests using the Guided Access mode, which can be activated as follows:
Go to Settings > Accessibility > Guided Access, then turn on Guided Access.
Once Guided Access is allowed, open the app where the Aztec Code is, then triple-press the side button to enter Guided Access mode. This prevents the phone from activating Apple Pay and opening the wallet. Once you have read the code, exit Guided Access mode by triple-pressing the side button, inputting your passcode, and tapping End.