pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
34 stars 14 forks source link

Subscriptions with failed first payment are re-activated by later successful payment for other subscription #315

Closed rvdsteege closed 2 years ago

rvdsteege commented 2 years ago

Issue with MemberPress (and possibly other extensions too). If the first payment for a subscription fails, the subscription will get the status 'Failed'. This means that a follow-up payment will be created when payment is due. If the customer created a mandate with a later successful payment for an other subscription, the first subscription will use that mandate. This results in duplicate payments.

We should either:

  1. set the subscription status to 'Cancelled' if the first payment fails;
  2. not start follow-up payments if the subscription status is 'Failed' (discussed earlier with @remcotolsma; we also want to have a way to have insights in failed payments for the subscriptions — which the 'Failed' status currently gives).

Internal Help Scout ticket: https://secure.helpscout.net/conversation/1812850798/23651

remcotolsma commented 2 years ago

Option 2 is probably a good step forward.

Should we change:

'post_status'    => array(
    'subscr_pending',
    'subscr_failed',
    'subscr_active',
),

to just:

'post_status'    => 'subscr_active',

?

https://github.com/pronamic/wp-pay-core/blob/01086c3caf4518d0e609e7d43c7b1d22ee090187/src/Subscriptions/SubscriptionsFollowUpPaymentsController.php#L390-L394

Then the operation is simpler, follow-up payments are only started for active subscriptions (subscription with the status active).

rvdsteege commented 2 years ago

I think we eventually want to make that change anyway, so updating the query to look at subscr_active post statuses is fine with me.

However, how will we handle failed recurring payments? Set both the payment status and subscription status to Failed (as is currently the case)? Do we then need to inform the admin to manually update the subscription status to Active again to continue payments when the next payment is due? And what if admin re-activates the subscription after the next payment date; payments will not be started as follow-up payments only query subscriptions with a next payment (delivery) date in the past 24 hours.

remcotolsma commented 2 years ago

I think payment status to Failed and subscription status On hold, an administrator should figure out what to do next. I think this is also related to the advice of Mollie on https://help.mollie.com/hc/nl/articles/115000309865-Waarom-is-mijn-incasso-mislukt-.

Vraag de klant om de juiste IBAN.

We raden je aan om de klant om een andere rekening te vragen.

Vraag de klant daarom om een andere rekening.

Probeer de incasso nog eens uit te voeren of neem contact op met de klant.

In almost all cases, the advice is to contact the customer.

Do we then need to inform the admin to manually update the subscription status to Active again to continue payments when the next payment is due?

Yes, maybe for now go with just a little count pill badge for the On hold items after the WordPress admin subscriptions menu item ?

Schermafbeelding 2022-03-23 om 17 42 54

Then administrators will at least see that action is required for a number of subscriptions.

And what if admin re-activates the subscription after the next payment date; payments will not be started as follow-up payments only query subscriptions with a next payment (delivery) date in the past 24 hours.

I think this requires some JavaScript, show a warning as soon as status select option is changed to "Active" and next payment date is in the past?

Ideally add the ability to change the next payment date?

rvdsteege commented 2 years ago

Option 2 is probably a good step forward.

Implemented in https://github.com/pronamic/wp-pay-core/commit/79f5b64c879808e165302ca9f423dcf10e702215