Skip to content

Commit 976dab4

Browse files
Merge pull request #204 from michaelmcandrew/master
Job.Process_recur should not try to update non existing contributions
2 parents 2bf1c84 + c4750ee commit 976dab4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

api/v3/Job/ProcessRecurring.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Pass all due recurring contributions to the processor to action (if possible).
45
*
@@ -65,12 +66,13 @@ function civicrm_api3_job_process_recurring($params) {
6566
'id' => $recurringPayment['id'],
6667
'failure_count' => $recurringPayment['failure_count'] + 1,
6768
]);
68-
civicrm_api3('Contribution', 'create', [
69+
if (!empty($pending['id'])) {
70+
civicrm_api3('Contribution', 'create', [
6971
'id' => $pending['id'],
7072
'contribution_status_id' => 'Failed',
7173
'debug' => $params['debug'] ?? 0,
72-
]
73-
);
74+
]);
75+
}
7476
$result[$recurringPayment['id']]['error'] = $e->getMessage();
7577
$result['failed']['ids'] = $recurringPayment['id'];
7678
}

0 commit comments

Comments
 (0)