Oops, correction:
*if ($var(credit) < $var(cost_per_second)) {*
* sl_send_reply("402", "payment required");*
* exit;*
*}*
By the way, please inform of your results after doing your tests.
Thanks,
Carlos
On Fri, May 9, 2014 at 3:17 PM, Carlos Ruiz Díaz <
carlos.ruizdiaz(a)gmail.com> wrote:
Hello,
"i_pulse" and "f_pulse" are direct translations of the Spanish (I
noticed you speak it) phrases "pulso inicial" and "pulso final",
which I
don't think have the same meaning in English. Updating the docs and using
the proper terminology are pending matters on this module.
Both values represent the initial and interim costs of the call, in your
case, it is being billed second by second (1:1), subtracting
"0.000666666666666667"
every second from a pool of credit that is equal to "0.0006500000".
The message that's being shown, looks like a precision loss error, which
is unlikely because I used numbers even smaller than yours. Please print
the values of $var(credit) and $var(cost_per_sec) before calling the
cnxcc function.
Furthermore, you should also consider checking your values before
passing them to the function. For example:
*1. check if the credit is greater than the cost per second, *before*.*
*if ($var(credit) > $var(cost_per_second)) {*
* sl_send_reply("402", "payment required");*
* exit;*
*}*
There's no reason to call the function when the conditions are not met.
Cnxcc will authorize the call and hang it immediately (1 second later).
I may need to add this check myself inside the module.
*2. make sure you are rejecting the call in case of module's error. *
*if (!cnxcc_set_max_credit("$var(client)", "$var(credit)",
"$var(cost_per_sec)", "$var(i_pulse)",*
* "$var(f_pulse)") { *
* sl_send_reply("503", "something's wrong in the server");
*
* exit; *
*}*
Regards,
Carlos
On Fri, May 9, 2014 at 2:45 PM, Rene Montilva <renemontilva(a)gmail.com>wrote;wrote:
Hi Carlos
This my kamailio config:
#!ifdef CNXCC_MONEY
sql_query("ca", "select * from
billing.sel_customer_credit('pepe','xxxxxxx","ra");
xlog("L_INFO", "Setting up money based credit control");
if($dbr(ra=>rows)> 0){
xlog("L_INFO", "saldo:$dbr(ra=>[0,0]) y seg:$dbr(ra=>[0,1])
");
$var(credit) = $dbr(ra=>[0,0]); # 30$ of credit
$var(cost_per_sec) = $dbr(ra=>[0,1]); # 1$ per sec
$var(i_pulse) = "1"; # 1$ to establish the call
$var(f_pulse) = "1"; # 1$ per second
}
sql_result_free ("ra");
# if only one call is established, that call should last 9 seconds.
if (!cnxcc_set_max_credit("$var(client)",
"$var(credit)",
"$var(cost_per_sec)",
"$var(i_pulse)",
And this are the values by syslog info
INFO: <script>: saldo:0.0006500000 y seg:0.000666666666666667
ERROR: cnxcc [cnxcc_mod.c:1425]: set_max_credit(): credit value must be
> 0: 0.000000
On Fri, May 9, 2014 at 3:08 PM, Carlos Ruiz Díaz <
carlos.ruizdiaz(a)gmail.com> wrote:
> Hi,
>
> Can you paste the code you are using, with the values that each
> variable contain at the moment of initiating the call?
>
> Regards,
>
>
> On Fri, May 9, 2014 at 2:35 PM, Rene Montilva <renemontilva(a)gmail.com>wrote;wrote:
>
>> Hi list
>>
>> I don't understand prepaid logic calculation, because when my credit
>> is 0 or lees than cost per second, the call is established equal
>>
>> $var(i_pulse) and $var(f_pulse) how this works????
>>
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
>> list
>> sr-users(a)lists.sip-router.org
>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>
>
> --
> Carlos
>
http://caruizdiaz.com
>
http://ngvoice.com
> +52 55 3048 3303
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users(a)lists.sip-router.org
>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Carlos
http://caruizdiaz.com
http://ngvoice.com
+52 55 3048 3303
+52 55 3048 3303
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org