From: eileen Date: Thu, 25 Mar 2021 23:38:08 +0000 (+1300) Subject: [REF] Cleanup access to payment_processor_id X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=17dcf20115464a73a25a6b89655be1098ad904ac;p=civicrm-core.git [REF] Cleanup access to payment_processor_id --- diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index c25e991bdc..84dce6fa35 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -816,8 +816,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * @return int */ - public function getPaymentProcessorID() { - return $this->_paymentProcessorID; + public function getPaymentProcessorID(): int { + return (int) $this->_paymentProcessorID; } /** diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 31bcac4792..9d4d85d58b 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1163,7 +1163,7 @@ DESC limit 1"); $params['financial_type_id'] = $this->getFinancialTypeID(); //get the payment processor id as per mode. Try removing in favour of beginPostProcess. - $params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id']; + $params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->getPaymentProcessorID(); $params['register_date'] = CRM_Utils_Time::date('YmdHis'); // add all the additional payment params we need @@ -1808,7 +1808,7 @@ DESC limit 1"); } $recurParams['invoice_id'] = $this->getInvoiceID(); $recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); - $recurParams['payment_processor_id'] = $params['payment_processor_id'] ?? NULL; + $recurParams['payment_processor_id'] = $this->getPaymentProcessorID(); $recurParams['is_email_receipt'] = (bool) $this->getSubmittedValue('send_receipt'); // we need to add a unique trxn_id to avoid a unique key error // in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991 @@ -1879,4 +1879,13 @@ DESC limit 1"); return $this->_mode && $this->getSubmittedValue('auto_renew'); } + /** + * Get the payment processor ID. + * + * @return int + */ + public function getPaymentProcessorID(): int { + return (int) ($this->getSubmittedValue('payment_processor_id') ?: $this->_paymentProcessor['id']); + } + }