[solved] PlaySMS not deducting user credit after SMS successfully delievered

Hello all,

Thanks for the good work on PlaySMS.

I successfully deployed and configured PlaySMS. All seems fine except that when I send an SMS user credit doesnt get deducted even when the message is successfully delivered. I also notice d that admin credit doesnt get updated when I add credit to a user.

Below is a sample log from PlaySMS log file. It shows that all went well.

- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 kannel__outgoing # smslog_id:14 response:0: Accepted for delivery
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 dlr # isdlrd:1 smslog_id:14 p_status:0 uid:3
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 kannel__outgoing # end smslog_id:14 p_status:0
- - 2017-08-10 09:57:38 PID598c2e12a372b - L2 simplerate_hook_rate_deduct # enter smslog_id:14
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 simplerate_hook_rate_getbyprefix # found rate id:1 prefix:234817 rate:2.000 description:Nigeria to:2348170311628
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 simplerate_hook_rate_getcharges # uid:3 u:saheedalbert2 len:12 unicode:0 to:2348170311628 enable_credit_unicode:1 count:1 rate:2.000 charge:2
- - 2017-08-10 09:57:38 PID598c2e12a372b - L2 simplebilling_hook_billing_post # saving smslog_id:14 rate:2.000 count:1 charge:2
- - 2017-08-10 09:57:38 PID598c2e12a372b - L2 simplebilling_hook_billing_post # saved smslog_id:14 id:3
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 simplerate_hook_rate_deduct # deduct successful uid:3 parent_uid:0 smslog_id:14
- - 2017-08-10 09:57:38 PID598c2e12a372b - L2 sendsms_process # end
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 sendsms_throttle_count # throttle bucket exists start:2017-08-09 16:25:18 sum:9 limit:2160000
- - 2017-08-10 09:57:38 PID598c2e12a372b - L3 sendsms_throttle_count # expired start:2017-08-10 09:57:38
- - 2017-08-10 09:57:38 PID598c2e12a372b - L2 sendsmsd # result queue_code:8cc9ba983d254fb92f9a24e178324588 to:2348170311628 flag:1 smslog_id:14
- - 2017-08-10 09:57:39 PID598c2e12a372b - L3 sendsms_throttle_isoverlimit # under quota not overlimit sum:0
- - 2017-08-10 09:57:39 PID598c2e12a372b - L2 sendsmsd # finish processing queue_code:8cc9ba983d254fb92f9a24e178324588 uid:3 sender_id:1960SMS queue_count:1 sms_count:1
- - 2017-08-10 09:57:39 PID598b376d85a55 - L3 dlrd # id:14 smslog_id:14 p_status:0 uid:3

Please kindly advise.

Thanks

Hi,

You have to activate the sms rate. It can be made on main configuration option, Default SMS rate and set any value Ex: 10.
it will dedut 10 on your credit per each massege you send

@mateus

I tried that, but account balance not decreased when i send sms -seems i have same issue as OP

thanks for suggestion tho

Hello,
Please, tell what gateway do you use ?
Thanks.

@astra_Jj we are using Kannel.

Please paste playsmsd check here

Anton

no, run: playsmsd check

anton

will do and will revert a bit later today
thank you

the result should be similar to this:

PLAYSMSD_CONF = /etc/playsmsd.conf
PLAYSMS_PATH = /var/www/html/playsms
PLAYSMS_LIB = /var/lib/playsms
PLAYSMS_BIN = /usr/local/bin
PLAYSMS_LOG = /var/log/playsms
DAEMON_SLEEP = 1
ERROR_REPORTING = E_ALL ^ (E_NOTICE | E_WARNING)
IS_RUNNING = 1
PIDS schedule = 28351
PIDS ratesmsd = 28353
PIDS dlrssmsd = 28355
PIDS recvsmsd = 28357
PIDS sendsmsd = 28359

These are daemon scripts that need to be active all time:

PIDS schedule = 28351
PIDS ratesmsd = 28353
PIDS dlrssmsd = 28355
PIDS recvsmsd = 28357
PIDS sendsmsd = 28359

credits and balance are updated by ratesmsd

also run playsmsd version, it should be 1.4.2 the latest

anton

@anton thank you

ver 1.4.1 is what we have

we will upgrade to 1.4.2 thanks

@anton this is now resolved thank you. v1.4.2. fixed the problem.

I have v1.4.2 but still have issue below is error

41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms # start uid:2 sender_id:[M-BET] smsc:[]
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms_queue_create # saving queue_code:15a866055375de17e9c22e23ccecec0d src:M-BET scheduled:2019-07-21 23:46:02
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms_queue_create # saved queue_code:15a866055375de17e9c22e23ccecec0d id:103
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms # dst_count:1 sms_count:1 total_charges:0.15
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms_queue_push # saving queue_code:15a866055375de17e9c22e23ccecec0d dst:260976198318
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms_queue_push # saved queue_code:15a866055375de17e9c22e23ccecec0d smslog_id:2286
41.223.117.77 178.79.154.208 2019-07-21 18:46:02 PID5d3488ba18c2b chris L2 sendsms # end queue_code:15a866055375de17e9c22e23ccecec0d queue_count:1 sms_count:1 failed_queue:0 failed_sms:0

    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsmsd # start processing queue_code:15a866055375de17e9c22e23ccecec0d chunk:0 queue_count:1 sms_count:1 scheduled:2019-07-21 18:46:02 uid:2 gpid:0 sender_id:M-BET
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsmsd # sending queue_code:15a866055375de17e9c22e23ccecec0d smslog_id:2286 to:260976198318 sms_count:1 counter:1
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsms_process # start
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 simplerate_hook_rate_cansend # allowed user uid:2 sms_to:260976198318 adhoc_credit:999.998 count:1 rate:0.150 charge:0.15 adhoc_balance:999.848
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsms # saving smslog_id:2286 u:2 parent_uid:0 g:0 gw:kannel smsc:routesms s:M-BET d:260976198318 type:text unicode:0 status:0
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsms_process # saved smslog_id:2286 id:2286
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 simplerate_hook_rate_deduct # enter smslog_id:2286
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 simplebilling_hook_billing_post # saving smslog_id:2286 rate:0.150 count:1 charge:0.15
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 simplebilling_hook_billing_post # saved smslog_id:2286 id:2286
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsms_process # end
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsmsd # result queue_code:15a866055375de17e9c22e23ccecec0d to:260976198318 flag:1 smslog_id:2286
    • 2019-07-21 18:46:02 PID5d3488bad8691 - L2 sendsmsd # finish processing queue_code:15a866055375de17e9c22e23ccecec0d uid:2 sender_id:M-BET queue_count:1 sms_count:1
      178.79.154.208 178.79.154.208 2019-07-21 18:46:03 PID5d3488bb3995d - L2 kannel__call # start load:/var/www/html/criticalsms/plugin/gateway/kannel/dlr.php
      178.79.154.208 178.79.154.208 2019-07-21 18:46:03 PID5d3488bb3995d - L2 kannel__dlr # unable to process DLR. remote_addr:[178.79.154.208] or remote_host:[178.79.154.208] does not match with your bearerbox_host config:[localhost] smsc:[routesms]
      178.79.154.208 178.79.154.208 2019-07-21 18:46:10 PID5d3488c2997fc - L2 kannel__call # start load:/var/www/html/criticalsms/plugin/gateway/kannel/dlr.php
      178.79.154.208 178.79.154.208 2019-07-21 18:46:10 PID5d3488c2997fc - L2 kannel__dlr # unable to process DLR. remote_addr:[178.79.154.208] or remote_host:[178.79.154.208] does not match with your bearerbox_host config:[localhost] smsc:[routesms]

Hello Anton,

PlaySMS is working great and SMS are sent, but in All sent messages the messages are pending.
This is probably the reason why Credit deduct doesn’t work. All PIDS are running and PlaySMS version is 1.4.2. with SMS server tools 3.

See log below;

    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsms_process # start
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 simplerate_hook_rate_cansend # allowed user uid:2 sms_to:31644764869 adhoc_credit:100 count:1 rate:1.000 charge:1 adhoc_balance:99
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsms # saving smslog_id:714 u:2 parent_uid:0 g:0 gw:smstools smsc:modem1 s:+31683239221 d:31644764869 type:text unicode:0 status:0
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsms_process # saved smslog_id:714 id:702
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 smstools_hook_sendsms # saved outfile:/var/spool/sms/modem1/out.20191016142623.0.2.714 smsc:[modem1]
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 simplerate_hook_rate_deduct # enter smslog_id:714
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 simplebilling_hook_billing_post # saving smslog_id:714 rate:1.000 count:1 charge:1
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 simplebilling_hook_billing_post # saved smslog_id:714 id:140
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsms_process # end
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsmsd # result queue_code:27970aaff3d5adc7226ef91095df5d1d to:31644764869 flag:1 smslog_id:714
    • 2019-10-16 14:26:23 PID5da70c6f04433 - L2 sendsmsd # finish processing queue_code:27970aaff3d5adc7226ef91095df5d1d uid:2 sender_id:+31683239221 queue_count:1 sms_count:1

After sending a SMS the credits do not deduct.
The SMS rate is also set;
Destination: NL
Prefix: 31
Rate: 1.000

What goes wrong, Please help…

Thank you,

Mark

I had the same problem with kannel. The issue was kannel was not forwarding the dlr back to PlaySMS, so the system never new the message was delivered. If PlaySMS doesn’t get updated with delivery information, it doesn’t deduct credit. For the me actual problem was the url at for my PlaySMS . I was using https instead of http . Kannel from the repos doesn’t support https . You must compile it from source with this option. Hope this helps someone

Hi Mymanga,

Thank you for your input.

If have used http and https but not with kannel. I am using SMS Server Tool 3 and an url as set in kannel is not an option. The default url in PaySMS is correct.

I hope someone knows the solution…

Thanks

I have Solved the problem by changing the fn.php file at /plugin/feature/simplebilling.

function simplebilling_hook_billing_post($smslog_id, $rate, $count, $charge) {
$ok = false;
_log(“saving smslog_id:” . $smslog_id . " rate:" . $rate . " count:" . $count . " charge:" . $charge, 2, “simplebilling_hook_billing_post”);
$db_query = “INSERT INTO " . DB_PREF . “_tblBilling (post_datetime,smslog_id,rate,count,charge,status) VALUES (’” . core_get_datetime() . “’,’$smslog_id’,’$rate’,’$count’,’$charge’,‘1’)”;
if ($id = @dba_insert_id($db_query)) {
_log(“saved smslog_id:” . $smslog_id . " id:” . $id, 2, “simplebilling_hook_billing_post”);
$ok = true;
}
return $ok;
}

Change the “status” value from ‘0’ to '1’
Maybe not the best way, but it works…

Unfortunately the “sent messages” are still having status “Pending”, but simplebilling is working fine now…

1 Like