[REF][PHP8.2] Fix Dynamic property payment instrument id on back office contribution...
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 26 Jan 2023 00:35:48 +0000 (00:35 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 26 Jan 2023 00:35:48 +0000 (00:35 +0000)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/Contribution.php

index 1aa0ee72f4eaec4480833ca70dee8436f3c07920..59c30d96ac0d821672e468411a52899e23da79d8 100644 (file)
@@ -707,7 +707,7 @@ WHERE  contribution_id = {$id}
    *
    * @throws \CRM_Core_Exception
    */
-  protected function getDefaultPaymentInstrumentId() {
+  protected function getDefaultPaymentInstrumentId(): int {
     $paymentInstrumentID = CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer');
     return (int) ($paymentInstrumentID ?? $this->_paymentProcessor['payment_instrument_id']);
   }
index daac2892e9ac6a4b4d504cc4f8ab18caf51192d7..4a137b44c045a0e108e615da41aae87fd46b8a8e 100644 (file)
@@ -208,6 +208,14 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
    */
   protected $previousContributionStatus;
 
+
+  /**
+   * Payment Instrument ID
+   *
+   * @var int
+   */
+  public $payment_instrument_id;
+
   /**
    * Explicitly declare the form context.
    */
@@ -590,7 +598,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $paneNames[ts('Premium Information')] = 'Premium';
     }
 
-    $this->payment_instrument_id = CRM_Utils_Array::value('payment_instrument_id', $defaults, $this->getDefaultPaymentInstrumentId());
+    $this->payment_instrument_id = $defaults['payment_instrument_id'] ?? $this->getDefaultPaymentInstrumentId();
     CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->payment_instrument_id);
     if (!empty($this->_recurPaymentProcessors)) {
       $buildRecurBlock = TRUE;