Does all mobile wallet apps require payment gateway?

A lot of mobile wallet apps are using QR codes in a transaction. Does the fund go through a payment gateway upon scanning the QR codes in a transaction? Is mobile wallet app getting a merchant account from the available payment gateway that the app uses and issue sub-meechant IDs to the sub-merchants? So that the funds will go to the gateway first, then into master merchsnt(mobile wallet app) and finally to the sub-merchants(eg. Restaurants/stores)