Refer and Earn

I would like to implement Refer and Earn service in our ionic 1 app. Looking for a full fledged solution where user can refer and earn post successful implementation by the persona referred by him. It ahs to be one package where individual codes get generated and analytics will be shown. Please help me.