Hi guys,
I have noticed, looking at the code, that your handling of the next charge is not correct.
Example:
My customer buys a product on Jan 12. Next fee is Feb 12. All good.
Feb 12 arrives, you attempt a charge. It fails. The try again is in 1 day. Thus, it tries again on Feb 13. This gives me a little time to review the order that failed (just in case I can see something like CC out of date...)
Feb 13, it works. Great!
Now, you change $next_charge to now + "1 months". The next charge will be Mar 13. I would expect the next charge to be Mar 12.
The reason is this:
$fee->next_charge = strtotime('+'. $fee->regular_interval);
The strtotime() uses time() since you do not specify a date anywhere.
Instead, we would need a start date (which I know is not exactly straight forward to compute... since we need to take the start date in account which can vary depending on the 1st charge definition... and even possibly a few more days in case the user credit card did not work for the first few days...)
So, anyway, I would suggest a computation with something like this:
$fee->next_charge = strtotime('+'. $fee->regular_interval, 0) * $fee->recur_count + $fee->start_date;
Now we eliminate the possibility of a date that changes from month to month. It will however have to increase recur_count or whatnot the variable would be called and the start date would be the date when the very first charge occurred.
If you agree, I'll be glad to offer a patch. There are a few changes required for this to work right.
Thank you.
Alexis
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | uc_recurring-728716.patch | 1.29 KB | univate |
Comments
Comment #2
univate commentedNo that solution would limit the flexibility of this module. How would this handle giving one members a free week when their intervals are normally a month.
I think the solution here is to add an extended field, which keeps track of the time extended. Then when renewed it would add the regular interval minus what ever the extended field contains, reseting the extended field for next renewal.
Comment #3
AlexisWilke commentedunivate,
Then we could add yet another field like this:
The freebie is the extra week... so if you want to add more time, you let the admin edit that field in some fashion.
Another way is to move the start date by 1 week. Then we avoid having another field, but that's also "misspelling" the name of the start date field.
Now, how often a slip occurs, probably quite rare. I was actually thinking about that because I'd like my customers to all be charged on the 1st of the month (I have seen another such request.) There are accounting reasons for doing this. Having a prorate is one way, the other is giving 1 free day per month until the day of the charge is 1.
So I looked at the code for that reason. 8-)
I still think that it is really bad that it can slip so easily without the admin intervention.
Thank you.
Alexis
Comment #4
univate commentedI can't really see how adding three fields - 'start_date', 'recur_count' & 'freebie' is a better solution to just adding the one field for 'extended' and using that to keeping track of how long a subscription has been extended (for whatever reason, e.g. freebie, failed payment) so the next renewal dates can be accurately calculated to include any extensions that occur.
Recurring fees and Order objects already contain a created field so that could be used to determine the start date if you want to find that out.
If you want to make the first payment prorata to get the recurring payments happening on the same day each month you could use the available hooks, like the following:
You will also need to alter the order to change the amount on the product to be a prorata amount.
Comment #5
univate commentedHere is a quick simple fix to this issue.
Comment #6
univate commentedCommitted my patch above.
Comment #7
AlexisWilke commentedHi Univate,
Thank you for the fix! 8-)
Alexis