This is not a full function USSD, only the buying of daily voice bundles is functional and the airtime advance option. The rest of the functions in one way or the other behave like the two implemented here. For the M-Pesa part I will be cloning the Ecocash USSD which has the same functionality as the M-Pesa.
To test this code, the advice is to use ngrok.com/get-started/ and africastalking.com
To download and use ngrok head over to https://ngrok.com/download for more information.
Check out the africastalking website for more info on how to create ussd channels and how to use emulators to test the functionlaity of this code.