Page MenuHomePhabricator

DLocal recurring cancel not sticking
Closed, ResolvedPublic

Description

We have a DLocal recurring donation where the cancel button in Civi is not cancelling the donation.

CID 55939331 - reached out Nov 29th (ZD 1407724) asking for their recurring to be cancelled. We did so, but then a new donation was reinstated the same day (with no new contribution, but a TY receipt was sent).

Donor reached out again on Dec 29th (ZD 1429672) when the next installment processed, asking again for a cancel. We again cancelled, but a new donation has been once again set up, with the next processing date on Jan 29th. Again the new one was set up with no new contribution, but with a TY receipt being sent.

(check activities in Civi to see the paper trail).

It seems highly unlikely a donor would set up a new donation the same day it cancelled, after asking for it to be cancelled twice, and I don't know how a donor would set up a new recurring without a new contribution coming through, so I believe the recurring cancel function in Civi is not working correctly for this donor.

We have not yet cancelled the new recurring donation, in case it's useful for it to be live for triage.

Can we please look into this, and also other DLocal recurring that have been cancelled, to ensure there isn't an issue? Thanks!

Event Timeline

@jgleeson Is this an issue within the Dlocal infrastructure that we should chase down?

@Damilare has picked this one up and is looking into it now

Change 987846 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/crm@master] Ensure no new rows are created for UPI transaction when a payment message is received after DR had cancelled the recurring.

https://gerrit.wikimedia.org/r/987846

Thanks @EMartin and @krobinson for reporting this issue. Looks like the primary cause of this is the prenotification system of UPI recurrings. I've pushed up a patch to prevent a new recurring from starting when we receive a payment from a cancelled recurring. Cancelling the payment on Civi alone is not enough for a payment in the prenotification stage, the donor would also need to cancel the request on their end.

@EMartin It would be good to know if Dlocal offers a method by which we can cancel a payment during the pre-notification phase on our end.

cc @jgleeson @Ejegg

I'm wondering if we also need to add a check in this function (or before calling this function): rWFCG drupal/sites/default/civicrm/extensions/wmf-civicrm/Civi/WMFHelpers/ContributionRecur.php:62

To avoid saying paypal by name we could say

if (gatewayHandlesRecurringScheduling($msg['gateway']))

or something like that. There's the IRecurringPaymentProfileProvider at the SmashPig level that might be a good indicator, though we'd have to instantiate a class to check that.

Going a bit further down the rabbit hole, it looks like that reactivateIfInactive function isn't actually working as advertised. It's clearing out the cancel date, cancel reason, and end date, but it's not actually changing the status.

Noticed with this one:
select * from log_civicrm_contribution_recur where id=1358652;

Change 987881 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/crm@master] Fix recurring record reactivation

https://gerrit.wikimedia.org/r/987881

@Damilare - After reading all notes here I am a little unsure if you still want us to reach out to dLocal for "@EMartin It would be good to know if Dlocal offers a method by which we can cancel a payment during the pre-notification phase on our end.". Please let me know.

Hi @RKumar_WMF, yes that would still be good to check up on.

greg triaged this task as High priority.Jan 5 2024, 5:13 PM

@Damilare - are we good to go ahead and re-cancel this recurring donation now?

Also, is there any way to check other UPI recurring cancels to ensure the cancels have stuck? Thanks!

Hi @krobinson, we are still reviewing the patch. We'd inform you when it is deployed for the cancellations.

Here's a list of similar donors I found in our db:

+------------+
| contact_id |
+------------+
|   43699200 |
|   55563390 |
|   60126498 |
|   55939331 |
|   60296658 |
|   60346240 |
|   60385025 |
|   19017403 |
|    3770950 |
|   60401921 |
|   60422664 |
|   60423732 |
|   60430326 |
+------------+

Query: select contact_id from civicrm_contribution_recur where payment_token_id in (select id from civicrm_payment_token where payment_processor_id=3 group by token having count(token) >1);

Response from dLocal:

"After review and discussion with Seba and the team, unfortunately, we are unable to make changes or cancel the payment at the pre-notification phase."

Change 987846 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Ensure no new rows are created for UPI transaction when a payment message is received after DR had cancelled the recurring.

https://gerrit.wikimedia.org/r/987846

Change 987881 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Fix recurring record reactivation

https://gerrit.wikimedia.org/r/987881

Thanks @RKumar_WMF, the changes have been deployed. This means if the donor requests to cancel the recurring and approves the prenotification, the recurring would be cancelled but the approved payment would be completed.

@krobinson the changes have been deployed and the recurrings can now be cancelled. Thanks for your patience.

Thank you, however, the pre-notification does not carry any action, it is just FYI sorts, so donor does not have any way to approve it. @Damilare

Thanks for the update.

Can I just confirm the actual flow here to confirm I'm following correctly:

  • Donor requests cancel during prenotification period
  • DR cancels donation
  • However the last payment (which may be AFTER the cancel has been actioned) will still process, but the cancel of the subscription will stick?

If that is correct, I can see us getting a lot of refund requests or follow ups a few days later to confirm the donation was actually cancelled as a charge has processed.

Is there any way to streamline this? Thanks for clarifying!

Hi @krobinson, the flow is correct and the cancel of the subscription would always stick if in or out of the prenotification stage.

The donor can cancel the payment at the prenotification stage, if they do so they won't be charged. However, if they approve the payment in the prenotification stage and choose to refund, we have a batch refund script that can help with that.

Thanks Dami!

Can I just confirm one thing: @RKumar_WMF said the prenotification is an FYI with no action, can I confirm that the donor is able to cancel the payment at this stage?

@krobinson looks like I may have mixed it up a bit, I just confirmed with the team and looks like the donor also can't cancel the payment in the prenotification stage.

Thanks for confirming!

Is there any workaround on this? As I can see this being confusing for donors - cancelling but then being billed doesn't feel like optimum experience, even if there is a notification. I'm sure many will be concerned the cancel didn't work.

@krobinson, I understand and I'm currently discussing with the team about a potential solution. While we may not be able to cancel the payment given Dlocal capabilities, we might be able to automate the refunds. I'd let you know the outcome of the conversation.

Hi @krobinson, it is possible for us to refund the donor automatically as soon as we get the payment notification. This is the most optimal approach we were able to decide on, I'd push up a patch for this change shortly.

Change 989949 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/crm@master] Refund donation received after recurring cancelled

https://gerrit.wikimedia.org/r/989949

Change 991572 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/SmashPig@master] Add interface for refund payment to dlocal

https://gerrit.wikimedia.org/r/991572

Change 991572 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Add interface for refund payment to dlocal

https://gerrit.wikimedia.org/r/991572

Change 989949 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Refund donation received after recurring cancelled

https://gerrit.wikimedia.org/r/989949

XenoRyet set Final Story Points to 4.