* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public static function completeOrder($input, &$ids, $objects, $isPostPaymentCreate = FALSE) {
+ public static function completeOrder($input, $ids, $objects, $isPostPaymentCreate = FALSE) {
$transaction = new CRM_Core_Transaction();
$contribution = $objects['contribution'];
+ // @todo see if we even need this - it's used further down to create an activity
+ // but the BAO layer should create that - we just need to add a test to cover it & can
+ // maybe remove $ids altogether.
+ $contributionContactID = $ids['related_contact'] ?? NULL;
+ // Unset ids just to make it clear it's not used again.
+ unset($ids);
// The previous details are used when calculating line items so keep it before any code that 'does something'
if (!empty($contribution->id)) {
$input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(['id' => $contribution->id]);
if ($input['component'] == 'contribute') {
//CRM-4027
$targetContactID = NULL;
- if (!empty($ids['related_contact'])) {
+ if ($contributionContactID) {
$targetContactID = $contribution->contact_id;
- $contribution->contact_id = $ids['related_contact'];
+ $contribution->contact_id = $contributionContactID;
}
CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID);
}
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public function completeTransaction(&$input, &$ids, &$objects) {
+ public function completeTransaction($input, $ids, $objects) {
CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects);
}