Page MenuHomePhabricator

Check on handling of payment-method.deleted IPNs from Gravy
Closed, ResolvedPublic

Description

This is how they send us what's basically a subscr_cancel IPN from PayPal. An example from payments-listener-gravy-20260405.gz:
{

"type": "event",
"name": "payment-method.deleted",
"id": "0786948d-bba7-4748-8052-2418441b29d6",
"created_at": "2026-04-04T08:50:39.953833+00:00",
"target": {
  "type": "payment-method",
  "id": "07a398d7-cbbc-4261-bce9-3c6e6a938062",
  "external_identifier": null,
  "method": "paypal",
  "status": "succeeded",
  "created_at": "2025-05-15T08:39:52.819891+00:00",
  "updated_at": "2026-04-04T08:50:39.945828+00:00"
},
"merchant_account_id": "default",
"gr4vy_id": "wikimedia",
"environment": "production"

}

This should have been recorded as a recurring cancel but instead we went on to try to charge the donation on Apr 15th

Relevant classes: (smashpig)
PaymentProviders/Gravy/Actions/PaymentMethodDeleteAction.php
PaymentProviders/Gravy/Jobs/RecurringCancellationJob.php

Event Timeline

Looks like we're relying on civicrm_contribution_recur.trxn_id to be the same as payment_token.token for all Gravy / Paypal recurrings, and it's mostly but not always true. If we search by payment_token.token that would be more reliable. There used to be indexing issues there, but maybe not now?

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

[wikimedia/fundraising/crm@master] Let subscr_cancel specify recurring_payment_token

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

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

[wikimedia/fundraising/SmashPig@master] Cancel gravy/paypal by token not subscr_id

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

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

[wikimedia/fundraising/crm@master] Remove special subscr_id for gravy/paypal

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

Change #1273906 merged by Eileen:

[wikimedia/fundraising/crm@master] Let subscr_cancel specify recurring_payment_token

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

Change #1273913 merged by Eileen:

[wikimedia/fundraising/SmashPig@master] Cancel gravy/paypal by token not subscr_id

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

I deployed the CiviCRM patch to handle payment tokens in subscr_cancel messages yesterday, and deployed the SmashPig patch to send them that way today, so hopefully we should stop seeing the 'payment method not found' failmails from Gravy/PayPal recurrings by this time next month. There is one follow-on patch still in review that will stop special-casing the contribution_recur.trxn_id for gravy/paypal.

XenoRyet set Final Story Points to 4.

Change #1275995 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Remove special subscr_id for gravy/paypal

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