wpsharks / s2member

s2Member® Framework (membership management for WordPress®).
64 stars 36 forks source link

Automatic EOT Time does not get populated after IPN is received and then does Not demote member? #1140

Open tcf123 opened 6 years ago

tcf123 commented 6 years ago

EXPLANATION OF THE ISSUE

I'm having a lot of issues trying to get members which have cancelled their subscription to be automatically demoted.

WordPress Version: 4.9.4 s2Member Version: 170722 + s2Member Pro v170722

STEPS TO REPRODUCE THE ISSUE

I created a level 1 subscription with 1 day try free and then afterwards $1.20 per month. About 1 hour after creating the subscription I cancel the subscription through Paypal.

BEHAVIOR THAT I EXPECTED

I was expecting the member to be demoted back to level 0 free subscriber but it continues to stay on level 1.

BEHAVIOR THAT I OBSERVED

My latest test I see the following:

[s2Eot /] echos out "Next Payment: Mar 19th, 2018, 10:00 am UTC"

where if I do the following:

$eot = s2member_eot();
echo var_dump($eot);

which echoes out: array(4) { ["type"]=> string(5) "fixed" ["time"]=> int(1521386410) ["tense"]=> string(6) "future" ["debug"]=> string(146) "This is the estimated EOT time. The PayPal Pro API says this subscription is no longer active, and thus, access should be terminated at this time." }

echo gmdate("M jS, Y, g:i a T", $eot['time']);

echos out "Mar 18th, 2018, 3:20 pm GMT" which is a different time from using [s2Eot /].

Also I have noticed that no EOT is set against the field "Automatic EOT Time" on the users record.

The other confusion is that the EOT Grace Time (in seconds) is set to "0" so even s2member_eot() is not right as the EOT should have been now and not 24 hours later which is the default.

I will update again when it goes past Mar 18th, 2018, 3:20pm as based upon my previous tests the member will not be demoted back to being a free subscriber.

It has now gone past 3:20pm and I have run the following PHP:

$eot = s2member_eot();
echo var_dump($eot);

which echoes out: array(4) { ["type"]=> string(5) "fixed" ["time"]=> int(1521386410) ["tense"]=> string(4) "past" ["debug"]=> string(146) "This is the estimated EOT time. The PayPal Pro API says this subscription is no longer active, and thus, access should be terminated at this time." }

I can see the time is the same but the field tense has now changed to past so s2Member knows its gone past the EOT. But as predicted the user has not been demoted and is still on Level 1.

[s2Eot /] echos out now "Access Expires: Mar 18th, 2018, 3:20 pm UTC"

Do you have any idea what is going on?

tcf123 commented 6 years ago

This is where I am at the moment with this issue:

  1. Free trial subscription is created and member is set on level 1.
  2. Subscription is cancelled by member.
  3. Paypal sends out IPN Cancellation.
  4. s2Member receives IPN Cancellation.
  5. s2Member creates Transient records for EOT.
  6. s2Member FAILS to update Automatic EOT Time field with EOT time on users record?
  7. WP Cron fires but because the field Automatic EOT Time is blank the member does NOT get demoted.

I need to know why point 6 above is not happening as I think it is this that is causing all the issues with EOT?

tcf123 commented 6 years ago

Update on issue:

After many hours of looking at this issue I have now fixed the issue! :slight_smile:

All it was... was a plugin conflict with another plugin called iTheme Security. This was all working great some months ago but I guess it must have been one of the recent updates that we applied to iTheme Security which broke s2Members EOT.

I did find this on the issue: https://github.com/websharks/s2member-kb/issues/328 but even disabling those features did not make it work. I even tried disabling all of the features within iTheme Security and that still broke s2Member EOT.

Having looked around I decided to go with Loginizer as it had a particular feature that I required that not all of them have, and I can confirm that this replacement does not have any conflicts with s2Member as I can tell at the moment.