How to make calls with minutes and seconds allowed by balance

Hi

I’m trying ASTPP 5 to allow calls via calling card system.
I want to allow customers to use all the card balance, example, 1dollar per minute and a 5dollars card allows 5 minutes, a customer talks 3minutes and 15 seconds, but for the next call the system only allows 1 minute instead 1 minute and 45seconds

I have configured all the tariffs to bill every second as tariff cycle.

Call Flow.
Customer calls to the inbound DID
After the welcome message and the card id and pin be inserted, the message only says full minutes.
The tariff configuration

Rate Group → Increment 1 → Initial Increment 1
Origination Rate → Connection Cost 0 → Grace Time 0 → Cost Min 1$ → Initial Increment 1 → Increment 1
Termination Rate → Connection Cost 0 → Grace Time 0 → Cost Min 1$ → Initial Increment 1 → Increment 1

How can i configure the ASTPP software to allow calls and tariff by seconds instead full minutes???

Hello @pyazfrnymqffqscbwq ,
In ASTPP per second billing is possible as the logic of cost per minutes is defined as seconds.

Hi @palak

I though the same at first documentation read, but actually, i have configured all the tariff to be second by second but the freeswitch cli log show that’s not enough balance to make a call with minutes and seconds.

Attached some screenshots about the basic (really basic) configuration of my astpp to test the calling card functionality

Calling Card Access Number

Two fresh customers, with 3$

Origination Rates
Without connection costs, and increment by 1 second (second by second)

Termination Rates
Without connection costs, and increment by 1 second (second by second)

First test call
With the tariff, balance and the 3 minutes available

via fs_cli

2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] call_direction:::::: 
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] =============== Rates Information ===================
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] ID : 77
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Connectcost : 0.00000
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Includedseconds : 0
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Cost : 1.00000
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] comment : 
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Country Id : 174
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Accid : 31
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Trunk ID: 0
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] Routing type: 
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] ================================================================
2022-07-04 11:20:41.292991 97.73% [INFO] switch_cpp.cpp:1465 [ASTPP] [FIND_MAXLENGTH] Your3 balance Accountid 31 !!!
EXECUTE [depth=0] sofia/default/555666888@xxxxxxxxxxx:5060 limit(db 22255 db_22255 1)
2022-07-04 11:20:41.292991 97.73% [DEBUG] switch_limit.c:124 incr called: 22255_db_22255 max:1, interval:0
2022-07-04 11:20:41.292991 97.73% [DEBUG] mod_db.c:194 Usage for 22255_db_22255 is now 1/1
2022-07-04 11:20:41.292991 97.73% [NOTICE] switch_cpp.cpp:1465 [ASTPP] 3 Minutes
2022-07-04 11:20:41.292991 97.73% [DEBUG] switch_cpp.cpp:1465 [ASTPP] [SAY_TIMELIMIT] MINUTES 3
2022-07-04 11:20:41.292991 97.73% [DEBUG] switch_core_file.c:444 File /usr/share/freeswitch/sounds/en/us/callie/astpp-this-call-will-last.wav sample rate 16000 doesn't match requested rate 8000
2022-07-04 11:20:41.292991 97.73% [DEBUG] switch_ivr_play_say.c:1556 Codec Activated L16@8000hz 1 channels 20ms
2022-07-04 11:20:42.492930 97.53% [DEBUG] switch_ivr_play_say.c:2001 done playing file /usr/share/freeswitch/sounds/en/us/callie/astpp-this-call-will-last.wav
EXECUTE [depth=0] sofia/default/555666888@xxxxxxxxxxx:5060 say(en number pronounced 3)
2022-07-04 11:20:42.492930 97.53% [DEBUG] switch_ivr_play_say.c:1556 Codec Activated L16@8000hz 1 channels 20ms
2022-07-04 11:20:43.152950 97.47% [DEBUG] switch_ivr_play_say.c:2001 done playing file file_string://digits/3.wav
2022-07-04 11:20:43.152950 97.47% [DEBUG] switch_core_file.c:444 File /usr/share/freeswitch/sounds/en/us/callie/astpp-minutes.wav sample rate 16000 doesn't match requested rate 8000
2022-07-04 11:20:43.152950 97.47% [DEBUG] switch_ivr_play_say.c:1556 Codec Activated L16@8000hz 1 channels 20ms

Here goes the CDR of this customer (calling card)
I use one of the created cards with it’s pin, a call duration of 2minutes and 10seconds

With the second by second tariff and working method, for the next call i neet to have 50seconds to place a new call

After a new call, the call_flow script says to me that’s not enough balance (less than a minute)

2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] call_direction:::::: 
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] =============== Rates Information ===================
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] ID : 77
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Connectcost : 0.00000
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Includedseconds : 0
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Cost : 1.00000
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] comment : 
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Country Id : 174
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Accid : 31
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Trunk ID: 0
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] Routing type: 
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] ================================================================
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] [FIND_MAXLENGTH] Your0.8333 balance Accountid 31 !!!
2022-07-04 11:27:06.292935 95.70% [INFO] switch_cpp.cpp:1465 [ASTPP] [FIND_MAXLENGTH] Your balance is not sufficent to dial 9 !!!
2022-07-04 11:27:06.292935 95.70% [DEBUG] switch_cpp.cpp:1465 [ASTPP] post_cdrs:::0
EXECUTE [depth=0] sofia/default/555666888@xxxxxxxxxxx:5060 set(process_cdr=false)
2022-07-04 11:27:06.292935 95.70% [DEBUG] mod_dptools.c:1685 SET sofia/default/555666888@xxxxxxxxxxx:5060 [process_cdr]=[false]
2022-07-04 11:27:06.292935 95.70% [DEBUG] switch_core_file.c:444 File /usr/share/freeswitch/sounds/en/us/callie/astpp-not-enough-credit.wav sample rate 16000 doesn't match requested rate 8000
2022-07-04 11:27:06.292935 95.70% [DEBUG] switch_ivr_play_say.c:1556 Codec Activated L16@8000hz 1 channels 20ms
2022-07-04 11:27:07.972897 95.90% [DEBUG] switch_ivr_play_say.c:2001 done playing file /usr/share/freeswitch/sounds/en/us/callie/astpp-not-enough-credit.wav

With another test, first call with a minute and a half
For the second call, only place me a minute not the 1:27seconds disposable by balance

2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] call_direction:::::: 
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] =============== Rates Information ===================
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] ID : 77
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Connectcost : 0.00000
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Includedseconds : 0
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Cost : 1.00000
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] comment : 
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Country Id : 174
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Accid : 30
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Trunk ID: 0
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] Routing type: 
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] ================================================================
2022-07-04 11:33:54.632875 44.40% [INFO] switch_cpp.cpp:1465 [ASTPP] [FIND_MAXLENGTH] Your1.45 balance Accountid 30 !!!
EXECUTE [depth=0] sofia/default/555666888@xxxxxxxxxxx:5060 limit(db 22169 db_22169 1)
2022-07-04 11:33:54.632875 44.40% [DEBUG] switch_limit.c:124 incr called: 22169_db_22169 max:1, interval:0
2022-07-04 11:33:54.652886 44.40% [DEBUG] mod_db.c:194 Usage for 22169_db_22169 is now 1/1
2022-07-04 11:33:54.652886 44.40% [NOTICE] switch_cpp.cpp:1465 [ASTPP] 1 Minutes
2022-07-04 11:33:54.652886 44.40% [DEBUG] switch_cpp.cpp:1465 [ASTPP] [SAY_TIMELIMIT] MINUTES 1


And ASTPP hangup the call after one minute
The customer still have balance

May i think that’s all this is a configuration error from my side, but in the code, i can’t find the way to calculate the calling duration by seconds, only by full minutes without comma

Hello @pyazfrnymqffqscbwq ,
After the last call how much balance was there in customer’s account? Is it 0.5000 ?

Hi @palak
That’s correct

This calling card starts with 3$, the tariff is 1$ per minute
After 2 calls with a total of 2minutes and 30seconds
The rest balance is 0.5$, this is sufficient to place a 30seconds call, but the astpp lua says the message of not enough balance

@pyazfrnymqffqscbwq as the origination rate’s cost/min is 1.000 so the account needs 1$ in account in order to make any call related to that code. Please check origination rate’s charges.
image

Hi @palak

but if the cost per minute, i understand that’s it for the allowed minutes to call

at the same message, i make a call with 1$ and 45cents to make a call, and the system only allows 1 minute for the call instead 1 minute and 20 seconds
That’s means than the origin calls are billed by minutes and the termination calls by seconds???

if i change the origination rate to 0$ per minute, the calling cards are going to work and bill every second???

@pyazfrnymqffqscbwq If Origination rate is 1.000$ then it will ask in account for another 1.000 $ to complete the call of 45 seconds.
Customer has 2$ balance, call connects, from calling card 1 minute deducted then 45 seconds remains, then again it will ask for 1.000 as call per minute but will deduct charges from 1.000$ as per 45 seconds only.

Hi @palak

with this explanation, my theory for this opened message it’s correct

i need the full minute cost to allow a call, and it’s imposible to allow calls with minutes and seconds, ONLY with full minutes

based on your explananation

with a calling card with 3$, and 1$ per minute, the total of possible call is 3 full minutes
a customer makes a call with the 3$, the system says that the call can make a 3 minutes of duration
the customer hangs up after 45seconds
The calling card still have 2$ and 25cents as balance

a new call from the same customer with the same card, with 2$ and 25cents, the system ONLY allow 2 minutes

where goes the rest of 25seconds???

That’s really means that the calling card only allows the initial call with FULL minutes???

if it’s really possible to allow to initiate a call with minutes and seconds, how i need to configure the origination rates and termination rates???
i tested with 0$ for the origination, and the call it’s converted to free one

edit: if the termination rate is higher than the origination one, the system never allows the call

2022-07-05 09:46:50.692989 97.57% [NOTICE] switch_cpp.cpp:1465 [ASTPP] 3CX: 1.00000 > 0.00000, skipping

Hi @palak

at my last message, is this correct???
the ASTPP can bill by seconds but only allows to the customers to do calls with full minutes???

@pyazfrnymqffqscbwq , with 0 it will take free calls only and if termination rates are higher then the origination rates then call will never connected due to the logic that origination rates are always bigger then the termination rates.

ok @palak
i understood the freecalls functionality

but backing up to the origin of this thread, any way to allow to originate calls with minutes ands seconds and not only full minutes???

ASTPP can do this??? or i need another calling card software