From f443eb025a7d93b15c44b245d091afdfc7ddb0f1 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 13 Feb 2017 08:03:59 +1100 Subject: [PATCH] CRM-20007 Fix issue where contribution not getting correct payment instrument set --- CRM/Contribute/BAO/Contribution.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 09f57773ec..361ad3a378 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4467,6 +4467,12 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) )); $contributionParams['payment_processor'] = $input['payment_processor'] = $paymentProcessorId; + // If paymentProcessor is not set then the payment_instrument_id would not be correct. + // not clear when or if this would occur if you encounter this please fix here & add a unit test. + if (empty($contributionParams['payment_instrument_id']) && isset($contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'])) { + $contributionParams['payment_instrument_id'] = $contribution->_relatedObjects['paymentProcessor']['payment_instrument_id']; + } + if ($recurringContributionID) { $contributionParams['contribution_recur_id'] = $recurringContributionID; } -- 2.25.1