[SR-Users] Cost deduction in kamailio

Logeshwaran G logeshwarangs at gmail.com
Wed Aug 30 07:16:23 CEST 2017


Hi,

Is this the correct way of using the CNXCC for cost deduction, Guide me
please.

route[CNXCC]
{
        $var(customer) = $fU;
        $var(cps)   = "1.00";      # cost per second
        $var(initial_p)   = "1";   # intial pulse
        $var(final_p)   = "1";    #Final_pulse
        $var(minbal) = 1;
        $var(ret) = avp_db_query("SELECT credits FROM subscriber where
username='$fU'", "$avp(s:credits)");
        xlog("L_WARN", "CNXCC: var(ret)=$var(ret)
avp(s:credits)=$avp(s:credits)\n");
        cnxcc_set_max_credit("$var(customer)", "$avp(s:credits)",
"$var(cps)", "$var(initial_p)", "$var(final_p)");
        if ($avp(s:credits)<  $var(minbal)){
                xlog("L_ALERT", "ALERT: Credit balance is low, sent
403:Forbidden. required=$var(minbal)\n");
                sl_send_reply("403", "Forbidden: Low balance");
                drop;

        }
}




Thanks & Kind Regards,
Logeshwaran G

On Fri, Aug 25, 2017 at 11:14 AM, Logeshwaran G <logeshwarangs at gmail.com>
wrote:

> Thanks For your Input Federico, Will try it .
>
> Thanks & Kind Regards,
> Logeshwaran G
>
> On Wed, Aug 23, 2017 at 5:45 PM, Federico Cabiddu <
> federico.cabiddu at gmail.com> wrote:
>
>> Hi,
>> cnxcc doesn't provide this feature. Is not aware of any backend, it just
>> controls subscriber's balance, money or time, as instructed.
>> You can calculate the amount to be deducted after the call ends (if
>> you're doing money based accounting) using dlg variables to store the
>> needed information (start_time, end_time, cost per second) and then
>> updating the balance via sqlops module's functions.
>>
>> Cheers,
>>
>> Federico
>>
>> On Wed, Aug 23, 2017 at 7:50 AM, Logeshwaran G <logeshwarangs at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> How to deduct the call cost or credits for the subscribers with the
>>> cnxcc module?
>>>
>>> Input Please
>>>
>>>
>>> Thanks & Kind Regards,
>>> Logeshwaran G
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>>
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20170830/23305288/attachment.html>


More information about the sr-users mailing list