Abandoned payments aren't being cancelled
Created by: wmortada
v1.8 added a schedulded job to mark pending recurring contributions as failed and the related contributions as cancelled (see release notes).
The relevant code is here: https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/blob/master/api/v3/Job/Gocardlessfailabandoned.php#L26-L81
The first part of this seems to be working fine. The recurring contributions are identified and marked as 'Failed'. However the second part seems not to be happening. Most contributions are left as 'Pending'. Only a few are updated to 'Cancelled'.
Looking at our scheduled job log I can see that this job is generating an error:
Full message: Finished execution of GoCardless: mark abandoned Pending recurring contributions Failed with result: Failure, Error message: Expected one FinancialItem but found 0
Looking at the code I think it is the following lines that are causing the error: https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/blob/master/api/v3/Job/Gocardlessfailabandoned.php#L70-L75
It appears to fail because there are no financial items associated with the contribution (because it wasn't completed). I'm not sure if this is due to a recent change in CiviCRM, but have found reference to what sounds like a similar issue here: https://github.com/mecachisenros/woocommerce_civicrm/issues/32
We're using CiviCRM 5.33.5 on WordPress 5.4.6 and v1.9.3 of this extension.