[Asterisk-Users] PrePaid and IVR

Brian West brian at bkw.org
Tue Aug 19 20:36:12 MST 2003


I see all these posts about wanting a script for prepaid setup... Have you
not even tried to look it up or put any effort forth?  If you stop and
think about it its not that hard.  It takes alot of error checking, alot
of testing to make sure it does correctly.  I did something simple today
just playing around.  I'm sure its buggy.. I'm sure it could be done
better... I'm sure some of you will giggle and point at it:


#!/usr/bin/perl
#
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $try = 0;

while(length($pin) >= 3 || $try < 3) {
        $pin = $AGI->get_data("agent-pass", "10000", "4");
        if($pin eq "1234") {
                $AGI->exec('SetAccount',$pin);
                $AGI->stream_file('auth-thankyou');
                $AGI->exec('AbsoluteTimeout','10');
                $AGI->exec('Dial','ZAP/1/4238080');
                $AGI->hangup();
                exit(0);
        }
        $try++;
}
$AGI->stream_file('vm-goodbye');
$AGI->hangup();
exit(0);

You could also query one db for the card/pin and see how much time that
pin is worth.. then subtract the usage from that and use that value*60 for
AbsoluteTimeout

Now slap some DBI, better error checking and more logic/safeguards all of
which i'm going to be doing later on this week... but this is a very basic
concept of how it can be done.

Hint Hint.. you can round all the calls up to the next min by doing an sql
query (if using cdr_mysql)

select SUM(CEILING(billsec/60)) as used from cdr where accountcode='1234';

Just pass the accountcode == pin number

Really not that hard now is it?

bkw


On Tue, 19 Aug 2003, CW_ASN wrote:

> Could you give us an example? It could be interesting.
>
> Thanks,
>
> Gus
>
> ----- Original Message -----
> From: "Lubomir Christov" <voip at minitelecom.org>
> To: <asterisk-users at lists.digium.com>
> Sent: Tuesday, August 19, 2003 1:41 PM
> Subject: Re: [Asterisk-Users] PrePaid and IVR
>
>
> >
> > O, Jeremy again you :)
> >
> > What is the problem with a RADIUS based biling system now?
> > We know very well on this mailing list that you hate Quicknet products
> > and RADIUS based solutions .... ;)
> > I don't know way ... but it's tru.
> > We have here a 100% working calling card solution using Quicknet
> > hardware, Asterisk and RADIUS based billing system :)
> >
> > Best regards
> > Lubo
> >
> > Jeremy McNamara wrote:
> > > It is not that simple.  First you need a real billing system (no not
> > > RADIUS based), then you need some sort of calling card application (AGI
> > > works, but the Asterisk C API is much better), then you are going to
> > > need some sort of luser friendly GUI to admin and manage your calling
> > > card accounts.
> > >
> > > The calling card application itself is cake, the GUI isn't trivial, but
> > > not very complicated. The hard part is the billing system. Most billing
> > > platforms out there are nothing but hacks and kludges (Yes even
> SysMaster)
> > >
> > >
> > > Jeremy McNamara
> > >
> > >
> > >
> > > Bartosz Jozwiak wrote:
> > >
> > >> Hello,
> > >>
> > >> If it is not too much to ask.
> > >> Could you please provide some examples of configuration files ?
> > >>
> > >> Thanks in advance.
> > >> Bartosz
> > >>
> > >>     ----- Original Message -----
> > >>     *From:* Cristian Vasiliu <mailto:cvasiliu at accessnet.ro>
> > >>     *To:* asterisk-users at lists.digium.com
> > >>     <mailto:asterisk-users at lists.digium.com>
> > >>     *Sent:* Saturday, August 16, 2003 11:20 AM
> > >>     *Subject:* Re: [Asterisk-Users] PrePaid and IVR
> > >>
> > >>     Yes ! And the answer for "HOW?" :
> > >>
> > >>     1. IVR : "Welcome to XXX . Please enter your PIN for
> authentication"
> > >>     2 Authentication with mysql for a pin  (a  table in which  you
> > >>     enter the PIN and the value for card)
> > >>     3. IVR : "Please enter the number you want to reach "
> > >>     4. Dial the number they have entered!
> > >>     5. In CDR (mysql or another database) decrease the value of their
> > >>     card.
> > >>
> > >>          It worked for me... :-) I was deep into   CDR source and I
> > >> had to
> > >>     develop the auth and preserv unicity applications. But it worked.
> > >>
> > >>     Bartosz Jozwiak wrote:
> > >>
> > >>>     Hello,
> > >>>          Is it possible to make an IVR Prepaid system with Asterisk ?
> > >>>     For example like on Cisco routers.
> > >>>          regards,
> > >>>     Bartosz Jozwiak
> > >>
> > >>
> > >
> > >
> > > _______________________________________________
> > > Asterisk-Users mailing list
> > > Asterisk-Users at lists.digium.com
> > > http://lists.digium.com/mailman/listinfo/asterisk-users
> > >
> > >
> >
> > _______________________________________________
> > Asterisk-Users mailing list
> > Asterisk-Users at lists.digium.com
> > http://lists.digium.com/mailman/listinfo/asterisk-users
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
>



More information about the asterisk-users mailing list