From e3b6c2443c2de5958ed448d361acae86d79b99ca Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Tue, 3 Oct 2017 17:33:53 +0530 Subject: [PATCH] CRM-21200: Pay Now payment overwrites the contribution --- CRM/Contribute/BAO/Contribution/Utils.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 3930addfda..c245f95a17 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -102,10 +102,26 @@ class CRM_Contribute_BAO_Contribution_Utils { 'id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'is_test' => $isTest, - 'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)), - 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), ); + + // CRM-21200: Don't overwrite contribution details during 'Pay now' payment + if (empty($form->_params['contribution_id'])) { + $contributionParams['contribution_page_id'] = $form->_id; + $contributionParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $paymentParams, CRM_Utils_Array::value('campaign_id', $form->_values)); + } + // In case of 'Pay now' payment, append the contribution source with new text 'Paid later via page ID: N.' + else { + // contribution.source only allows 255 characters so we are using ellipsify(...) to ensure it. + $contributionParams['source'] = CRM_Utils_String::ellipsify( + ts('Paid later via page ID: %1. %2', array( + 1 => $form->_id, + 2 => $contributionParams['source'], + )), + 220 // eventually activity.description append price information to source text so keep it 220 to ensure string length doesn't exceed 255 characters. + ); + } + if (isset($paymentParams['line_item'])) { // @todo make sure this is consisently set at this point. $contributionParams['line_item'] = $paymentParams['line_item']; -- 2.25.1