CRM-20336: Failed contributions should be set as failed, not left as pending (cleanup)
[civicrm-core.git] / CRM / Contribute / BAO / Contribution.php
index cda0ca55b0f81466711a054aec807b46b6bd9ddd..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',
+    ));
   }
 
   /**
@@ -4532,6 +4538,8 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
 
             // CRM-8141 update the membership type with the value recorded in log when membership created/renewed
             // this picks up membership type changes during renewals
+            // @todo this is almost certainly an obsolete sql call, the pre-change
+            // membership is accessible via $this->_relatedObjects
             $sql = "
 SELECT    membership_type_id
 FROM      civicrm_membership_log