Didn't buy one of those phone numbers from an SMS API. Had good success with Tasker Android app.
https://play.google.com/store/apps/details?id=net.dinglisch....
(This was in 2012-13. Not sure if Tasker can do these things today what it could do in 2012, due to increased security limitations in Android)
Had a rule configured in Tasker to call a HTTP end point with the sender details. received timestamp and the text message content, whenever a message was received on the android phone.
Didn't have to write any code and could get it done in the Tasker app UI, as it had all the variables/tokens available and I just had to form the endpoint link to be pinged with those variables in the request.
A similar thing might be possible with Tasker or similar apps to do the other way round (ie, having the phone send an SMS via mobile network in response to a ping from another device on the wifi network)