Callback

Hello

i am trying to develop a custom billing solution for asterisk, curentrly experiencing some trouble with callback. The callback does not bill ( there are no records in CDR, the call from asterisk to the client, but the call that client makes when asrerisk has made a callback is placed into CDR there for it’s billed, the question is how to force asterisk to write this call to CDR

here is the code

callback_dial.php - acurring the clients nuber



#!/usr/local/bin/php -q
<?php

require_once 'phpagi/phpagi.php';
require_once '/usr/local/apache2/htdocs/asterisk_agi/db.class.php';
require_once '/usr/local/apache2/htdocs/asterisk_agi/asterisk.class.php';
$agi   = new Agi();
$aster = new Asterisk();
$cid   = $agi->parse_callerid();

if ($agi->request['agi_extension'] == '380445856211')
    $tel = '3' . $agi->request['agi_callerid'];


$aster->saveCallbackPhone($tel);

?>

callback_call.php - number dial ( the one that is not placed to CDR )




 #!/usr/local/bin/php -q
<?php

ob_implicit_flush(true);
set_time_limit(0);

require_once '/usr/local/apache2/htdocs/asterisk_agi/db.class.php';
require_once '/usr/local/apache2/htdocs/asterisk_agi/asterisk.class.php';


/*
$err=fopen("php://stderr","w");
$in = fopen("php://stdin","r");
while (!feof($in)) {
$temp = str_replace("\n","",fgets($in,4096));
$s = split(":",$temp);
$agi[str_replace("agi_","",$s[0])] = trim($s[1]);
if (($temp == "") || ($temp == "\n")) {
break;
}
}
*/
$aster = new Asterisk();


while (true) {
    
$time = time();

    foreach ($aster->getCallbackPhones($time) AS $row) {

        $params = array(
            'tel'      => $row['phone'],
            'CallerID' => $row['sip'],
            'Context'  => 'callback-from'
        );
        outgoing($params);
    }
    
    $aster->deleteCallbackPhones($time);
    sleep(10);
}

function outgoing($params) {
    $cf = fopen("/var/spool/asterisk/outgoing/" . $params['tel'], "w+");
     fputs($cf,"Channel: IAX2/intelia-frn/00" . $params['tel'] . "\n");
     fputs($cf,"CallerID: \"".$params['CallerID']."\"<".$params['CallerID'].">\n");
     fputs($cf,"MaxRetries: 1\n");
     fputs($cf,"RetryTime: 60\n");
//     fputs($cf,"WaitTime: 30\n");
     fputs($cf,"Context: ".$params['Context']."\n");
     fputs($cf,"Extension: ". $params['tel']."\n");
     fputs($cf,"Priority: 1");
    fclose($cf);
}

?>

Any Advices are welcome

thx in advance
:smiley:

i have fixed it :smiley: thx for help 8)