gocodebox / gocodebox/lifterlms
Switching timezones can cause incorrect double charges
- Dominant language
- PHP
- Stars
- 212
- Forks
- 140
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 19
Description
### Reproduction Steps
There are likely other scenarios that can cause the same problem, and trial is likely not needed, but it's one scenario to test.
1. With the site timezone in UTC, purchase a monthly recurring access plan with a 1 day trial.
2. Switch the site to UTC-6 timezone
3. Wait a couple days for the renewal to happen
### Expected Behavior
One recurring charge happens for the monthly access plan, and the next payment date is at the same time (timezone adjusted)
### Actual Behavior
Two recurring charges happen on the same day, and the next payment date is 6 hours ahead. The first charge happens as the original time due to the task already being scheduled.
### Tech Notes
The next payment date is stored in the current local timezone. It's then interpreted as the new timezone when read on renewal.

Next payment date is set to the same time, but in the new time zone, since it appears to be in the future. The first (original) payment happened at the time in the old timezone. There's a check that the next payment isn't within 2 hours in case of daylight savings time, but that doesn't account for a totally different timezone that's more than that 2 hour difference.

Next recurring payment scheduled task in the new time zone.
Contributor guide
Assessment
This issue has not been assessed yet.