Pre pay calling card application

I’m looking to create a calling card / pre pay service where users will have an amount of credit applied to an inbound DID.

Does anyone have a method they could share which in realtime manages the credit and warns the caller when credit is low during a live call and then ultimatly drops the call or directs the caller to a sales team?

The solution would need to handle multiple calls coming in using the same pool of minutes so credit of 10 minutes with two callers would last 5 minutes for example.

is there a way to do this in dialplan linking to mysql?

Thanks

Look at A2billing, but here we dont provide support for A2billing so you will need to enagage with their official support or the forums.

A2billing is an over the top answer to the problem I’m trying to solve.

I was hoping to do this simply in dialplan and function ODBC commands

My initial thought was to write a routine is mysql to make a calculation on how many minutes had been used per day and subtract it from a pre paid table but I wanted to see if anyone had any better ideas on how to make this a bit more real time.

Regards

simple logic, look at the initial amount, set the price of the call calculate the maximum time and set it with timeout(absolute) then use the command DIAL with option L, if the call hang up before the limit use the billsec to reduces the amount. done

Thanks for this.

Actually my requirement is even simpler than that, I’m billing for the inbound call.

So call comes in on a specific DID (Users account)
User can user the inbound DID until there are no more minutes left
There will be multiple calls to the one DID.

So if there is 15 mins of credit and 3 callers, if they all called at the same time the call would last 5 minutes then a warning would be played, 1 more minute granted and the call drops

Next call not allowed.

So useful dialplan apps could be:
Set commands to mysql
timeout absolute

I guss the issue is getting the timeout absolute updated as callers join.

any more idea?

You will need a daemon monitoring the calls and decreasing the amount in “realtime” this daemon could be a bash script running every minute, so yes is external. But you will use maybe AMI to monitor the calls and the price then you can use AMI or asterisk -rx o hangup all channels. Finally for the warning you can try injecting audio using chanspy or joning the chan in a meetme/confbridge.

Maybe you want to look at Asterisk 12/13 and the ARI interface.

Maybe the end time is calculated and set or triggered as each call joins. No need to have a deamon as the end time only changes when another call joins.

So the calculation is remaining minutes / joined callers

Minutes = 15

call 1 opens call and duration is set to 15
call 2 joins and sets call to 7.5
call 3 joins and sets call to 5 or a third of whats left

I think I need to study what timeout(absolute) can be used for. Thanks

If I have 3 callers in a confbridge will the last caller joining the timeout(absolute) reset all the timers for all of the active calls or just itself?

I would assume that absolute timeout is implemented for the channel, but try it.

Real DID numbers can handle multiple simultaneous calls.

hmm actually I would have to close all calls for a specific DID and prevent dialing in on other DID’s

Is there a command which can dump all calls in a group?