diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 6a328ca1e9e6b43b28e79aa0a8c44f2c50e03a65..fd7447efd8d2fd076a377796f9336674433016bd 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -653,14 +653,15 @@ WHERE contribution_id = {$id} /** * Get the default payment instrument id. * + * This priortises the submitted value, if any and falls back on the processor. + * * @return int + * + * @throws \CRM_Core_Exception */ protected function getDefaultPaymentInstrumentId() { $paymentInstrumentID = CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer'); - if ($paymentInstrumentID) { - return $paymentInstrumentID; - } - return key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); + return (int) ($paymentInstrumentID ?? $this->_paymentProcessor['payment_instrument_id']); } /**