'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'];