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

Users will receive an extra year in certain PayPal cases #8

Closed kimcoleman closed 3 years ago

kimcoleman commented 3 years ago

Describe the bug When a PayPal payment subscription fails, sometimes there are two IPN sent. This is a case where the payment fails and the admin would receive the email from PayPal "An automatic payment failed. You didn't get your money."

The first IPN sent in this scenario has the IPN txn_type recurring_payment_failed the value for the next_payment_date is one year out. Then, a second IPN is sent with the txn_type recurring_payment_profile_cancel and the value for the next_payment_date is "N/A".

The CONPD code here (https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/blob/dev/pmpro-cancel-on-next-payment-date.php#L50) processes the logic to set cancellation on next payment date one year out when the first IPN is received. The second IPN is ignored.

We should probably add logic before this line to first process the IPN txn_type recurring_payment_failed and use the built-in pmpro_next_payment function to cancel immediately.

kimcoleman commented 3 years ago

Fixed in https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/commit/b01d1b068217d882b90ae4e54f5f2add132dd840