Forums/Community/Feature Requests

PlannedDoneNot planned

Migration Proration Preview

James Paden
suggested this on June 24, 2011 10:37 pm

I would like to be able to show my subscribers a preview of the prorated charge/credit before they confirm the migration.  Something along the lines of "You will be billed a prorated $12.45 today and the full $19.99 monthly fee will begin on July 1st."  That data is returned after the migration, any way I can get a "preview"?

 

Comments

User photo
Spencer Caldwell

I agree with James. This would be key in up sale conversions. I know that the proration  is calculated by the second and would always be inaccurate, but even an approximate cost would be good.

March 12, 2012 10:27 pm
User photo
Tim Shnaider

I will presume you are using the API for product migration.  Below is .NET code that always seems to be accurate, we display exactly what James suggested when people Upgrade (Downgrades take affect at next billing cycle). Additional code calculates relevant taxes and coupon discounts, but it means I have to track a lot of stuff my side to make it accurate.

An API method to get this value would be much preferred. 

 

        public decimal GetRemainingValueOfSubscription(string externalSubscriptionID, ISubscription chargifySubscription)
        {
            try
            {
                if (chargifySubscription == null)
                    chargifySubscription = _Chargify.LoadSubscription(Int32.Parse(externalSubscriptionID));
            }
            catch (ChargifyException ex)
            {
                ThrowSubscriptionProcessingExceptionFromChargifyException(ex);
            }
 
            DateTime convertedCurrentTime = DateTime.UtcNow;
 
            TimeSpan subscriptionTimeLeft = chargifySubscription.CurrentPeriodEndsAt.ToUniversalTime().Subtract(convertedCurrentTime);
            TimeSpan totalSubscriptionTime = chargifySubscription.CurrentPeriodEndsAt.ToUniversalTime().Subtract(chargifySubscription.CurrentPeriodStartedAt.ToUniversalTime());
 
            decimal costPerMinute = chargifySubscription.Product.Price / Convert.ToDecimal(totalSubscriptionTime.TotalMinutes);
            decimal subscriptionValue = Convert.ToDecimal(subscriptionTimeLeft.TotalMinutes) * costPerMinute;
 
            // Adjust the value if there was a slight error in the calculation due to time differences
            // and apply the minimum charge
            decimal minimumCharge = new Decimal(0.01);
            if (subscriptionValue > Convert.ToDecimal(chargifySubscription.Product.Price) - minimumCharge)
            {
                subscriptionValue = Convert.ToDecimal(chargifySubscription.Product.Price) - minimumCharge;
            }
 
            return subscriptionValue;
        }
April 10, 2012 09:55 pm
User photo
Tim Shnaider

So I'm reading through Docs and notice there is now migration preview support in the API.

I have no idea when this was added but I think it was very very recently and there is no mention of it in release notes.

Cmon Chargify, please monitor these forums and respond when relevant updates are done.

May 09, 2012 07:59 pm
User photo
Tim Shnaider
May 09, 2012 08:00 pm