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.
Gates with card scanners are used at almost every train station in the Netherlands. Most of the time, they work just fine – people check in with their OV chipkaart or debit/credit cards. However, when travelling with on an international train, one needs to scan the Aztec Code on the ticket. However, the gates have both an optical Aztec Code reader and also handle contactless payment cards via near-field communication (NFC). For iPhones, the NFC field of the latter triggers Apple Pay, essentially hijacking the session from the current application. While certain transport applications (e.g. NS International) stop this from happening, 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 a screenshot of the code is not sufficient – the iPhone will still change to the wallet.
Searching around the internet led into some dead ends but ultimately 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.
Note: similar gates are in operation at airports for reading the boarding pass before the security check and during the boarding process.