Extend Payment Gateways

I am working on integrating the braintree payment gateway into my membership install. However, one question that is coming up is where should this code go? I see that the membership plugin loads the gateways by looking through the gateway folder (which is hard-coded). I shouldn’t put the gateway there, as it will get wiped out after each update. Any ideas? What have others done?