strangerstudios / pmpro-pay-by-check

Add a "Pay by Check" option to PMPro levels, and keep members in "pending" status until an admin changes the order status.
https://www.paidmembershipspro.com/add-ons/pmpro-pay-by-check-add-on/
11 stars 27 forks source link

Do not create recurring orders if last payment was from another gateway #115

Closed dparker1005 closed 7 months ago

dparker1005 commented 7 months ago

All Submissions:

Changes proposed in this Pull Request:

Fixed issue in PMPro v3.0+ where recurring orders could be created for old Check orders even if the last payment was from a different payment gateway.

This means that if a user paid by check and then switched to paying with Stripe, recurring check orders could still be created in pending status and, if not marked as success, the user's membership could be canceled.

The change in PMPro v3.0 that brought about this issue was the removal of the cancelled status. The query fix by this PR only looks for orders in pending or success status to create a recurring order for, and since orders for old memberships were in cancelled status previously, recurring orders would not be created for them. Now that all cancelled orders are now success, this safeguard no longer works.

The fix in this PR changes the query to say "Only create recurring order if there is an old Check order that does not have orders from ANY gateway following it".

The fact that all orders are now success means that this query is now a lot less performant. We want to update this Add On to utilize Subs Table ASAP to both fix edge cases and improve performance.

Other information:

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.