How about AstRTB ? Asterisk Real Time Billing --- Thameem Ansari <[EMAIL PROTECTED]> wrote:
> Hello All, > > I had the same question when I was writing my own > billing software in java. > Here is what I am doing to track multiple calls at a > time from the prepaid > account. > > 1. Keep on db table for balance and > reserver_balance. > 2. First call coming to agi, check the balance - Sum > of all the > reserve_balance of that account code. > 3. Check the destination and allowed minutes for > that balance amount from > step 2. > 4. Reserve balance table will contain destination, > amount, reserved secs > columns > 5. If the avaialable balance is <= 0 then announce > not enough credit and > hangup. > 6. If the available balance is > 0 but seconds > allowed to talk is less than > reserved secs (see step 8 for more details about > what this is) > then set absolutetimeout for those seconds. > 7. Otherwise the allowed seconds is more than the > allowed seconds, set > absolute time out for the reserved seconds and make > the call. > 8. Reserved secs is a custom constant seconds, say > you can reserve fund for > 3 minutes (180 seconds). if the account has balance > for only 2 minutes (120 > seconds) then the absolute time out will be 120 > seconds. > 9. Once the channel status changed to reserved, > insert an record to > reserve_balance table with uniqueid, accountcode, > amount, reserved_secs > information. > > The above steps will handle one call so far > now...and lets see how the dial > plan should be, > 10. In your dial plan, add an AbsoluteTimeout > extension "T" and call another > AGI script which will just to reset the absolute > timeout. > 11. When the particular timeout is reached asterisk > will transfer the call > to 'T" extension which will in turn call another > agi. > 12. The agi will receive all the information about > the channel including > uniqueid, repeat the steps 2- 7 (except dial) and > reset the abstimeout and > this process will repeat until the channel hangup. > 13. Once the channel hangup, you can either use > Manager to receive the cdr > event or you can set "h" extension (not reliable and > not recommended) to > calculate the real balance and update the balance > table. Once you update the > balance table, remove the record from > reserve_balance table for the > uniqueid, channel and accountcode. (these three are > enough to find out the > entry in that table). > > Now lets take the scenario for second call when the > first call was active, > > 14. When the second call comes in, start from step > 2. In step 2, we are > doing finalBalance = Balance - Sum(reserve_balance) > for that account code. > If there is already a call on this accountcode, then > this table will have > one entry and the reserved amount. Get the > finalBalance by subtracting the > amounts. Follow step 3 and allow or deny the caller. > The above said solution is very stable and doesn't > overflow the memory or > session and not using any threads. The only > restriction here is, if we have > the scenario, > > Call -1 > balance = $0.10 > destination= 1 (which is US) > rate = $0.02 per minute > reserveSecs = 10 minutes (600secs) > finalBalance = $0.10 - $0 (consider this is first > call and no entry in > reserve_balance table) = $0.10 > allowedMints = $0.10/$0.02 = 5 minutes = 300 > seconds. > AbsoluteTimeout = 300 seconds (this is less than the > default reserveSecs so > set this as abstimeout) > > Call -2 > balance = $0.10 > destination= 1 (which is US) > rate = $0.02 per minute > reserveSecs = 10 minutes (600secs) > finalBalance = $0.10 - $0.10 (consider this is > second call and already an > entry in reserve_balance table) = $0.0 > allowedMints = 0 seconds. > announce the denied ivr. > > So, the reserveSecs is critical to avoid how much > threshold amount the > caller should have to make two calls. If they have > $10 in their account as > per the above two algorithms, they can make as many > simultaneous calls. > > I hope this solves most of your problems. I looked > at ASTCC, A2Billing etc > and they are not doing this way and not know whether > they work properly. But > this works for me. Shoot me your questions if you > have one. > > I am developing my own billing and routing app (in > java) and I need a name > for that.. guys pls suggest one.. i may put that in > sourceforge if i feel > confident. > > Thanks, > Thameem > > > On 4/27/06, JP Carballo <[EMAIL PROTECTED]> wrote: > > > > Dovid Bender wrote: > > > > >A while back some one posted some code that he > used > > >that took out the flag in astcc that kept track > if > > >there was a call in progress for that pin or not. > Dont > > >know if it wil work for real time though. > > > > > >Dovid > > > > > > > > I don't know if you were pertaining to what I > posted in the message > > "ASTCC: How to reset "in-use" flag automatically > ?". > > The setinuse() routine already exists in ASTCC. > > One simply has to use that routine to disable the > inuse flag when a call > > begins and ASTCC will allow multiple calls for the > same account. > > > > However, I too have no idea if this will work for > real time. > > > > -- > > JP Carballo > > > > http://www.netfone2x.com > > Bringing the world closer. > > > > It might look like I'm doing nothing, but at the > cellular level, I'm > > really quite busy. > > > > _______________________________________________ > > --Bandwidth and Colocation provided by > Easynews.com -- > > > > Asterisk-Users mailing list > > To UNSUBSCRIBE or update options visit: > > > http://lists.digium.com/mailman/listinfo/asterisk-users > > > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com > -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > > http://lists.digium.com/mailman/listinfo/asterisk-users > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users