Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Calculation of Trial Days Remaining from Cancellation #320

Open
cemilkrc opened this issue Jun 13, 2024 · 2 comments
Open

Problem with Calculation of Trial Days Remaining from Cancellation #320

cemilkrc opened this issue Jun 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@cemilkrc
Copy link

cemilkrc commented Jun 13, 2024

Expected Behavior

The expected behavior is that users should only have access to the trial period once for a set duration (e.g., 3 days) and should not be able to exploit the trial period by continuously uninstalling and reinstalling the application to reset the trial days.

Current Behavior

Currently, users can exploit the trial period calculation by continuously uninstalling and reinstalling the application within a 24-hour period. This allows them to gain unlimited trial days because the dates are stored only on a day-level basis, ignoring hours and minutes.

Failure Information

This issue arises because the date and time are recorded only at the day level. Users can uninstall and reinstall the application within a 24-hour period to abuse the trial period. This allows them to repeatedly reset the trial period to the full duration (e.g., 3 days).

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

Step 1: Install the application.

activated_on: 2024-06-12 00:00:00
trial_ends_on: 2024-06-15 00:00:00
cancelled_on: 2024-06-12 00:00:00 (same day)

Step 2: Uninstall the application on the same day.

Step 3: Reinstall the application the next day.

activated_on: 2024-06-13 00:00:00
trial_ends_on: 2024-06-16 00:00:00
cancelled_on: NULL

Step 4: Repeat the uninstall and reinstall process to continuously gain a new trial period.

image

Current Function

public function remainingTrialDaysFromCancel(): ?int

This function only calculates the trial days at the day level, ignoring hours and minutes. As a result, in the above scenario, each reinstallation provides the user with a new full 3-day trial period.

Root Cause

The root cause is storing dates only at the day level and not capturing hours and minutes, preventing accurate calculation of the trial period. The following image clearly illustrates this issue:

Proposed Solution

We can provide a more accurate calculation by storing the date and time information with minute-level precision, and adjusting the remainingTrialDaysFromCancel function accordingly. If you give me your thoughts, I would like to contribute to solving the problem.

Context

  • Package Version: 21.0
  • Laravel Version: 10.10
  • PHP Version: 8.3
@cemilkrc cemilkrc added bug Something isn't working unconfirmed Bug has not been reproduced yet labels Jun 13, 2024
@Kyon147
Copy link
Owner

Kyon147 commented Jun 13, 2024

Thanks @cemilkrc

I've seen something issue and did have a quick look into it but you've done a lot more work in investigating so thank you!

Sounds like a good solution if you wanted to open a PR

@Kyon147 Kyon147 removed the unconfirmed Bug has not been reproduced yet label Jun 13, 2024
@cemilkrc
Copy link
Author

@Kyon147 I'm working on the problem, I'll open a PR when I solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants