CRM-20336: Failed contributions should be set as failed, not left as pending (cleanup)
[civicrm-core.git] / CRM / Contribute / BAO / Contribution.php
index 60b197bd78dfaa63166884febba6f437412a480f..2e3404c3603205d56e9b396ae61425f637055b13 100644 (file)
@@ -1053,6 +1053,12 @@ LEFT JOIN  civicrm_line_item i ON ( i.contribution_id = c.id AND i.entity_table
       'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
         $contactID,
     ));
+
+    // CRM-20336 Make sure that the contribution status is Failed, not Pending.
+    civicrm_api3('contribution', 'create', array(
+      'id' => $contributionID,
+      'contribution_status_id' => 'Failed',
+    ));
   }
 
   /**