From: eileen Date: Wed, 16 Dec 2020 05:19:42 +0000 (+1300) Subject: [REF] Extract code that assigns isPendingOutcome variable on thank you page X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b2bfcb289c5895edbcac557df344ab06a024cbf0;p=civicrm-core.git [REF] Extract code that assigns isPendingOutcome variable on thank you page --- diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index 41d8077543..2d12a1a6b2 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -279,34 +279,39 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $this->assign('friendURL', $url); } - $isPendingOutcome = TRUE; + $this->assign('isPendingOutcome', $this->isPendingOutcome($params)); + $this->freeze(); + + // can we blow away the session now to prevent hackery + // CRM-9491 + $this->controller->reset(); + } + + /** + * Is the outcome of this contribution still pending. + * + * @param array $params + * + * @return bool + */ + protected function isPendingOutcome(array $params): bool { + if (empty($params['payment_processor_id'])) { + return FALSE; + } try { // A payment notification update could have come in at any time. Check at the last minute. - $contributionStatusID = civicrm_api3('Contribution', 'getvalue', [ + civicrm_api3('Contribution', 'getvalue', [ 'id' => $params['contributionID'] ?? NULL, - 'return' => 'contribution_status_id', - 'is_test' => ($this->_mode == 'test') ? 1 : 0, + 'contribution_status_id' => 'Pending', + 'is_test' => '', + 'return' => 'id', 'invoice_id' => $params['invoiceID'] ?? NULL, ]); - if (CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatusID) === 'Pending' - && !empty($params['payment_processor_id']) - ) { - $isPendingOutcome = TRUE; - } - else { - $isPendingOutcome = FALSE; - } + return TRUE; } catch (CiviCRM_API3_Exception $e) { - + return FALSE; } - $this->assign('isPendingOutcome', $isPendingOutcome); - - $this->freeze(); - - // can we blow away the session now to prevent hackery - // CRM-9491 - $this->controller->reset(); } }