Membership plugin. How to set the order paid status?

Hi. I need to use my own payment gateway and I was able to modify the 2CO gateway provided by Membership plugin so it is sending needed values now. But how to create the callback script which will mark make the subscription active for user? I have two parameters USER_ID and SUBSCRIPTION_ID which I can return but how and where to return these value? And second question is where to get the documentation on what parameters can be used inside payment gateway script?