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

Orders in 'review' status immediately cancelled #12

Closed mircobabini closed 3 years ago

mircobabini commented 3 years ago

Describe the bug With PayPal Express frequently happens to have orders in 'review' status for a while (or, sometimes, forever). When the cancellation logic runs just uses the 'success' status to extend the next date. Check this up. So, since the order in 'review' status is not found, the cancellation is not extended to the end of the period.

To Reproduce Steps to reproduce the behavior:

  1. Create a paid order
  2. Set the status to 'review'
  3. Cancel the order from the gateway (or maybe from the site as well)
  4. Cancellation is immediate, not to the next payment date

Expected behavior Since the 'review' status is considered like a paid status, we should set the enddate to the end of the paid period.

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

WordPress Environment

``` Please share non-sensitive information about your hosting environment such as WordPress version, PHP version, Paid Memberships Pro and any related plugins versions. ```
mircobabini commented 3 years ago

Please note that I really don't know if using [ 'review', 'success' ] may cause issues with other gateways.

Also, when cancelling from the site (not from the gateway) there is a related issue because of the pmpro_next_payment method at this line, searching for a 'success' order as well. By the way, if the correct order is found above, we can maybe use the MemberOrder status.

This is what I mean: compare.

mircobabini commented 3 years ago

Also, just to add everything to this discussion even if related to PMPro Core, the pmpro_next_payment should just be used to find the MemberOrder and then use a MemberOrder::getNextPayment method with the logic into it.

This way, every time you already have a MemberOrder, don't have to search for it once again.

This issue is logged in pmpro core as well: https://github.com/strangerstudios/paid-memberships-pro/issues/1530

mircobabini commented 3 years ago

Can be closed once https://github.com/strangerstudios/paid-memberships-pro/pull/1600 will be merged.