Twilio total call duration does not match with billing minutes

喜欢而已 提交于 2019-12-11 09:10:27

问题


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);
    }


回答1:


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() ));



回答2:


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.



来源:https://stackoverflow.com/questions/27022950/twilio-total-call-duration-does-not-match-with-billing-minutes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!