A2billing Tutorials
This document details the basic setup and configuration of a2billing v1.3.3 in Trixbox v2.2 It assumes that no configuration has been performed yet...as in, we are starting with a fresh install.
We are assuming in this tutorial that trixbox 2.2.4 or higher is already installed.
1) A2billing Installation
Log in to your terminal server from the console or SSH with root credentials
and Perform the following commands:
Step1: Removing A2billing Old files
The directories and files to be removed are as follows:
- /var/www/html/a2billing/
- /var/www/html/a2customer/
- /var/lib/asterisk/agi-bin/a2billing.php
- /var/lib/asterisk/agi-bin/libs_a2billing/
- /etc/asterisk/additional_a2billing_iax.conf
- /etc/asterisk/additional_a2billing_sip.conf
- /etc/asterisk/a2billing.conf
At the command prompt type:
rm -f -R /var/www/html/a2billing/
rm -f -R /var/www/html/a2customer/
rm -f -R /var/lib/asterisk/agi-bin/a2billing.php
rm -f -R /var/lib/asterisk/agi-bin/libs_a2billing/
rm -f -R /etc/asterisk/additional_a2billing_iax.conf
rm -f -R /etc/asterisk/additional_a2billing_sip.conf
rm -f /etc/asterisk/a2billing.conf
Drop the old database (if it exists)
At the command prompt type:
mysqladmin drop mya2billing -u root -ppassw0rd
(default password is passw0rd unless if you changed) Step2: A2billing installation
At the command prompt type:
cd /usr/src
wget http://www.asterisk2billing.org/downloads/A2Billing_1.3.3.tar.gz .
wget http://dfn.dl.sourceforge.net/sourceforge/phprpms/php-pcntl-4.3.11-2.5.1.i386.rpm .
rpm -ivh php-pcntl-4.3.11-2.5.1.i386.rpm
tar -xzf A2Billing_1.3.3.tar.gz
cd A2Billing_1.3.3
cd
/DataBase/mysql/Mysql-3.x_4.x/
This is a one line command:
echo "GRANT ALL PRIVILEGES ON *.* TO 'a2billinguser'@'localhost' IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | mysql -ppassw0rd
mysqladmin create mya2billing -u a2billinguser -pa2billing
This is a one line command:
mysql mya2billing -u a2billinguser -pa2billing < a2billing-mysql-schema-MYSQL.3.X-4.X_v1.3.0.sql
Step3: A2billing web interfaces installation
At the command prompt type:
cd ..
cd ..
cd ..
mv ./A2Billing_UI /var/www/html/A2Billing_UI
mv ./A2BCustomer_UI/ /var/www/html/A2BCustomer_UI
Step4: A2billing configuration files
At the command prompt type:
mv a2billing.conf /etc/asterisk/a2billing.conf
cd A2Billing_AGI mv a2billing.php /var/lib/asterisk/agi-bin/a2billing.php
mv libs_a2billing /var/lib/asterisk/agi-bin
Step5: A2billing Extra sounds
cd ..
cd /addons/sounds/
mv * /var/lib/asterisk/sounds/
Note: if you going to use calling in other languages than english, please peform the following:
mkdir /var/lib/asterisk/sounds/digits/es
mkdir /var/lib/asterisk/sounds/digits/fr
mkdir /var/lib/asterisk/sounds/digits/br
Then download the extra sounds digits for the language used from this URL:
http://www.voip-info.org/wiki/view/Asterisk+sound+files+international
Don't forget to set the permissions:
At the command prompt type:
chown -R asterisk:asterisk /var/lib/asterisk/sounds/digits/es
chown -R asterisk:asterisk /var/lib/asterisk/sounds/digits/br
chown -R asterisk:asterisk /var/lib/asterisk/sounds/digits/fr
chown -R asterisk:asterisk /var/lib/asterisk/sounds/en
chown -R asterisk:asterisk /var/lib/asterisk/sounds/es
chown -R asterisk:asterisk /var/lib/asterisk/sounds/fr
chown -R asterisk:asterisk /var/lib/asterisk/sounds/br
Step6: Asterisk files
At the command prompt type:
cd /etc/asterisk/
touch additional_a2billing_iax.conf
touch additional_a2billing_sip.conf
touch extensions_a2billing.conf
touch
sip_custom.conf
touch iax_custom.conf
During the install process, three new files were created: -
- additional_a2billing_sip.conf - SIP friends
- additional_a2billing_iax.conf - IAX Friends
- extensions_a2billing.conf - A2Billing contexts
We need to ensure that the values in these files are picked up by Asterisk.
Edit /etc/asterisk/sip_custom.conf
using ssh (nano command) or trixbox's configedit utility and include additional_a2billing_sip.conf so that it looks like this:
| #include additional_a2billing_sip.conf |
Edit /etc/asterisk/iax_custom.conf and include additional_a2billing_iax.conf so that it
looks like this:
| #include additional_a2billing_iax.conf |
Finally, we need to include extensions_a2billing.conf in extensions_custom.conf
Edit extensions_custom.conf and add #include extensions_a2billing.conf under the other includes, so that it looks like this:
#include extensions_hud.conf
#include extensions_a2billing.conf |
Step7: A2billing file permissions
At the command prompt type:
chmod 666 /etc/asterisk/additional_a2billing_iax.conf
chmod 666 /etc/asterisk/additional_a2billing_sip.conf
chmod 666 /etc/asterisk/extensions_a2billing.conf
chown -R asterisk:asterisk /etc/asterisk/
chown -R asterisk:asterisk /var/www/html/
chown -R asterisk:asterisk /var/lib/asterisk/
Step8: A2billing Initial configuration
Database Section
The file a2billing.conf, located in /etc/asterisk/ is where all the defaults are set for the A2Billing system. It is recommended that most of the defaults are left as are, unless you are trying to achieve something specific. Changes to the file, when saved have an instant effect on the behaviour of A2Billing.
This file can be editted using your favourite editor, such as vi, via winSCP or via Config Edit included with Trixbox.
comment out dbtype = postgres
remove the ; from ;dbtype = mysql
It should look like this:
[database]
hostname = localhost
port = 5432
user = a2billinguser
password = a2billing
dbname = mya2billing
;dbtype = postgres
dbtype = mysql |
Manager Section
Please edit a2billing.conf manager connection credentials to match those in manager_custom.conf so that it looks like this:
; MANAGER CONNECTION PARAMETERS
manager_host = localhost
manager_username = a2billinguser
manager_secret = a2billing |
Step9: A2billing Contexts
In extensions_a2billing.conf, add the following lines:
| [custom-a2billing]
exten => _X.,1,Answer
exten => _X.,n,Wait(1)
exten => _X.,n,DeadAGI(a2billing.php|1)
exten => _X.,n,Hangup
[a2billing-callback]
exten => _X.,1,DeadAGI(a2billing.php|2|callback)
exten => _X.,n,Hangup
[custom-a2billing-callback]
exten => _X.,1,DeadAGI(a2billing.php|2|callback)
exten => _X.,n,Hangup
[a2billing-cid-callback]
exten => _X.,1,DeadAGI(a2billing.php|2|cid-callback|1
exten => _X.,n,Hangup
[custom-a2billing-allcallback]
[custom-a2billing-did]
exten => _X.,1,deadAGI(a2billing.php|1|did)
exten => _X.,2,Hangup |
Step10: a2billing.conf file
We need to make a small change to made to a2billing .conf in this application - set
"use_dnid = yes" in a2billing .conf and save the file.
We will use Config Edit trixbox utility to modify a2billing.conf under section agi-conf1 .
|
[agi-conf1]
; 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 = 0
; 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 = NO
; 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 = 3
; 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 = YES
; 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 =YES
; 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 = YES
; 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 = 9
; 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 = YES
; 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 =
; List the prefixes that will be stripped off if the call plan requires it
international_prefixes = 011,00,09
; 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
; g: When the called party hangs up, exit to execute more commands in the current context. (new in 1.4)
; i: Asterisk will ignore any forwarding (302 Redirect) requests received. Essential for DID usage to prevent fraud. (new in 1.4) Useful if you are ringing a group of people and one person has set their phone to forwarded direct to voicemail on their cell or something which normally prevents any of the other phones from ringing.
; 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|HRgrL(%timeout%:61000:30000)"
; by default (3600000 = 1HOUR MAX CALL)
dialcommand_param_sipiax_friend = "|60|HRgirL(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 = NO
; 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
|
Step11: Reload Asterisk files
Using confedit utility or from freepbx , reload asterisk.
Click “Submit Changes” then click on "ApplyConfiguration Changes"

2) Trixbox/Freepbx Configuration
Providers and trunks
In this tutorial we will be using dialdigit origination/termination provider.
dialdigit offers 25 channels per 1 DID and great international rates. For more details it can be found here: www.dialdigit.com
Using FREEPBX to configure your Trixbox server with dialdigit provider
FREEPBX can configure the following:
Incoming Calls — Specify where to send calls coming from the outside
Extensions — Add extensions and set voicemail properties
Ring Groups — Group extensions that should ring simultaneously
Queues — Place calls into queues and allow them to be answered in order
Digital Receptionist — Create voice menus to greet callers
Trunks — Set up trunks to connect to the outside world
Outbound Routing — Manage which trunks outbound calls go out
DID Routes — Specify the destination for calls if their trunk supports direct inward dial
On Hold Music — Upload MP3 files to be played while users are on hold
System Recordings — Record or upload messages for specific extensions
Backup and Restore — Create, back up, and restore profiles of your system
General Settings — Set basic dialing, company directory, and fax settings
Step1: Access the Web Portal Interface
- Open your web browser and type HTTP://YourTrixboxIPaddressHere
- Switch to Admin Mode. (click on the switch link in the upper right corner)
- Enter the username and password given in the confirmation Email.
- Click on the Asterisk Menu
- Select FreePBX
Step2: Configuring trunk for inbound and outbound calls
Outgoing Settings
Trunk Name: dialdigit
Peer Details:
allow=ulaw
allow=alaw
allow=g729
authname=Your username
canrenvite=no
context=from-pstn
fromuser=Your username
host=IP address
insecure=very
secret= Your password
sendrpid=yes
trustrpid=yes
type=friend
username=Your username
Incoming Settings
USER Context: Leave blank
PEER Details
Leave blank
Registration
Leave blank
Click “Submit Changes” then click on "Apply ConfigurationChanges"

Step3:General Settings
Click on General settings and allow anonymous SIP calls


Step4: Configuring Outbound Routing (optional)
You will need to allow calls from your phones to go out on a trunk. When having more than one trunk, you will need to setup dialing rules (dialing patterns) in order to specify which calls should go out on which trunk.
- Select setup
- Click on Outbound Routes.
- Assign a name for your route (USA-International).
- Enter the following Information:
Dial Patterns
NXXXXXX
NXXXXXX
NXXNXXXXXX
1800NXXXXXX
1888NXXXXXX
1877NXXXXXX
1866NXXXXXX
1NXXNXXXXXX
011.
411
911
Trunk Sequence
Select dialdigit


Step5: Configuring Inbound Routing for calling card service
NOTE: YOU WILL NOT BE ABLE TO RECEIVE CALLS IF YOU DO NOT CONFIGURE AT LEAST ONE INBOUND ROUTE
Configuring inbound routes will allow calls from dialdigit go someplace in your PBX.
Using FREEPBX
- Select setup
- Select Inbound Routes.
- Enter the DID number like: 1112223333 and leave Caller ID Number boxes empty.
- Under “set destination” select Custom App to "custom-a2billing,_X.,1"
- Click Submit


Click “Submit Changes” then click on "Apply ConfigurationChanges"


Step6: Test Call
Call the dialdigit Virtual number or the DID associated to it . Your should hear "Please enter your complete pin number"
3) A2billing Getting started
Step1: Create a trunk
In order to make outbound calls, it is necessary to create a trunk.
It is assumed that you already have a working trunk in the Trixbox / FreePBX, and this trunk can be used in A2Billing.
Identify the name of the trunk in FreePBX - in this tutorial, we'll assume its called dialdigit
- On the Sidebar, Trunks -> Add Trunk
- Give the trunk a useful name - for example in this case, dialdigit
- Enter the type of trunk you are using in FreePBX (SIP / IAX2 / ZAP)and enter the type of trunk in "Provider Tech" In this case, we'll assume it's an SIP trunk, so enter SIP.
- In the Provider IP section, simply type the name of the trunk you have already set up in FreePBX. In this example dialdigit
- Click "confirm data" in the bottom right hand corner of the screen

Step2: Create a call plan
- On the sidebar, click Ratecard -> Create call plan
- Give the call plan a name, e.g. Plan1
- You have two options, LCR and LCD - LCR will route the call at the cheapest rate for you, and LCD will route the call at the cheapest rate for the customer.
- Leave Package set to "No Package Offer" as we have not created one yet.
- Remove Inter Prefix should be set to yes if your VoIP provider demands that the numbers be dialedin IETF format. Leave it to NO if you just want the calls dialedas is.

Step3: Create a Ratecard
We now have to create a new ratecard. For demonstration purposes, we'll call it Rate1
- Click "Create new Ratecard" on the sidebar.
- In Tariff Nameenter Rate1
- Select dialdigit in the trunk field and confirm data.

Step4: Add Rate Card to Call Plan
Go back and click "List Call Plan" and if everything is still going well, you should see Plan1 listed. Click Edit at the end of the line, and at the bottom of the page, in the drop down select the previously created Rate1 Click Add, and confirm data.
As you get rates from different providers, they can be added into the call plan and selected on the basis of price. 
Step5: Create Rates
For this tutorial, we are testing via VoIP and we want to make our first call over A2Billing to a USA national number. USA National numbers begin with 1 prefix. In this we will use 1617 prefix.
To create a rate card from a CSV file please look at the end of this section.
- Click Ratecard -> Add Rate
- Select the ratecard you are adding the rate to in the ratecard drop down
- Enter the dial prefix as 1617.
- Enter a name for the destination - USA Mass
- Set the buying rate - in this case 0.015
- Set the minimum duration to 30
- Set the Buyrate Billing Block to 6
- Put in the selling rate - 0.02
- The Sellrate min duration to 30
- The sellrate Billing Block to 6
- The connect charge and disconnect charge can be left blank.
- Start date: (leave default)
Stop date: (leave default)
Start time: (leave default)
End time: (leave default)
- Set the Trunk to dialdigit, as we defined it earlier for the ratecard as a whole.
- Confirm data.


Step6: Create Calling cards/ Accounts
The customer can be created one at a time from the Admin interface, created in bulk from the admin screens.
In order to create a customer from the signup page, outbound email has to be working (type setup-mail from the command line) , also make sure that your hostname is a valid hostname like: a2billing.mydomain.com
In this example - we will create a new customer from the admin interface.
- Click Customers -> Create Customers
- Add a balance, say 5
- Select the Plan1 we created earlier
- Activated = yes
- Signup Confirmation = yes
- Enter your Name and email address in the appropriate fields
- and confirm data.
You could also generate large number of calling cards by a one single click button.

Customers can also be created from the customer signup page at
http:// <Your_IP_Address>>/A2Billing_UI/signup
Note you will also need to modify the Signup mail template from the MISC menu:
Last thing is to make sure the signup page is activated under a2billing.conf file.
Locate the signup section and it should look like this:
|
[signup]
; enable the signup module
enable_signup = 1
|
4) Paypal Module
Go ToBilling > View payment Methods > paypal details >
Add the business account email address (according to your business paypal account)

Here is a working configuration file! Text in orange has to be changed to match your settings.
[epayment_method]
enable = yes
; eg, http://localhost - should not be empty for productive servers
http_server = "http://www.yourdomain.com"
; eg, https://localhost - Enter here your Secure Server Address, should not be empty for productive servers
https_server = "https://www.yourdomain.com"
; Enter your Domain Name or IP Address, eg, 26.63.165.200
http_cookie_domain = www.domain.com
; Enter your Secure server Domain Name or IP Address, eg, 26.63.165.200
https_cookie_domain = www.domain.com
; Enter the Physical path of your Application on your server
http_cookie_path = "/A2BCustomer_UI/"
; Enter the Physical path of your Application on your Secure Server
https_cookie_path = "/A2BCustomer_UI/"
; Enter the Physical path of your Application on your server
dir_ws_http_catalog = "/A2BCustomer_UI/"
; Enter the Physical path of your Application on your Secure Server
dir_ws_https_catalog = "/A2BCustomer_UI/"
; secure webserver for checkout procedure?
enable_ssl = yes
http_domain = www.domain.com
dir_ws_http = "/var/www/html"
; maybe try with :
; Define here the URL to notify the payment
; payment_notify_url=...
;define the different amount of purchase that would be available - 5 amount maximum (5:10:15)
purchase_amount = 1:2:5:10:20
; Item name that would be display to the user when he will buy credit
item_name = "Credit Purchase"
; Currency for the Credit purchase, only one can be define here
currency_code = USD
; Define here the URL of paypal gateway the payment (to test with paypal sandbox)
paypal_payment_url = "https://secure.paypal.com/cgi-bin/webscr"
;paypal_payment_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"
;paypal transaction verification url
paypal_verify_url = www.paypal.com
;paypal_verify_url = www.sandbox.paypal.com
; Define here the URL of Authorize gateway
;authorize_payment_url = "https://secure.authorize.net/gateway/transact.dll"
;authorize_payment_url = "https://test.authorize.net/gateway/transact.dll"
;paypal store name to show in the paypal site when customer will go to pay
store_name = Yourstorename
;Transaction Key for security of Epayment Max length of 60 Characters.
;Yours should be different than this
transaction_key = asdf1212fasd121554sd4f5 ;Moneybookers secret word
moneybookers_secretword = areski
; SIGNUP MODULE |
Note: It is very important to have ports 443 and 445 open and routed to the server or the balance of customers will not be updated automatically.
For integrations with other CC providers like: Linkpoint and
Authorize.net, please contact us at sales@click4pbx.com
5) Callback Module
In this example we will use callback-all method.
Step1: Installing callback module Make sure that this package is installed:perl-DBD-MySQl
At the command prompt type:
mkdir /var/lib/asterisk/a2billing/
mv /usr/src/a2billing/CallBack/callback-daemon /var/lib/asterisk/a2billing/
echo "*******************************************************************"
echo "Now installing callback"
echo "-------------------------------------------------"
echo "Go with the defaults in the following script - when prompted, but in your country"
echo ""
echo ""
echo "When you see the CPAN prompt, and the script has halted, you will need to type the following"
echo "SO TAKE NOTES"
echo "*******************************************************************"
echo "*******************************************************************"
echo "install Config::IniFiles"
echo "reload"
echo "quit"
echo "*******************************************************************"
sleep 10
pear install --alldeps SOAP-0.9.4
perl -MCPAN -e shell
cd /var/lib/asterisk/a2billing/callback-daemon/
install --owner=root --group=root --mode=700 a2billing-callback-daemon.rc /etc/rc.d/init.d/a2billing-callback-daemon
chkconfig --add a2billing-callback-daemon && chkconfig a2billing-callback-daemon on
service a2billing-callback-daemon start tail -F /var/log/asterisk/a2billing-daemon-callback.log
Step2: Configure manager
You have to enable manager connections on the servers where is runningthe callback daemon .
Using Conf Edit trixbox utility, open manager_custom.conf file
[a2billinguser]
secret=a2billing
;deny=0.0.0.0/0.0.0.0
;permit=127.0.0.1/255.255.255.0
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user
This will allow connection from anywhere , so you can be more restrictive using deny and permit like:
deny=0.0.0.0/0.0.0.0
permit=**my-ip**/255.255.255.0
That will allow connections only from **my-ip**
Save the file and reload asterisk! Step3: Create agi-conf2
We will need to create another agi-conf context named agi-conf2 just after agi-conf1:
|
[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 = YES
; 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 = YES
; 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 = 0
; 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 = NO
; 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 = NO
; 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 = 3
; 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 = NO
; 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 = NO
; 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 = YES
; 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 = 9
; 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 = YES
; 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 =
; List the prefixes that will be stripped off if the call plan requires it
international_prefixes = 011,00,09
; 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
; g: When the called party hangs up, exit to execute more commands in the current context. (new in 1.4)
; i: Asterisk will ignore any forwarding (302 Redirect) requests received. Essential for DID usage to prevent fraud. (new in 1.4) Useful if you are ringing a group of people and one person has set their phone to forwarded direct to voicemail on their cell or something which normally prevents any of the other phones from ringing.
; 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|HRgrL(%timeout%:61000:30000)"
; by default (3600000 = 1HOUR MAX CALL)
dialcommand_param_sipiax_friend = "|60|HRgirL(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 = NO
; 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
|
You also need to change the callback setting under /etc/asterisk/a2billing.conf file.
|
[callback]
; When web call-back is enabled this is the context to sent the call.
context_callback = custom-a2billing-callback
; this is the Extension to redirect the call when the web callback is returned
extension = 1000
; this is the number of seconds to wait before initiating the call back.
sec_wait_before_callback = 10
;Number of seconds before the call-back can be re-initiated from the web page
; to prevent repeated and unwanted calls.
sec_avoid_repeate = 30
; if the callback doesnt succeed within the value below, then the call is deemed to have failed.
timeout = 20
; if we want to manage the answer on the call
; Disabling this for callback trigger numbers makes it ring not hang up.
answer_call = yes
; PREDICTIVE DIALER
; number of calls an agent will do when the call button is clicked
nb_predictive_call = 10
; Number of days to wait before the number becomes available to call again.
nb_day_wait_before_retry = 1
; The context to redirect the call for the predictive dialer
context_preditctivedialer = a2billing-predictivedialer
; When a call is made we need to limit the call duration : amount in seconds
predictivedialer_maxtime_tocall = 3600
; set the callerID for the predictive dialer and call-back
callerid = 1112223333
; ID Call Plan to use when you use the all-callback mode, check the ID in the "list Call Plan" - WebUI
all_callback_tariff = 11
; Define the group of servers that are going to be used by the callback
id_server_group = 1
; Audio intro message when the callback is initiate
callback_audio_intro = prepaid-callback_intro
; CUSTOMISATION Of THE CUSTOMER INTERFACE |
Save the a2billing.conf file and reload asterisk! Step4: Setup DID for callback
Configuring inbound routes will allow calls from dialdigit go to callback context named: custom-a2billing-allcallback
Using FREEPBX
- Select setup
- Select Inbound Routes.
- Enter the DID number like: 1112223333 and leave Caller ID Number boxes empty.
- Under “set destination” select Custom App to "custom-a2billing-allcallback,_X.,1"
- Make sure that you send a ringing tone back to VoIP provider and let them know that you are reachable. Otherwise it will get back to caller saying "the number is a none working number"
- Click Submit



click “Submit Changes” then click on "ApplyConfiguration Changes"  Test the call and it should call you back saying "Please enter your pin number".
6) DID Module
This works as follows:
- Make sure that the DID is working by making tests .
- Pass the call into A2Billing with the DID switch.
- Add the DID in this screen
- Set the destination in Add Destination.
Step1: Setup DID In freepbx
Configuring inbound routes will allow calls from dialdigit go to callback context named: custom-a2billing-allcallback
Using FREEPBX
- Select setup
- Select Inbound Routes.
- Enter the DID number like: 1112223333 and leave Caller ID Number boxes empty.
- Under “set destination” select Custom App to "custom-a2billing-did,_X.,1"
- Click Submit
 
click “Submit Changes” then click on "ApplyConfiguration Changes"

Step2: Setup DID In A2billing
1)
Enter the DID exactly as received by Asterisk "1112223333"
2) This is where the billing type is set.
- Fix per Month + Dial out rate - Charge a monthly subscription, and make a charge for all calls which go out via a trunk. The rate charged will depend on the customers rate plan. Calls that are made to VoIP destinations (not via a trunk) are not able to be charged. - there is a methodology of charging for voip calls, search the forum for a solution.
- Fixed - Charge only a fixed monthly charge. All calls to any destinations are not charged.
- Dial Out Rate - Charge only when the call is delivered via a trunk at the rate dictated in the customers call plan.
3)
Set a start date and expiry date for the DID.
4)
Set the group that the DID belongs to.
5)
The country label used for identification of the DID for the customer.
6) Activated set to :
Yes or no.
7) Set the monthly rate in the base currency. In order for this to be charged and applied, a cron job has to be set up in the system. See the comments in /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_bill_diduse.php for more information on setting this up.
8)
Submit the changes

The the Add sestination screen you can forward calls to other destinations.
Note that if a call goes out via a trunk, then the call will be charged at a per minute rate, assuming you have set this as your pricing model, but where a call goes out directly over VOIP, not via a trunk, there will be no perminute charge applied.
Destination
Set the destination here. It is necessary to tell A2Billing the technologly being used to deliver the call, e.g. SIP/ IAX2/ ZAP/ or local/
To forward to a SIP friend on the system
In the destination type
sip/123456
where 123456 is the card number
A per minute charge will not be applied
Set Voip call = yes
To forward to an IAX friend on the system
In the destination type
iax2/123456
where 123456 is the card number.
Optionally, you can type iax2/123456/555654321 where 555654321 is a DID on your asterisk system, and therefore will match on your inbound route for that DID.
A per minute charge will not be applied
Set Voip call = yes
Forwarding to a SIP destination
Most SIP addresses are in the form user@ DomainName? .com so simply point to sip/joe@domain.com
A per minute charge will not be applied
Set Voip call = yes
Forwarding to the PSTN
Simply type in the the number of divert, exactly as A2Billing expects so see it. e.g. 1112223333
The call will be charged according the to the customer's call plan as the call is going out via a trunk.
Set Voip call = no
Forwarding to a Local Extension Number
To forward a call to a local number, e.g. an extension on FreePBX, type:-
local/246@from-internal
where 246 is the extension number and from-internal is the context in which the extension sits.
Set Voip call = yes ID Card
Select the card number to be charged for this DID.
Select DID
Select the DID entered in the Add DID section
Activated
Yes / No - Switch it on or off
Priority
There are up to 5 priorities, where the call will fail over if the destination is unavailable.
The suggested use is to put a VoIP destination as priority 1, and a landline or mobile as priority 2. If the VoIP destination is unavailable, then it will try the landline.
If both are set to priority 1, then it will call both destinations simultaneously.
VoIP Call
Set VoIP Call = yes if the destination is VoIP, see the examples above.
Set VoIP call = No if the call is to go out via a trunk irrespective of whether the trunk is a VoIP trunk or not.
Confirm Data
Confirm Data to apply the settings.

Note: if you want to charge local destinations expample: extensions, queues, ring groups, conferences, etc.. please contact us at support@click4pbx.com
Click4PBX offers a high end dedicated A2billing platforms:
http://www.click4pbx.com/hosted-calling-cards.html
This documentation is still in progress as we will add more tutorials.
|