laravel-cashier-mollie icon indicating copy to clipboard operation
laravel-cashier-mollie copied to clipboard

Wrong date for next subscription cycle.

Open tobischulz opened this issue 2 years ago • 5 comments

We have switched from cashier_plans.php to our own database plan table. Since then the cycle date calculation is very strange.

Before we had monthly (1 month) cycles that looked like this in the subscription and order_items table:

2022-01-11 08:00:00 -> 2022-02-11 08:00:00
2022-02-11 08:00:00 -> 2022-03-11 08:00:00
2022-03-11 08:00:00 -> 2022-04-11 08:00:00

Right now we have something like this:

2022-08-11 08:00:00 -> 2022-09-21 08:00:00

or

2022-08-11 08:00:00 -> 2022-09-06 08:00:00

This is our Plan-Model with the interval attribute method.

CleanShot 2022-08-11 at 12 49 24

CleanShot 2022-08-11 at 12 48 59

PHP: 8.1 Cashier-Mollie: v2.4.3

I think this should be very good handled by the DefaultIntervalGenerator class. I don´t get it why this is happening.

CleanShot 2022-08-11 at 12 57 49

Did we something wrong? Thanks again!

tobischulz avatar Aug 11 '22 10:08 tobischulz

Is it possible that it is the trial_ends_at timestamp? As far as i can see uses the startOfTheSubscription the end date of trial to calculate the next possible cycle end date.

CleanShot 2022-08-11 at 13 04 35

CleanShot 2022-08-11 at 13 04 26

For this specific real customer the trial has ended 2020-12-06, what looks logical for the next cycle_ends_at 2022-09-06. Does this column should be null after trial expired?

CleanShot 2022-08-11 at 13 04 00

tobischulz avatar Aug 11 '22 11:08 tobischulz

Hi @tobischulz ,

Thanks for the extensive report. @ciungulete can you figure out what happened here?

sandervanhooft avatar Aug 11 '22 11:08 sandervanhooft

Hello, any updates on this?

tobischulz avatar Aug 23 '22 06:08 tobischulz

@ciungulete can you reproduce this issue?

sandervanhooft avatar Sep 01 '22 10:09 sandervanhooft

As far as i can see it is the trial_ends_at or the created_at timestamps that will be used on every new cycle. But it ignores the cycle_started_at and cycle_ends_at timestamps which are important cause on a 14 day trial there are not the same day.

We have 14 day trials and monthly subscriptions. On any point, or update of the package the new cycle_ends_at is a totally different day which leads to a monthly payed subscription for a cycle that is less days as the month should have.

After manually changing the trials_ends_at timestamp to the same day as the cycle has, see above screenshot 2020-12-06 changed into 2020-12-11, the new cycle is correct and everything works as expected.

Should be easy to reproduce, just take an active subscription, change the day of the trial_ends_at and start the next cycle. cycle_ends_at should now have the day same as trial_ends_at but not as the plan interval "1 month".

tobischulz avatar Sep 01 '22 13:09 tobischulz

At the moment im not able to reproduce this anymore. It just happens on production as there was a bug that has switched every subscription to yearly that has to be monthly. Maybe its just that bug that leads to this behaviour. So i will close this issue. I will come back to this if this ever happens again. Thanks for your time @sandervanhooft @ciungulete

tobischulz avatar Oct 07 '22 11:10 tobischulz