Re: [SR-Users] CNXCC PrePaid module

2014-11-27 Thread Rene Montilva
Hi Carlos

is there any different issue with kamailio 4.2.1, because i have the same
error, you solved above, i got the same error with float value
/usr/sbin/kamailio[13336]: WARNING:  [rvalue.c:1016]: rval_get_int():
automatic string to int conversion for "0.0005" failed

and with the basic value, it doesn't close the call after 4 seconds

$var(credit) = "4"; # 30$ of credit
$var(cost_per_sec) = "1"; # 1$ per sec

$var(i_pulse) = "1"; # 1$ to establish the call
$var(f_pulse) = "1"; # 1$ per second



On Tue, May 13, 2014 at 3:05 PM, Rene Montilva 
wrote:

> Hi Carlos
>
> i've tested, works perfect, muchas gracias hermano!
>
>
> On Mon, May 12, 2014 at 11:27 PM, Carlos Ruiz Díaz <
> carlos.ruizd...@gmail.com> wrote:
>
>> Get the latest updates, by cloning the repository and
>> recompiling/reinstalling it.
>>
>> $ git clone git://git.sip-router.org/kamailio kamailio
>>
>> Regards,
>> Carlos
>>
>>
>> On Mon, May 12, 2014 at 2:21 PM, Rene Montilva 
>> wrote:
>>
>>> Hi carlos,
>>>
>>> sorry my ignorance, where is it the master link?
>>>
>>> the test with only integers works perfect
>>>
>>>
>>> On Sun, May 11, 2014 at 10:48 PM, Carlos Ruiz Díaz <
>>> carlos.ruizd...@gmail.com> wrote:
>>>
 Yep, assignment failed because the variables contain floating point
 values and Kamailio does not handle well this kind of precision.

 I patched the module to add the check before initiating the call, it is
 in master.

 As a way of testing your code, replace those values with integer ones,
 like 5 and 6, and check if the call is actually terminated or even
 initiated. This will give you a quick diagnosis of your routing script.

 Regards,
 Carlos


 On Sun, May 11, 2014 at 9:04 PM, Rene Montilva 
 wrote:

> Hi Carlos
>
> kamailio version  4.1
> El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
> escribió:
>
>  What Kamailio version are you using?
>>
>>
>> On Sat, May 10, 2014 at 9:33 PM, Rene Montilva <
>> renemonti...@gmail.com> wrote:
>>
>>> Hi Carlos
>>>
>>> kamailio config:
>>>
>>> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>>>
>>>
>>> if($var(cost_per_sec) > $var(credit)) {
>>>
>>> sl_send_reply("402","payment required");
>>> exit;
>>> }
>>>
>>>
>>> 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;
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>> i got this by syslog
>>>
>>> $var(credit) = "0.0005";
>>> $var(cost_per_sec) = "0.0006";
>>>
>>>
>>>
>>> #$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
>>>
>>> if (!cnxcc_set_max_credit("$var(client)",
>>> "$var(credit)",
>>> "$var(cost_per_sec)",
>>> "$var(i_pulse)",
>>> "$var(f_pulse)")) {
>>> sl_send_reply("402", "Sin saldo PAPA");
>>> xlog("Error setting up credit control");
>>> exit;
>>> }
>>>
>>>
>>>
>>> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-13 Thread Rene Montilva
Hi Carlos

i've tested, works perfect, muchas gracias hermano!


On Mon, May 12, 2014 at 11:27 PM, Carlos Ruiz Díaz <
carlos.ruizd...@gmail.com> wrote:

> Get the latest updates, by cloning the repository and
> recompiling/reinstalling it.
>
> $ git clone git://git.sip-router.org/kamailio kamailio
>
> Regards,
> Carlos
>
>
> On Mon, May 12, 2014 at 2:21 PM, Rene Montilva wrote:
>
>> Hi carlos,
>>
>> sorry my ignorance, where is it the master link?
>>
>> the test with only integers works perfect
>>
>>
>> On Sun, May 11, 2014 at 10:48 PM, Carlos Ruiz Díaz <
>> carlos.ruizd...@gmail.com> wrote:
>>
>>> Yep, assignment failed because the variables contain floating point
>>> values and Kamailio does not handle well this kind of precision.
>>>
>>> I patched the module to add the check before initiating the call, it is
>>> in master.
>>>
>>> As a way of testing your code, replace those values with integer ones,
>>> like 5 and 6, and check if the call is actually terminated or even
>>> initiated. This will give you a quick diagnosis of your routing script.
>>>
>>> Regards,
>>> Carlos
>>>
>>>
>>> On Sun, May 11, 2014 at 9:04 PM, Rene Montilva 
>>> wrote:
>>>
 Hi Carlos

 kamailio version  4.1
 El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
 escribió:

  What Kamailio version are you using?
>
>
> On Sat, May 10, 2014 at 9:33 PM, Rene Montilva  > wrote:
>
>> Hi Carlos
>>
>> kamailio config:
>>
>> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>>
>>
>> if($var(cost_per_sec) > $var(credit)) {
>>
>> sl_send_reply("402","payment required");
>> exit;
>> }
>>
>>
>> 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;
>>
>> }
>>
>>
>>
>>
>>
>> i got this by syslog
>>
>> $var(credit) = "0.0005";
>> $var(cost_per_sec) = "0.0006";
>>
>>
>>
>> #$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
>>
>> if (!cnxcc_set_max_credit("$var(client)",
>> "$var(credit)",
>> "$var(cost_per_sec)",
>> "$var(i_pulse)",
>> "$var(f_pulse)")) {
>> sl_send_reply("402", "Sin saldo PAPA");
>> xlog("Error setting up credit control");
>> exit;
>> }
>>
>>
>>
>> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-12 Thread Carlos Ruiz Díaz
Get the latest updates, by cloning the repository and
recompiling/reinstalling it.

$ git clone git://git.sip-router.org/kamailio kamailio

Regards,
Carlos


On Mon, May 12, 2014 at 2:21 PM, Rene Montilva wrote:

> Hi carlos,
>
> sorry my ignorance, where is it the master link?
>
> the test with only integers works perfect
>
>
> On Sun, May 11, 2014 at 10:48 PM, Carlos Ruiz Díaz <
> carlos.ruizd...@gmail.com> wrote:
>
>> Yep, assignment failed because the variables contain floating point
>> values and Kamailio does not handle well this kind of precision.
>>
>> I patched the module to add the check before initiating the call, it is
>> in master.
>>
>> As a way of testing your code, replace those values with integer ones,
>> like 5 and 6, and check if the call is actually terminated or even
>> initiated. This will give you a quick diagnosis of your routing script.
>>
>> Regards,
>> Carlos
>>
>>
>> On Sun, May 11, 2014 at 9:04 PM, Rene Montilva wrote:
>>
>>> Hi Carlos
>>>
>>> kamailio version  4.1
>>> El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
>>> escribió:
>>>
>>>  What Kamailio version are you using?


 On Sat, May 10, 2014 at 9:33 PM, Rene Montilva 
 wrote:

> Hi Carlos
>
> kamailio config:
>
> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>
>
> if($var(cost_per_sec) > $var(credit)) {
>
> sl_send_reply("402","payment required");
> exit;
> }
>
>
> 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;
>
> }
>
>
>
>
>
> i got this by syslog
>
> $var(credit) = "0.0005";
> $var(cost_per_sec) = "0.0006";
>
>
>
> #$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
>
> if (!cnxcc_set_max_credit("$var(client)",
> "$var(credit)",
> "$var(cost_per_sec)",
> "$var(i_pulse)",
> "$var(f_pulse)")) {
> sl_send_reply("402", "Sin saldo PAPA");
> xlog("Error setting up credit control");
> exit;
> }
>
>
>
> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-12 Thread Rene Montilva
Hi carlos,

sorry my ignorance, where is it the master link?

the test with only integers works perfect


On Sun, May 11, 2014 at 10:48 PM, Carlos Ruiz Díaz <
carlos.ruizd...@gmail.com> wrote:

> Yep, assignment failed because the variables contain floating point values
> and Kamailio does not handle well this kind of precision.
>
> I patched the module to add the check before initiating the call, it is in
> master.
>
> As a way of testing your code, replace those values with integer ones,
> like 5 and 6, and check if the call is actually terminated or even
> initiated. This will give you a quick diagnosis of your routing script.
>
> Regards,
> Carlos
>
>
> On Sun, May 11, 2014 at 9:04 PM, Rene Montilva wrote:
>
>> Hi Carlos
>>
>> kamailio version  4.1
>> El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
>> escribió:
>>
>>  What Kamailio version are you using?
>>>
>>>
>>> On Sat, May 10, 2014 at 9:33 PM, Rene Montilva 
>>> wrote:
>>>
 Hi Carlos

 kamailio config:

 log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");


 if($var(cost_per_sec) > $var(credit)) {

 sl_send_reply("402","payment required");
 exit;
 }


 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;

 }





 i got this by syslog

 $var(credit) = "0.0005";
 $var(cost_per_sec) = "0.0006";



 #$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

 if (!cnxcc_set_max_credit("$var(client)",
 "$var(credit)",
 "$var(cost_per_sec)",
 "$var(i_pulse)",
 "$var(f_pulse)")) {
 sl_send_reply("402", "Sin saldo PAPA");
 xlog("Error setting up credit control");
 exit;
 }



 /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-11 Thread Carlos Ruiz Díaz
Yep, assignment failed because the variables contain floating point values
and Kamailio does not handle well this kind of precision.

I patched the module to add the check before initiating the call, it is in
master.

As a way of testing your code, replace those values with integer ones, like
5 and 6, and check if the call is actually terminated or even initiated.
This will give you a quick diagnosis of your routing script.

Regards,
Carlos


On Sun, May 11, 2014 at 9:04 PM, Rene Montilva wrote:

> Hi Carlos
>
> kamailio version  4.1
> El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
> escribió:
>
> What Kamailio version are you using?
>>
>>
>> On Sat, May 10, 2014 at 9:33 PM, Rene Montilva wrote:
>>
>>> Hi Carlos
>>>
>>> kamailio config:
>>>
>>> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>>>
>>>
>>> if($var(cost_per_sec) > $var(credit)) {
>>>
>>> sl_send_reply("402","payment required");
>>> exit;
>>> }
>>>
>>>
>>> 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;
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>> i got this by syslog
>>>
>>> $var(credit) = "0.0005";
>>> $var(cost_per_sec) = "0.0006";
>>>
>>>
>>>
>>> #$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
>>>
>>> if (!cnxcc_set_max_credit("$var(client)",
>>> "$var(credit)",
>>> "$var(cost_per_sec)",
>>> "$var(i_pulse)",
>>> "$var(f_pulse)")) {
>>> sl_send_reply("402", "Sin saldo PAPA");
>>> xlog("Error setting up credit control");
>>> exit;
>>> }
>>>
>>>
>>>
>>> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-11 Thread Rene Montilva
Hi Carlos

kamailio version  4.1
El 11/05/2014 21:32, "Carlos Ruiz Díaz" 
escribió:

> What Kamailio version are you using?
>
>
> On Sat, May 10, 2014 at 9:33 PM, Rene Montilva wrote:
>
>> Hi Carlos
>>
>> kamailio config:
>>
>> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>>
>>
>> if($var(cost_per_sec) > $var(credit)) {
>>
>> sl_send_reply("402","payment required");
>> exit;
>> }
>>
>>
>> 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;
>>
>> }
>>
>>
>>
>>
>>
>> i got this by syslog
>>
>> $var(credit) = "0.0005";
>> $var(cost_per_sec) = "0.0006";
>>
>>
>>
>> #$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
>>
>> if (!cnxcc_set_max_credit("$var(client)",
>> "$var(credit)",
>> "$var(cost_per_sec)",
>> "$var(i_pulse)",
>> "$var(f_pulse)")) {
>> sl_send_reply("402", "Sin saldo PAPA");
>> xlog("Error setting up credit control");
>> exit;
>> }
>>
>>
>>
>> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-11 Thread Carlos Ruiz Díaz
What Kamailio version are you using?


On Sat, May 10, 2014 at 9:33 PM, Rene Montilva wrote:

> Hi Carlos
>
> kamailio config:
>
> log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");
>
>
> if($var(cost_per_sec) > $var(credit)) {
>
> sl_send_reply("402","payment required");
> exit;
> }
>
>
> 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;
>
> }
>
>
>
>
>
> i got this by syslog
>
> $var(credit) = "0.0005";
> $var(cost_per_sec) = "0.0006";
>
>
>
> #$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
>
> if (!cnxcc_set_max_credit("$var(client)",
> "$var(credit)",
> "$var(cost_per_sec)",
> "$var(i_pulse)",
> "$var(f_pulse)")) {
> sl_send_reply("402", "Sin saldo PAPA");
> xlog("Error setting up credit control");
> exit;
> }
>
>
>
> /usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-10 Thread Rene Montilva
Hi Carlos

kamailio config:

log("L_INFO", "saldo:$var(credit) y seg:$var(cost_per_sec) ");


if($var(cost_per_sec) > $var(credit)) {
sl_send_reply("402","payment required");
exit;
}


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;

}





i got this by syslog

$var(credit) = "0.0005";
$var(cost_per_sec) = "0.0006";



#$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

if (!cnxcc_set_max_credit("$var(client)",
"$var(credit)",
"$var(cost_per_sec)",
"$var(i_pulse)",
"$var(f_pulse)")) {
sl_send_reply("402", "Sin saldo PAPA");
xlog("Error setting up credit control");
exit;
}



/usr/sbin/kamailio[13336]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Carlos Ruiz Díaz
On Fri, May 9, 2014 at 3:52 PM, Rene Montilva wrote:

> these are the values before the function call:
>
>  /usr/sbin/kamailio[24933]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Rene Montilva
these are the values before the function call:

 /usr/sbin/kamailio[24933]: INFO: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Carlos Ruiz Díaz
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
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.000667"
> every second from a pool of credit that is equal to "0.000650".
>
> 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 wrote:
>
>> Hi Carlos
>>
>> This my kamailio config:
>>
>> #!ifdef CNXCC_MONEY
>> sql_query("ca", "select * from
>> billing.sel_customer_credit('pepe','xxx","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: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Carlos Ruiz Díaz
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.000667"
every second from a pool of credit that is equal to "0.000650".

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 wrote:

> Hi Carlos
>
> This my kamailio config:
>
> #!ifdef CNXCC_MONEY
> sql_query("ca", "select * from
> billing.sel_customer_credit('pepe','xxx","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: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Rene Montilva
Hi Carlos

This my kamailio config:

#!ifdef CNXCC_MONEY
sql_query("ca", "select * from
billing.sel_customer_credit('pepe','xxx","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: 

Re: [SR-Users] CNXCC PrePaid module

2014-05-09 Thread Carlos Ruiz Díaz
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 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@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@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] CNXCC PrePaid module

2014-05-09 Thread Rene Montilva
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@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users