Hello forrum, and thanks in advance, please help me find what I'm doing wrong, I'm sure it should be something really really stup..... but I can't find it..
My callback service is working properly, it can place the calls and bridge them, but i found that it is not billing the first leg, I've read that this is suppouse to be the defualt behavior but I found that the billing is not charging for the duration of first leg, I want a callback to be charged on both legs.
Here is my config and output
------------------------------------------------------------------------
source: 52551101 (my personal extension)
destination: 5255600 (echo test application)
both terminations are on area code 5255 (Mexico City)
------------------------------------------------------------------------
Call placed directly from my softphone, charge 1.350
1. 2007-11-22 13:52:50 847346156201194 5255600 Mexico City 00:10 9611974836 ANSWER STANDARD 1.30 1.350 usd
Call placed via callback service, charge 1.350 (why is not 2.7 ?????)
2. 2007-11-22 13:46:34 123456 5255600 Mexico City 00:09 9611974836 ANSWER STANDARD 1.30 1.350 usd
------------------------------------------------------------------------
extensions.conf
[a2billing_conf2]
exten => _X.,1,Answer
exten => _X.,2,Wait,2
exten => _X.,3,DeadAGI(a2billing.php|2)
exten => _X.,4,Wait,2
exten => _X.,5,Hangup
[a2billing-callback]
include => a2billing_conf2
------------------------------------------------------------------------
/etc/asteris/a2billing.conf
[agi-conf2]
; the debug level
; 0=none, 1=low, 2=normal, 3=all
debug = 1
; Asterisk Version Information
; 1_1,1_2,1_4 By Default it will take 1_2 or higher
asterisk_version = 1_2
; Manage the answer on the call
answer_call = NO
; Play audio - this will disable all stream file but not the Get Data
; for wholesale ensure that the authentication works and than number_try = 1
play_audio = NO
; play the goodbye message when the user has finished.
say_goodbye = NO
; enable the menu to choose the language
; press 1 for English, pulsa 2 para el español, Pressez 3 pour Français
play_menulanguage = NO
; force the use of a language, if you dont want to use it leave the option empty
; Values : ES, EN, FR, etc... (according to the audio you have installed)
force_language =
; Introduction prompt : to specify an additional prompt to play at the beginning of the application
intro_prompt =
; Minimum amount of credit to use the application
min_credit_2call = 1
; this is the minimum duration in seconds of a call in order to be billed
; any call with a length less than min_duration_2bill will have a 0 cost
; useful not to charge callers for system errors when a call was answered but it actually didn't connect
min_duration_2bill = 0
; if user doesn't have enough credit to call a destination, prompt him to enter another cardnumber
notenoughcredit_cardnumber = YES
; if notenoughcredit_cardnumber = YES then assign the CallerID to the new cardnumber
notenoughcredit_assign_newcardnumber_cid = YES
; 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
; list the dnid on which you want to avoid the use of the previous option "use_dnid"
no_auth_dnid = 2400,2300
; number of times the user can dial different number
number_try = 1
; this will force to select a specific call plan by the Rate Engine
force_callplan_id =
; Play the balance to the user after the authentication (values : yes - no)
say_balance_after_auth = YES
; Play the balance to the user after the call (values : yes - no)
say_balance_after_call = NO
; Play the initial cost of the route (values : yes - no)
say_rateinitial = NO
; Play the amount of time that the user can call (values : yes - no)
say_timetocall = YES
; enable the setup of the callerID number before the outbound is made, by default the user callerID value will be use
auto_setcallerid = YES
; If auto_setcallerid is enabled, the value of force_callerid will be set as CallerID
force_callerid =
; If force_callerid is not set, then the following option ensures that CID is set to one of the card's configured caller IDs or blank if none available.
; NO - disable this feature, caller ID can be anything.
; CID - Caller ID must be one of the customers caller IDs
; DID - Caller ID must be one of the customers DID nos.
; BOTH - Caller ID must be one of the above two items.
cid_sanitize = NO
; enable the callerid authentication
; if this option is active the CC system will check the CID of caller
cid_enable = NO
; if the CID does not exist, then the caller will be prompt to enter his cardnumber
cid_askpincode_ifnot_callerid = YES
; if the callerID authentication is enable and the authentication fails then the user will be prompt to enter his cardnumber
; this option will bound the cardnumber entered to the current callerID so that next call will be directly authenticate
cid_auto_assign_card_to_cid = YES
; if the callerID is captured on a2billing, this option will create automatically a new card and add the callerID to it
cid_auto_create_card = NO
; set the length of the card that will be auto create (ie, 10)
cid_auto_create_card_len = 10
; If cid_auto_create_card has been set to YES, the following options will define with which configuration we will create the card
;
; billing type of the new card
; ( value : POSTPAY or PREPAY)
cid_auto_create_card_typepaid = POSTPAY
; amount of credit of the new card
cid_auto_create_card_credit = 0
; if postpay, define the credit limit for the card
cid_auto_create_card_credit_limit = 1000
; the tariffgroup to use for the new card (this is the ID that you can find on the admin web interface)
cid_auto_create_card_tariffgroup = 6
; to check callerID over the cardnumber authentication (to guard against spoofing)
callerid_authentication_over_cardnumber = NO
; enable the option to call sip/iax friend for free (values : YES - NO)
sip_iax_friends = NO
; if SIP_IAX_FRIENDS is active, you can define a prefix for the dialed digits to call a pstn number
; values : number
sip_iax_pstn_direct_call_prefix = 555
; this will enable a prompt to enter your destination number.
; if number start by sip_iax_pstn_direct_call_prefix we do directly a sip iax call, if not we do a normal call
sip_iax_pstn_direct_call = NO
; enable the option to refill card with voucher in IVR (values : YES - NO)
ivr_voucher = NO
; if ivr_voucher is active, you can define a prefix for the voucher number to refill your card
; values : number - don't forget to change prepaid-refill_card_with_voucher audio accordingly
ivr_voucher_prefix = 8
; When the user credit are below the minimum credit to call min_credit
; jump directly to the voucher IVR menu (values: YES - NO)
jump_voucher_if_min_credit = NO
; Extracharge DIDs, multiple numbers and fees must be separated by comma
; extracharge_did = 1800XXXXXXX,1888XXXXXXX
extracharge_did =
;extracharge_fee = 0.02,0.03
extracharge_fee =
; More information about the Dial :
http://voip-info.org/wiki-Asterisk+cmd+dial
; 30 : The timeout parameter is optional. If not specifed, the Dial command will wait indefinitely, exiting only when the originating channel hangs up, or all the dialed channels return a busy or error condition. Otherwise it specifies a maximum time, in seconds, that the Dial command is to wait for a channel to answer.
; H: Allow the caller to hang up by dialing *
; r: Generate a ringing tone for the calling party
; R: Indicate ringing to the calling party when the called party indicates ringing, pass no audio until answered.
; m: Provide Music on Hold to the calling party until the called channel answers.
; L(x[:y][:z]): Limit the call to 'x' ms, warning when 'y' ms are left, repeated every 'z' ms)
; %timeout% tag is replaced by the calculated timeout according the credit & destination rate!
dialcommand_param = "|60|HRrL(%timeout%:61000:30000)"
; by default (3600000 = 1HOUR MAX CALL)
dialcommand_param_sipiax_friend = "|60|HL(3600000:61000:30000)"
; Define the order to make the outbound call
; YES -> SIP/dialedphonenumber@gateway_ip - NO SIP/gateway_ip/dialedphonenumber
; Both should work exactly the same but i experimented one case when gateway was supporting dialedphonenumber@gateway_ip
; So in case of trouble, try it out
switchdialcommand = NO
; failover recursive search - define how many time we want to authorize the research of the failover trunk when a call fails (value : 0 - 20)
failover_recursive_limit = 2
; For free calls, limit the duration: amount in seconds
maxtime_tocall_negatif_free_route = 5400
; Send a reminder email to the user when they are under min_credit_2call
send_reminder = YES
; enable to monitor the call (to record all the conversations)
; value : YES - NO
record_call = NO
; format of the recorded monitor file
monitor_formatfile = gsm
; Force to play the balance to the caller in a predefined currency, to use the currency set for by the customer leave this field empty
agi_force_currency =
; CURRENCY SECTION
; Define all the audio (without file extensions) that you want to play according to currency (use , to separate, ie "usd:prepaid-dollar,mxn:pesos,eur:Euro,all:credit")
currency_association = usd:dollars,mxn:pesos,eur:euros,all:credit
; Please enter the file name you want to play when we prompt the calling party to enter the destination number
; file_conf_enter_destination = prepaid-enter-number-u-calling-1-or-011
file_conf_enter_destination = prepaid-enter-dest
; Please enter the file name you want to play when we prompt the calling party to choose the prefered language
; file_conf_enter_menulang = prepaid-menulang
file_conf_enter_menulang = prepaid-menulang2
; Define if you want to bill the 1st leg on callback even if the call is not connected to the destination
callback_bill_1stleg_ifcall_notconnected = YES
-------------------------------------------------------------------------------
asterisk output
pbx001*CLI>
== Parsing '/etc/asterisk/manager.conf': Found
== Manager 'myasterisk' logged on from 127.0.0.1
-- Call accepted by 216.137.100.250 (format gsm)
-- Format for call is gsm
> Channel IAX2/mazone_ca-2 was answered.
-- Executing Answer("IAX2/mazone_ca-2", "") in new stack
-- Executing Wait("IAX2/mazone_ca-2", "2") in new stack
== Manager 'myasterisk' logged off from 127.0.0.1
-- Executing DeadAGI("IAX2/mazone_ca-2", "a2billing.php|2") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/a2billing.php
a2billing.php|2: A2Billing AGI internal configuration:
a2billing.php|2: Array
a2billing.php|2: (
a2billing.php|2: [debug] => 1
a2billing.php|2: [asterisk_version] => 1_2
a2billing.php|2: [answer_call] =>
a2billing.php|2: [play_audio] =>
a2billing.php|2: [say_goodbye] =>
a2billing.php|2: [play_menulanguage] =>
a2billing.php|2: [force_language] =>
a2billing.php|2: [intro_prompt] =>
a2billing.php|2: [min_credit_2call] => 1
a2billing.php|2: [min_duration_2bill] => 0
a2billing.php|2: [notenoughcredit_cardnumber] => 1
a2billing.php|2: [notenoughcredit_assign_newcardnumber_cid] => 1
a2billing.php|2: [use_dnid] => 1
a2billing.php|2: [no_auth_dnid] => Array
a2billing.php|2: (
a2billing.php|2: [0] => 2400
a2billing.php|2: [1] => 2300
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: [number_try] => 1
a2billing.php|2: [force_callplan_id] =>
a2billing.php|2: [say_balance_after_auth] => 1
a2billing.php|2: [say_balance_after_call] =>
a2billing.php|2: [say_rateinitial] =>
a2billing.php|2: [say_timetocall] => 1
a2billing.php|2: [auto_setcallerid] => 1
a2billing.php|2: [force_callerid] =>
a2billing.php|2: [cid_sanitize] =>
a2billing.php|2: [cid_enable] =>
a2billing.php|2: [cid_askpincode_ifnot_callerid] => 1
a2billing.php|2: [cid_auto_assign_card_to_cid] => 1
a2billing.php|2: [cid_auto_create_card] =>
a2billing.php|2: [cid_auto_create_card_len] => 10
a2billing.php|2: [cid_auto_create_card_typepaid] => POSTPAY
a2billing.php|2: [cid_auto_create_card_credit] => 0
a2billing.php|2: [cid_auto_create_card_credit_limit] => 1000
a2billing.php|2: [cid_auto_create_card_tariffgroup] => 6
a2billing.php|2: [callerid_authentication_over_cardnumber] =>
a2billing.php|2: [sip_iax_friends] =>
a2billing.php|2: [sip_iax_pstn_direct_call_prefix] => 555
a2billing.php|2: [sip_iax_pstn_direct_call] =>
a2billing.php|2: [ivr_voucher] =>
a2billing.php|2: [ivr_voucher_prefix] => 8
a2billing.php|2: [jump_voucher_if_min_credit] =>
a2billing.php|2: [extracharge_did] => Array
a2billing.php|2: (
a2billing.php|2: [0] =>
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: [extracharge_fee] => Array
a2billing.php|2: (
a2billing.php|2: [0] =>
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: [dialcommand_param] => |60|HRrL(%timeout%:61000:30000)
a2billing.php|2: [dialcommand_param_sipiax_friend] => |60|HL(3600000:61000:30000)
a2billing.php|2: [switchdialcommand] =>
a2billing.php|2: [failover_recursive_limit] => 2
a2billing.php|2: [maxtime_tocall_negatif_free_route] => 5400
a2billing.php|2: [send_reminder] => 1
a2billing.php|2: [record_call] =>
a2billing.php|2: [monitor_formatfile] => gsm
a2billing.php|2: [agi_force_currency] =>
a2billing.php|2: [currency_association] => Array
a2billing.php|2: (
a2billing.php|2: [0] => usd:dollars
a2billing.php|2: [1] => mxn:pesos
a2billing.php|2: [2] => eur:euros
a2billing.php|2: [3] => all:credit
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: [file_conf_enter_destination] => prepaid-enter-dest
a2billing.php|2: [file_conf_enter_menulang] => prepaid-menulang2
a2billing.php|2: [callback_bill_1stleg_ifcall_notconnected] => 1
a2billing.php|2: [logger_enable] => 1
a2billing.php|2: [log_file] => /tmp/a2billing.log
a2billing.php|2: [currency_association_internal] => Array
a2billing.php|2: (
a2billing.php|2: [usd] => dollars
a2billing.php|2: [mxn] => pesos
a2billing.php|2: [eur] => euros
a2billing.php|2: [all] => credit
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: [ivr_voucher_prefixe] => 8
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: file:a2billing.php - line:75 - IDCONFIG : 2
a2billing.php|2: file:a2billing.php - line:76 - MODE : standard
a2billing.php|2: file:a2billing.php - line:88 - AGI Request:
a2billing.php|2: file:a2billing.php - line:89 - Array
a2billing.php|2: (
a2billing.php|2: [agi_request] => a2billing.php
a2billing.php|2: [agi_channel] => IAX2/mazone_ca-2
a2billing.php|2: [agi_language] => en
a2billing.php|2: [agi_type] => IAX2
a2billing.php|2: [agi_uniqueid] => 1195757184.81
a2billing.php|2: [agi_callerid] => 123456
a2billing.php|2: [agi_calleridname] => unknown
a2billing.php|2: [agi_callingpres] => 0
a2billing.php|2: [agi_callingani2] => 0
a2billing.php|2: [agi_callington] => 0
a2billing.php|2: [agi_callingtns] => 0
a2billing.php|2: [agi_dnid] => unknown
a2billing.php|2: [agi_rdnis] => unknown
a2billing.php|2: [agi_context] => a2billing-callback
a2billing.php|2: [agi_extension] => 5255600
a2billing.php|2: [agi_priority] => 3
a2billing.php|2: [agi_enhanced] => 0.0
a2billing.php|2: [agi_accountcode] => 9611974836
a2billing.php|2: )
a2billing.php|2:
a2billing.php|2: file:Class.A2Billing.php - line:601 - get_agi_request_parameter = 123456 ; IAX2/mazone_ca-2 ; 1195757184.81 ; 9611974836 ; 5255600
a2billing.php|2: file:a2billing.php - line:142 - [NO ANSWER CALL]
a2billing.php|2: file:Class.A2Billing.php - line:1668 - SELECT credit, tariff, activated, inuse, simultaccess, typepaid, creditlimit, language, removeinterprefix, redial, enableexpire, UNIX_TIMESTAMP(expirationdate), expiredays, nbused, UNIX_TIMESTAMP(firstusedate), UNIX_TIMESTAMP(cc_card.creationdate), cc_card.currency, cc_card.lastname, cc_card.firstname, cc_card.email, cc_card.uipass, cc_card.id_campaign, cc_card.id, useralias FROM cc_card LEFT JOIN cc_tariffgroup ON tariff=cc_tariffgroup.id WHERE username='9611974836'
a2billing.php|2: file:Class.A2Billing.php - line:1742 - [SET LANGUAGE() en]
a2billing.php|2: file:Class.A2Billing.php - line:634 - [CARD STATUS UPDATE : UPDATE cc_card SET inuse=inuse+1 WHERE username='9611974836']
a2billing.php|2: file:Class.A2Billing.php - line:1969 - [A2Billing] SAY BALANCE : 31.01140
a2billing.php|2:
a2billing.php|2: file:Class.A2Billing.php - line:1122 - [CURRENCY : USD]
a2billing.php|2: file:Class.A2Billing.php - line:1427 - [AUTO SetCallerID]
a2billing.php|2: file:Class.A2Billing.php - line:1433 - [REQUESTED SetCallerID : 123456]
a2billing.php|2: file:Class.A2Billing.php - line:1444 - [EXEC SetCallerID : 123456]
a2billing.php|2: file:a2billing.php - line:169 - [CHANNEL STATUS : 6 = Line is up]
a2billing.php|2: file:a2billing.php - line:170 - [CREDIT : 31.01140][CREDIT MIN_CREDIT_2CALL : 1]
a2billing.php|2: file:Class.A2Billing.php - line:656 - 1 && && 7&& 0
a2billing.php|2: file:Class.A2Billing.php - line:681 - DESTINATION ::> 5255600
a2billing.php|2: file:Class.A2Billing.php - line:683 - RULES APPLY ON DESTINATION ::> 5255600
a2billing.php|2: file:Class.A2Billing.php - line:721 - OK - RESFINDRATE::> 1
a2billing.php|2: file:Class.A2Billing.php - line:743 - RES_ALL_CALCULTIMEOUT ::> 1
a2billing.php|2: file:Class.A2Billing.php - line:760 - TIMEOUT::> 81600 : minutes=1360 - seconds=0
a2billing.php|2: file:Class.RateEngine.php - line:960 - app_callingcard: Dialing 'IAX2/voipjet/0115255600|60|HRrL(81600000:61000:30000)' with timeout of '81600'.
a2billing.php|2:
a2billing.php|2: file:Class.RateEngine.php - line:985 - app_callingcard: CIDGROUPID='-1' OUTBOUND CID SELECTED IS '0'.
-- AGI Script Executing Application: (Dial) Options: (IAX2/voipjet/0115255600|60|HRrL(81600000:61000:30000))
-- Limit Data for this call:
-- - timelimit = 81600000
-- - play_warning = 61000
-- - play_to_caller= yes
-- - play_to_callee= no
-- - warning_freq = 30000
-- - start_sound = UNDEF
-- - warning_sound = timeleft
-- - end_sound = UNDEF
-- Called voipjet/0115255600
-- IAX2/voipjet-4 is circuit-busy
-- Hungup 'IAX2/voipjet-4'
== Everyone is busy/congested at this time (1:0/1/0)
a2billing.php|2: file:Class.RateEngine.php - line:960 - app_callingcard: Dialing 'IAX2/5640@iaxtermination1/0115255600|60|HRrL(72968000:61000:30000)' with timeout of '72968'.
a2billing.php|2:
a2billing.php|2: file:Class.RateEngine.php - line:985 - app_callingcard: CIDGROUPID='-1' OUTBOUND CID SELECTED IS '0'.
-- AGI Script Executing Application: (Dial) Options: (IAX2/5640@iaxtermination1/0115255600|60|HRrL(72968000:61000:30000))
-- Limit Data for this call:
-- - timelimit = 72968000
-- - play_warning = 61000
-- - play_to_caller= yes
-- - play_to_callee= no
-- - warning_freq = 30000
-- - start_sound = UNDEF
-- - warning_sound = timeleft
-- - end_sound = UNDEF
-- Called 5640@iaxtermination1/0115255600
-- Call accepted by 195.66.85.55 (format gsm)
-- Format for call is gsm
-- Hungup 'IAX2/iaxtermination1-5'
== Everyone is busy/congested at this time (1:0/0/1)
a2billing.php|2: file:Class.RateEngine.php - line:960 - app_callingcard: Dialing 'IAX2/6135@iaxtermination2/0115255600|60|HRrL(72968000:61000:30000)' with timeout of '72968'.
a2billing.php|2:
a2billing.php|2: file:Class.RateEngine.php - line:985 - app_callingcard: CIDGROUPID='-1' OUTBOUND CID SELECTED IS '0'.
-- AGI Script Executing Application: (Dial) Options: (IAX2/6135@iaxtermination2/0115255600|60|HRrL(72968000:61000:30000))
-- Limit Data for this call:
-- - timelimit = 72968000
-- - play_warning = 61000
-- - play_to_caller= yes
-- - play_to_callee= no
-- - warning_freq = 30000
-- - start_sound = UNDEF
-- - warning_sound = timeleft
-- - end_sound = UNDEF
-- Called 6135@iaxtermination2/0115255600
-- Call accepted by 195.66.85.55 (format gsm)
-- Format for call is gsm
-- Hungup 'IAX2/iaxtermination2-6'
== Everyone is busy/congested at this time (1:0/0/1)
a2billing.php|2: file:Class.RateEngine.php - line:960 - app_callingcard: Dialing 'IAX2/mazone_mx/600|60|HRrL(1428000:61000:30000)' with timeout of '1428'.
a2billing.php|2:
a2billing.php|2: file:Class.RateEngine.php - line:985 - app_callingcard: CIDGROUPID='-1' OUTBOUND CID SELECTED IS '0'.
-- AGI Script Executing Application: (Dial) Options: (IAX2/mazone_mx/600|60|HRrL(1428000:61000:30000))
-- Limit Data for this call:
-- - timelimit = 1428000
-- - play_warning = 61000
-- - play_to_caller= yes
-- - play_to_callee= no
-- - warning_freq = 30000
-- - start_sound = UNDEF
-- - warning_sound = timeleft
-- - end_sound = UNDEF
-- Called mazone_mx/600
-- Call accepted by 189.136.135.134 (format gsm)
-- Format for call is gsm
-- IAX2/mazone_mx-7 answered IAX2/mazone_ca-2
-- Hungup 'IAX2/mazone_mx-7'
a2billing.php|2: file:Class.RateEngine.php - line:1086 - -> dialstatus : ANSWER, answered time is 9
a2billing.php|2:
a2billing.php|2: file:Class.RateEngine.php - line:1090 - [USEDRATECARD=3]
a2billing.php|2: file:Class.RateEngine.php - line:777 - ft2c_package_offer : 0 ; ; 0
a2billing.php|2: file:Class.RateEngine.php - line:848 - [CC_asterisk_stop QUERY = INSERT INTO cc_call (uniqueid,sessionid,username,nasipaddress,starttime,sessiontime, calledstation, terminatecause, stoptime, calledrate, sessionbill, calledcountry, calledsub, destination, id_tariffgroup, id_tariffplan, id_ratecard, id_trunk, src, sipiax, buyrate, buycost, id_card_package_offer) VALUES ('1195757184.81', 'IAX2/mazone_ca-2', '9611974836', '', CURRENT_TIMESTAMP - INTERVAL 9 SECOND , '9', '5255600', 'ANSWER', now(), '1.3', '+1.35', '', '', 'Mexico City', '1', '1', '6', '6', '123456', '0', '0.09', '0.045', '0')]
a2billing.php|2: file:Class.RateEngine.php - line:851 - [CC_asterisk_stop 1.1: SQL: DONE : result=1]
a2billing.php|2: file:Class.RateEngine.php - line:869 - [CC_asterisk_stop 1.2: SQL: UPDATE cc_card SET credit= credit-1.35 , redial='5255600' , lastuse=now(), nbused=nbused+1 WHERE username='9611974836']
a2billing.php|2: file:Class.RateEngine.php - line:874 - UPDATE cc_trunk SET secondusedreal = secondusedreal + 9 WHERE id_trunk='6'
a2billing.php|2: file:Class.RateEngine.php - line:878 - UPDATE cc_tariffplan SET secondusedreal = secondusedreal + 9 WHERE id='1'
a2billing.php|2: file:a2billing.php - line:309 - [a2billing account stop]
a2billing.php|2: file:Class.A2Billing.php - line:634 - [CARD STATUS UPDATE : UPDATE cc_card SET inuse=inuse-1 WHERE username='9611974836']
-- AGI Script a2billing.php completed, returning 0
-- Hungup 'IAX2/mazone_ca-2'
pbx001*CLI>