Showing posts with label a2billing. Show all posts
Showing posts with label a2billing. Show all posts

Tuesday, October 27, 2015

Handling Austrian (and maybe German and Swiss) DID numbers with extensions at A2Billing

In Austria still using classic ISDN dialing rules. So, if your company have number 431234567, and your internal number is 101 you can dial 431234567101 from any phone and get to extension 101 without any crappy IVR's.
Causes several problems with dialing rules, but make life much more comfortable.
So, the problem is how to handle those DID's in A2Billing, cause this soft uses only exact matches.
Solution - use MySQL patterns in DID fields directly.

So, now DID in A2Billing will looks like
 431234567%
 yes with "%" sign at the end.
Also, for VoIP destination was made a quick modification, that allows to use variables in dialstring.
So, destination will be like
SIP/<YourSipUser>/%did%.
At %did% A2billing will automatically place original DID(extension)

Patch is below
diff -Naur AGI/a2billing.php agi-bin/a2billing.php
--- AGI/a2billing.php 2015-02-27 15:42:38.000000000 +0100
+++ agi-bin/a2billing.php 2015-10-27 13:17:49.000000000 +0100
@@ -643,7 +643,8 @@
             " aleg_carrier_initblock_offp, aleg_carrier_increment_offp, aleg_retail_initblock_offp, aleg_retail_increment_offp ".
             " FROM cc_did, cc_did_destination, cc_card ".
             " WHERE id_cc_did=cc_did.id AND cc_card.status=1 AND cc_card.id=id_cc_card AND cc_did_destination.activated=1 ".
-            " AND cc_did.activated=1 AND did='$mydnid' ".
+            //" AND cc_did.activated=1 AND did='$mydnid' ".
+            " AND cc_did.activated=1 AND '$mydnid' LIKE did ". // Added to Austrian DID handling
             " AND cc_did.startingdate<= CURRENT_TIMESTAMP AND (cc_did.expirationdate > CURRENT_TIMESTAMP OR cc_did.expirationdate IS NULL ".
             " AND cc_did_destination.validated=1";
         if ($A2B->config["database"]['dbtype'] != "postgres") {
diff -Naur AGI/lib/Class.A2Billing.php agi-bin/lib/Class.A2Billing.php
--- AGI/lib/Class.A2Billing.php 2015-02-27 15:42:38.000000000 +0100
+++ agi-bin/lib/Class.A2Billing.php 2015-10-27 11:26:36.000000000 +0100
@@ -1324,6 +1324,8 @@
                     $dialparams = str_replace("%timeout%", min($time2call * 1000, $max_long), $dialparams);
                     $dialparams = str_replace("%timeoutsec%", min($time2call, $max_long), $dialparams);
                     $dialstr = $inst_listdestination[4] . $dialparams;
+    // Added support for %did% variable
+    $dialstr = str_replace("%did%", $this->orig_ext, $dialstr);

                     $this->debug(DEBUG, $agi, __FILE__, __LINE__, "[A2Billing] DID call friend: Dialing '$dialstr' Friend.\n");


Friday, December 14, 2012

A2Billing. Хочу быть провайдером.

Итак... Захотелось мне стать провайдером, благо дешевую международку я нашел. Теперь с каждой станцией буду давать немного трафика покупателям! И мне несложно, и плюшка приятная. Используется версия 2.0.1
1. LAMP! (+php-gd)
2. Ставим Asterisk с поддержкой realtime (для этого поставить дополнительно mysclclient-dev)
3. Качаем A2Billing и внимательно читаем файл INSTALL.rst и выполняем инструкции (только думая, некоторые пути имеет смысл заменить). Также обратите внимание, в скрипте установки баз MySQL могут быть неправильно прописаны пути для Debian 6. Пароли тоже не стоит ставить дефолтные :)
4. vi /etc/asterisk/res_config_mysql.conf
[general]
dbhost = 127.0.0.1
dbname = mya2billing
dbuser = a2billinguser
dbpass =
dbport = 3306

5. vi /etc/asterisk/extconfig.conf
[settings]
iaxusers => mysql,general,cc_iax_buddies
iaxpeers => mysql,general,cc_iax_buddies
sipusers => mysql,general,cc_sip_buddies
sippeers => mysql,general,cc_sip_buddies

6. Настраиваем провайдеров в /etc/asterisk/sip.conf
[MainProvider](!)
context=NoContext ; DID пока не настраивал
disallow=all
allow=alaw
dtmf=rfc2833
type=peer
canreinvite=no

[Trunk1](MainProvider)
host=XXXXX

[Trunk2](MainProvider)
host=XXXXXX

[Trunk3](MainProvider)
host=XXXXXX


7. Настраиваем A2Billing (По мотивам http://sysadminman.net/documentation.html)
7.1 Настраиваем Провайдера (PROVIDERS)
7.2 Настраиваем Транки
7.3 Создаем Rate Card (RATES)
7.4 Создаем/Импортируем Rates, привязывая его к Rate Card
7.5 Создаем Сall Plan, привязывая его к Rate Card (Делается при повторном выборе Call Plan) (Тут можно вырезать префикс международки)
7.5 Создаем покупателя, приписываем ему Call Plan (CUSTOMERS)
7.6 Создаем VoIP Profile для пользователя, можно автоматом, только необходимо потом проставить CallerID. Оттуда же делаем Asterisk reload
Работает так:
Покупатель аутентифицируется на нашей платформе. Потом просто звонит на необходимый ему номер. Профит!
Несколько параметров, на которые стоит обратить внимание:

global-base_currency (базовая валюта), после ее смены надо в разделе Billing-Currency List сделать update
agi-conf1-asterisk_version 
global-asterisk_version
agi-conf1-answer_call 
agi-conf1-play_audio
agi-conf1-say_rateinitial 
agi-conf1-say_timetocall
agi-conf1-use_dnid Если YES, то система не будет просить ввести номер, на который звонить, будет использовать присланный.