Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Fri Mar 29, 2024 9:14 am
VoIP Billing solution


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject:
PostPosted: Sun Jan 27, 2008 4:32 am 
Offline

Joined: Wed Jan 23, 2008 10:21 am
Posts: 15
Further to my post below I have worked out a way to enable calls initiated from the dialplan (extensions.conf) to be billed to a specific A2B user.

This may be useful if you are wanting calls from within an IVR for example to be accounted for and charged to a particular user/client.

There may be a better way of doing this, if so please let me know how I should be doing this. For now, this seems to work.

Still to do:
- enable dialing to multiple numbers (e.g. calling a user's office, mobile, IAX2 phone at same time)
- handle the DIALSTATUS on hangup so you can still have voicemail, additional IVR options etc

To get this working you need to modify your extensions.conf, a2billing.php and Class.A2Billing.php files.

Modifications required (I've included some code either side so you can see where to put it).

Make backups of your files first.

1. Modify the a2billing.php file

Code:
if ($agi->request['agi_extension']=='s'){
            $A2B->dnid = $agi->request['agi_dnid'];
         }else{
            $A2B->dnid = $agi->request['agi_extension'];
         }
         
         //this is around line 230 in the a2billing.php file
         //Swap DNID with NUMTODIAL var defined in extensions
         $dialDNID =  $agi->get_variable("NUMTODIAL");
         $dialDNID  = $dialDNID ['data'];
         if (strlen($dialDNID) > 0) $A2B->dnid  = $dialDNID;
         //END

         if ($A2B->agiconfig['ivr_voucher']==1){
            $res_dtmf = $agi->get_data('prepaid-refill_card_with_voucher', 5000, 1);
            $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "RES REFILL CARD VOUCHER DTMF : ".$res_dtmf ["result"]);
            $A2B-> ivr_voucher = $res_dtmf ["result"];
            if ((isset($A2B-> ivr_voucher)) && ($A2B-> ivr_voucher == $A2B->agiconfig['ivr_voucher_prefixe']))
            {   
               $vou_res = $A2B->refill_card_with_voucher($agi, $i);
               //if ($vou_res==1)$A2B->fct_say_balance ($agi, $A2B->add_credit, 1);
            }
         }


2. Modify the Class.A2Billing.php file

Code:
/*
    * intialize evironement variables from the agi values
    */
   function get_agi_request_parameter($agi){
   
      $this->CallerID    = $agi->request['agi_callerid'];
      $this->channel      = $agi->request['agi_channel'];
      $this->uniqueid      = $agi->request['agi_uniqueid'];
      $this->accountcode   = $agi->request['agi_accountcode'];
      //$this->dnid      = $agi->request['agi_dnid'];
      $this->dnid      = $agi->request['agi_extension'];
      
      //custom dialplan DNID defined?
      $dialDNID =  $agi->get_variable("NUMTODIAL");
      $dialDNID  = $dialDNID ['data'];
      if strlen($dialDNID) > 0 {
         //NUMTODIAL was defined, set it
         $this->dnid  = $dialDNID;
         $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "Dialplan DNID ".$this->dnid);
       }
      //END custom dialplan DNID
      //Call function to find the cid number
      $this -> isolate_cid();
      
      $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, ' get_agi_request_parameter = '.$this->CallerID.' ; '.$this->channel.' ; '.$this->uniqueid.' ; '.$this->accountcode.' ; '.$this->dnid);
   }


3. In extensions.conf

Add a new macro
Code:
[macro-a2bexten];
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
exten => s,1,Set(CALLERID(all)=${ARG2} <${ARG1}>)
exten => s,2,Set(NUMTODIAL=${ARG3})
exten => s,3, DeadAGI,a2billing.php|2 ; ADJUST YOUR a2billing conf here
exten => s,4,Wait,2
exten => s,5,Hangup


I'd like to include checks for DIALSTATUS to enable voicemail etc but for now this works.

In your dial plan, where you would like to make a call and charge it to a particular card, here's how you do it:

Configure extension 96 to call Sydney 006124567890, bill to A2B account 6515000, CallerID name John Smith. I'm not sure if the name is required but I'm putting it in for now anyway :-)
Example:
Code:
exten => 96,1,Macro(a2bexten|651527|John Smith|006124567890)


Added after 19 minutes:

Some additional notes :-)

In your a2billing.conf you need to set:
Code:
; number of times the user can dial different number
number_try = 1


If you set it any higher than 1 if caller hangs up before remote party (the person called) then the person called will be prompted to enter a new number.

The above setup assumes you have configured to allow authentication based on DNID

Code:
; if YES it will use the DNID and try to dial out, without asking for the phonenumber to call
; value : YES, NO
use_dnid = YES


That's all I can think of now, if anyone is trying this and it doesn't work for you I'll post my full config file here.

Added after 3 hours 37 minutes:

A correction

In step 2 replace the relevant line with:

Code:
if (strlen($dialDNID) > 0) {


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 4:46 am 
Offline

Joined: Fri Oct 27, 2006 6:17 pm
Posts: 161
that is a cool work !


Top
 Profile  
 
 Post subject: Re: charging calls from dialplan to an a2billing user - solved
PostPosted: Thu Jul 21, 2011 10:31 am 
Offline

Joined: Tue Jul 13, 2010 11:41 am
Posts: 8
so before doing the above tutorial a2billing must install first?
and replace the script in the code or add it below?


Top
 Profile  
 
 Post subject: Re: charging calls from dialplan to an a2billing user - solved
PostPosted: Fri May 17, 2013 2:48 am 
Offline

Joined: Sun Mar 03, 2013 1:52 pm
Posts: 7
Hi,

That's great work!

Exactly what I'm trying to do right now.
Would you be so kind to post your a2billing.php + Class.A2billing.php and config files to be
able to charge calls from dialplan ?


Thank you!

-TL


Top
 Profile  
 
 Post subject: Re: charging calls from dialplan to an a2billing user - solved
PostPosted: Fri May 17, 2013 5:02 am 
Offline

Joined: Sun Mar 03, 2013 1:52 pm
Posts: 7
I tried your setup, but AGI returns 0 every time :/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group