Asterisk Billing Solution

Hi All,

I have 8-10 SIP clients who can call each other or to PSTN via Asterisk Server.

I want to develope full billing solution for this
That includes for example

(1) Knowing before placing call how much balance someone has, (Using Voice Playback to tell SIP client his max duration of call)

(2) During Call if someone reaches it’s time limit according to balance; then terminating his call

(3) during call displaying current updated information of some active SIP client showing his total Ballance left, Time left , Total call durion etc.

How above mentioned things can be achieved?
Through changing asterisk code or using some application running beside asterisk???

Thanks in advance
Code of asterisk you will need to touch only if you need things like reverce polarity and offhook.
At least around a year ago I had to touch code.
RP you will need for adequate charging when using PSTN.
Offhook you will need to know which channel is curently available (from ZAP).
May be you need not to touch code of Asterisk at all - my experience is based on older versions then current one.