This requires more than a simple script. You're going to need 3 things(in the simplest form)
1) streaming client - something to capture/send the rtmp data.
2) media server. Lots of options here, nginx has a great library for doing this for free. I personally used red5 previously on a project, and found it very powerful, would definitely recommend it.
3) player - JWplayer is a great JS/html5 open source and free player.
I don't know of any scripts to lock a player until payment has been received, but I'm sure it wouldn't be too difficult to make.