简体   繁体   中英

Twilio total call duration does not match with billing minutes

In the attached image , the total voice minutes for July is 30 minutes. However if I pull the call logs for the same month July 2014 (using the instruction in https://www.twilio.com/docs/api/rest/call ) , I get total duration as 17 minutes. Shouldn't the value of usage and total call duration in Log be equal ?.

Here is my test source code for finding the call log files for month July 2014. Any help is greatly appreciated.

       public static void  callLogs(string AccountSid, string AuthToken)
       {

        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new CallListRequest();
        request.StartTimeComparison = ComparisonType.GreaterThanOrEqualTo;
        request.StartTime = new DateTime(2014, 07, 01);         
        request.EndTimeComparison = ComparisonType.LessThanOrEqualTo;
        request.EndTime = new DateTime(2014, 07, 31);
        var calls = twilio.ListCalls(request);

        int? voiceMinutes = 0;
        decimal? totalCost = 0;
        foreach (var call in calls.Calls)
        {

            if ( call.Price != null)
            {
                voiceMinutes += call.Duration;
                totalCost += call.Price ;
            }

            Console.WriteLine(call.Price  +"-" + call.DateCreated + "-" + call.From + "-" + call.To + "-" + call.Status + "-" + call.Duration  );
        }

        Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes/60).ToString() ));
        Console.WriteLine("Total Cost :" +  totalCost);
    }

在此处输入图片说明

For billing minutes, Twilio will round all calls up to the nearest minute . So you should do the same. Something like this:

voiceMinutes += (call.Duration + 60)/ 60;

And then:

Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes).ToString() ));

I used to work at West Corporation. One of my duties was to manage the billing data for our clients. At West, the contracts were setup so that instead of exact to the second or minute, the billing was done in blocks.

So, for phone calls, for example, you would get charged for a minimum of 15 seconds and then 10 seconds after that.

Twilio might be using a similar billing model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM