📄 app_debit_callback.2.0.0.0.tcl
字号:
# Script Locked by: CiscoOfficial# Script Version: 2.0.0.0# Script Name: app_debit_callback# Script Lock Date: Fri Oct 4 11:16:30 2002# Aug 28th, 2001, Jinsong Liu# # Copyright (c) 2001 by Cisco Systems, Inc.# All rights reserved.#------------------------------------------------------------------# # Description: ## This application is a standard debitcard application with callback feature.# # The application starts with ani authentication. If ani authenticated, caller# will hear multiple beep tones which signals call back service is available to# the caller. Caller is expected to hangs up the phone. As soon as the caller# hangs up, application calls back the caller and play welcome message which starts# the standard debitcard application process. If the caller doesn't hangs up within # default 20 seconds which prevents GW from calling back, the call back will be cancelled.# User can configure CLI parameter wait-time to replace default 20 seconds.## If user is not ani authenticated, caller will be notified that the callback service# is not available.## The debitcard application allows a user to to select the lanaguage mode based on # the langauges that are configured through the CLIs.## The application then prompts and collects the card number. The card number consists # of a uid and pin where uid-length and pin-length are configured through through CLIs.## Authentication is done with the card number. If it passes authentication,# the application plays the amount available in the user's debitcard. It then# prompts and collects the destination number.## If authentication fails, the application allows user to retry and the number# of retries is configured through the CLI.## Authorization is done with the destination number. If authorization is# successful, the application plays a time duration which indicates the amount of# talk time in the user's debitcard account and places the call.## If authorization fails, the application allows users to retry.# # The main routine is at the bottom.proc init { } { global param1 global param2 global pound global beep set pound 0 set beep 0 set param1(interruptPrompt) true set param1(abortKey) * set param1(terminationKey) # set param2(interruptPrompt) true set param2(abortKey) * set param2(terminationKey) # set param2(dialPlanTerm) true set param2(enableReporting) true}proc init_ConfigVars { } { global commandHandle global operatorNum global accountLen global totalLang global retryCnt global warnTime global waitTime global prefix1 global prefix2 global prefix global pinLen set commandHandle "" set accountLen [string trim [infotag get cfg_avpair uid-len]] set pinLen [string trim [infotag get cfg_avpair pin-len]] set retryCnt [string trim [infotag get cfg_avpair retry-count]] set warnTime [string trim [infotag get cfg_avpair warning-time]] set operatorNum [string trim [infotag get cfg_avpair redirect-number]] if {[infotag get cfg_avpair_exists wait-time]} { set waitTime [string trim [infotag get cfg_avpair wait-time]] } else { set waitTime 20 } # Language related variables set totalLang [string trim [infotag get med_total_languages]]}proc init_perCallVars { } { global outgoingDisconnect global dontPlayAmount global noTimeLimit global promptFlag2 global promptFlag global selectCnt global destBusy global noPlay global count global fcnt set outgoingDisconnect 0 set dontPlayAmount 0 set noTimeLimit 0 set promptFlag2 0 set promptFlag 0 set promptFlag 0 set selectCnt 0 set destBusy 0 set noPlay 0 set count 0 set fcnt 0} proc act_Setup { } { global newGuidInd global new_guid global guid global dnis global ani init_perCallVars set newGuidInd 0 set new_guid [infotag get aaa_new_guid] set guid [infotag get leg_guid] set dnis [infotag get leg_dnis] set ani [infotag get leg_ani] infotag set med_language 1 leg setupack leg_incoming # Ani authentication set avsend(h323-ivr-out,0) "service:callback" aaa authorize $ani "" $ani "" leg_incoming -a avsend}proc act_ReSetup { } { global new_guid global guid global ani set callInfo(guid) $new_guid set callInfo(incomingGuid) $guid set callInfo(accountNum) $ani # Setup callback leg leg setup $ani callInfo}proc act_ReSetupDone { } { global callback_leg_id global totalLang global param1 global dnis set status [infotag get evt_status] if {$status == "ls_000"} { # Call back leg setup is successful set callback_leg_id [infotag get leg_outgoing] if {$totalLang < 1} { act_Cleanup } elseif {$totalLang == 1} { media play $callback_leg_id _welcome.au fsm setstate ONELANG } else { set param1(maxDigits) 1 leg collectdigits $callback_leg_id param1 media play $callback_leg_id _welcome.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au } } else { # Call back leg setup failed call close }}proc act_Authenticated { } { global billing_model global waitTime set status [infotag get evt_status] if {$status == "ao_000"} { if {[infotag get aaa_avpair_exists h323-billing-model]} { set billing_model [infotag get aaa_avpair h323-billing-model] if {$billing_model == 1} { # Caller authorized to have callback service media play leg_incoming _beep.au %s1000 _beep.au %s1000 _beep.au # Setup timer timer start leg_timer $waitTime leg_incoming fsm setstate BEEP } else { # Not authorized to have callback service media play leg_incoming _no_service.au fsm setstate CALLDISCONNECT } } else { # h323-billing-model not available media play leg_incoming _no_aaa.au fsm setstate CALLDISCONNECT } } else { # Not authorized to have callback service media play leg_incoming _no_service.au fsm setstate CALLDISCONNECT }}proc act_Disconnect { } { # Stop the timer timer stop leg_timer leg_incoming # Disconnect incoming leg leg disconnect leg_incoming}proc act_LangSelect { } { global callback_leg_id global selectCnt global retryCnt global param1 set status [infotag get evt_status] if {$status == "cd_005"} { # Collect success, set language selected set status [infotag set med_language [infotag get evt_dcdigits] ] if {$status == "language not supported" || $status == "language not specified in configuration"} { incr selectCnt if {$selectCnt < $retryCnt} { set param1(maxDigits) 1 leg collectdigits $callback_leg_id param1 media play $callback_leg_id %c1 _wrong_lang_sel.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au fsm setstate same_state } else { media play $callback_leg_id %c1 _generic_final.au fsm setstate CALLDISCONNECT } } else { # Get the card no act_GetCard } } elseif {($status == "cd_001") || ($status == "cd_002")} { # Collect timeout/Abort incr selectCnt if {$selectCnt < $retryCnt} { leg collectdigits $callback_leg_id param1 media play $callback_leg_id %c1 _no_lang_sel.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au fsm setstate same_state } else { media play $callback_leg_id %c1 _generic_final.au fsm setstate CALLDISCONNECT } }}proc act_GetCard { } { global callback_leg_id global promptFlag global accountLen global cardLen global pinLen global param1 global count set cardLen [expr $accountLen + $pinLen] set param1(maxDigits) $cardLen leg collectdigits $callback_leg_id param1 if {$count == 0} { media play $callback_leg_id _enter_card_num.au } elseif {$promptFlag == 1 } { media play $callback_leg_id _invalid_digits.au } elseif {$promptFlag == 2 } { media play $callback_leg_id _auth_fail.au } elseif {$promptFlag == 3} { media play $callback_leg_id _no_card_entered.au }}proc act_GotCardNumber { } { global callback_leg_id global promptFlag global accountLen global retryCnt global account global cardLen global pinLen global count global pin global ani set status [infotag get evt_status] if {$status == "cd_005"} { # Collect success set number [infotag get evt_dcdigits] set numberLen [string length $number] if {$numberLen == $cardLen} { # Extract account and pin set account [string range $number 0 [expr $accountLen -1]] set pin [string range $number $accountLen [expr $cardLen -1]] # Do authorize aaa authorize $account $pin $ani "" $callback_leg_id } else { incr count set promptFlag 1 if {$count < $retryCnt} { act_GetCard fsm setstate same_state } else { media play $callback_leg_id _final.au fsm setstate CALLDISCONNECT } } } elseif {$status == "cd_001"} { # Collect timeout set number [infotag get evt_dcdigits] set numberLen [string length $number] if {$numberLen == 0} { incr count set promptFlag 3 if {$count < $retryCnt} { act_GetCard fsm setstate same_state } else { media play $callback_leg_id _final.au fsm setstate CALLDISCONNECT } } elseif {$numberLen == $cardLen} { set account [string range $number 0 [expr $accountLen -1]] set pin [string range $number $accountLen [expr $cardLen -1]] # Do authorize aaa authorize $account $pin $ani "" $callback_leg_id } else { incr count set promptFlag 1 if {$count < $retryCnt} { act_GetCard fsm setstate same_state } else { media play $callback_leg_id _final.au fsm setstate CALLDISCONNECT } } } elseif {$status == "cd_002"} { # Collect aborted act_GetCard fsm setstate same_state } elseif {($status == "cd_007") || ($status == "cd_006")} { # Collect timeout/fail(disconnected)/invalid_no incr count set promptFlag 3 if {$count < $retryCnt} { act_GetCard fsm setstate same_state } else { media play $callback_leg_id _final.au fsm setstate CALLDISCONNECT } }}proc act_FirstAuthorized { } { global callback_leg_id global billing_model global promptFlag global retryCnt global count global amt set status [infotag get evt_status] if {$status == "ao_000"} { # Check billing model if {[infotag get aaa_avpair_exists h323-billing-model]} { set billing_model [infotag get aaa_avpair h323-billing-model] if {$billing_model == 1} { # Account successfully authorized, check credit amount if {[infotag get aaa_avpair_exists h323-credit-amount]} { set amt [infotag get aaa_avpair h323-credit-amount] act_GetDest } else { media play $callback_leg_id _no_aaa.au fsm setstate CALLDISCONNECT } } else { # Not authorized to have callback service media play $callback_leg_id _no_service.au fsm setstate CALLDISCONNECT } } else { # h323-billing-model not available media play $callback_leg_id _no_aaa.au fsm setstate CALLDISCONNECT } } else { # Account failed authorization, check return code if {[infotag get aaa_avpair_exists h323-return-code]} { set returnCode [infotag get aaa_avpair h323-return-code] incr count set promptFlag 2 if {$count < $retryCnt} { act_GetCard fsm setstate CARDSELECTION } else { # First authorization failed act_firstAuthorizeFailed $returnCode fsm setstate CALLDISCONNECT } } else { # No return code from radius server media play $callback_leg_id _no_aaa.au fsm setstate CALLDISCONNECT } }}proc act_firstAuthorizeFailed { returnCode } { global callback_leg_id media play $callback_leg_id _final.au}proc act_secondAuthorizeFailed { returnCode } { global callback_leg_id media play $callback_leg_id _final.au}proc act_GetDest { } { global callback_leg_id global promptFlag2 global destBusy global param2 global pound global fcnt global amt # Get destination number set param2(ignoreInitialTermKey) true leg collectdigits $callback_leg_id param2 if {$fcnt == 0} { if {$amt == 0} { media play $callback_leg_id _zero_bal.au fsm setstate CALLDISCONNECT } elseif {$amt > 999999.99} { media play $callback_leg_id _invalid_amt.au _dollars.au %s1000 _enter_dest.au } elseif {$destBusy == 1} { set destBusy 0 media play $callback_leg_id _dest_busy.au } elseif {$pound == 1} { set pound 0 media play $callback_leg_id _enter_dest.au } else { media play $callback_leg_id _you_have.au %a$amt %s1000 _enter_dest.au } } else { switch -regexp $promptFlag2 { {1} { media play $callback_leg_id _reenter_dest.au } {2} { media play $callback_leg_id _author_fail.au } {3} { media play $callback_leg_id _no_dest_entered.au }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -