Page 1 of 1

pro-rate subscription to the end of the month

Posted: Wed Apr 14, 2010 10:29 am
by mezojeff
Is there a way to do this through the interface, or would this be custom code? I'm trying to wrap my head around how to do this.

Re: pro-rate subscription to the end of the month

Posted: Wed Apr 14, 2010 11:03 am
by mezojeff
I should probably provide a little more detail.

I've figured out how to calculate it in the payment provider class I've created in the DoAuthorizeRecurring method.

double proratedAmount(string Amount)
{
double pricing = Convert.ToDouble(Amount);
DateTime nextDate = Convert.ToDateTime(DateTime.Now.AddMonths(1).Month.ToString() + "/1/" + DateTime.Now.AddMonths(1).Year.ToString() + " 00:00:00");
DateTime currentDate = DateTime.Now;
TimeSpan ts = nextDate - currentDate;
int daysbetween = ts.Days;
int daysinmonth = System.DateTime.DaysInMonth(currentDate.Year, currentDate.Month);
double priceperday = pricing / daysinmonth;
double proratedprice = priceperday * daysbetween;
return proratedprice;
}

I would like able commerce to be able to say as much in the interface. Right now the customer thinks they have been charged the full 9.99 when they've actually only been charged 5.33, the 9.99 will start when the first of the month billing comes around. How can I adjust email confirmations and order summaries to reflect?

Thanks,
Jeff

Re: pro-rate subscription to the end of the month

Posted: Wed Apr 14, 2010 4:38 pm
by jmestep
You could set your product to use a variable price and calculate that price every day using code. Only don't use the input box where the customer can enter a price.