From: deb.monish Date: Tue, 3 Oct 2017 12:03:53 +0000 (+0530) Subject: CRM-21200: Pay Now payment overwrites the contribution X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3b6c2443c2de5958ed448d361acae86d79b99ca;p=civicrm-core.git CRM-21200: Pay Now payment overwrites the contribution --- 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'];