strangerstudios / pmpro-cancel-on-next-payment-date

Change membership cancellation in Paid Memberships Pro to set expiration for next payment date instead of cancelling immediately.
https://www.paidmembershipspro.com/add-ons/cancel-on-next-payment-date
8 stars 8 forks source link

Compatibility with IPN Forwarders #35

Closed mircobabini closed 2 years ago

mircobabini commented 2 years ago

Describe the bug A lot of customers have a snippet in place to redirect IPN requests.

For instance:

function mgm_to_pmp_ipn_redirect()
{
    if(!empty($_REQUEST['module']) && !empty($_REQUEST['method']) && defined('PMPRO_DIR'))
    {
        if($_REQUEST['module'] == "mgm_paypal" && $_REQUEST['method'] == "payment_notify")
        {
            require_once(PMPRO_DIR . "/services/ipnhandler.php");
            exit;
        }
    }
}
add_action('init', 'mgm_to_pmp_ipn_redirect');

This is not compatible with CONP since in this case the Webhook IPN is a NON-admin request. CONP is not doing its job because this condition is met: https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/blob/e62e9d5c68dfa3b2540b0066eccf15b6fe5989ba/pmpro-cancel-on-next-payment-date.php#L51-L53

To Reproduce Steps to reproduce the behavior:

  1. Add a snippet which redirects any fake ipn call to the ipnhandler requiring it instead of throwing an admin-ajax request
  2. Simulate a cancellation request through IPN
  3. The membership is immediately cancelled and the next payment date is not set

Isolating the problem (mark completed items with an [x]):