Multi Marchant Payment Gateway

Based on my knowledge the current gateways provide payments between users and single marchant or app owner to let money transfered to his account.

But what if we want to apply a multi marchant that users could transfer money to any account? so the app can handle the transactions between all users and all multi account instead of single account.

maybe one of the solutions is paybal that could link the marchants account and user account. but how it could auto generated to handle different api keys and accounts?