From 1f1dbd19b99ae65ca037d6a18dfab99eb14573ab Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 18 May 2020 18:04:31 +1200 Subject: [PATCH] Call completeOrder directly from contribute status update form We should really call completetransaction but that has been left for later unravelling with the focus here being to clarify the purpose of the transaction. We don't need to pass a transaction around unless it has DB changes not yet committed - which is not eally the case here. There is no reason to invoke BaseIPN but more unravelling required... --- CRM/Contribute/Form/Task/Status.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index 09f1285c99..c8acc1e8ff 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -215,8 +215,6 @@ AND co.id IN ( $contribIDs )"; $statusID = $params['contribution_status_id'] ?? NULL; $baseIPN = new CRM_Core_Payment_BaseIPN(); - $transaction = new CRM_Core_Transaction(); - // get the missing pieces for each contribution $contribIDs = implode(',', $form->_contributionIds); $details = self::getDetails($contribIDs); @@ -246,11 +244,13 @@ AND co.id IN ( $contribIDs )"; ); if ($statusID == array_search('Cancelled', $contributionStatuses)) { + $transaction = new CRM_Core_Transaction(); $baseIPN->cancelled($objects, $transaction); $transaction->commit(); continue; } elseif ($statusID == array_search('Failed', $contributionStatuses)) { + $transaction = new CRM_Core_Transaction(); $baseIPN->failed($objects, $transaction); $transaction->commit(); continue; @@ -261,7 +261,6 @@ AND co.id IN ( $contribIDs )"; $contributionStatuses ) ) { - $transaction->commit(); continue; } @@ -282,8 +281,8 @@ AND co.id IN ( $contribIDs )"; $input['trxn_date'] = $params["trxn_date_{$row['contribution_id']}"] . ' ' . date('H:i:s'); $input['is_email_receipt'] = !empty($params['is_email_receipt']); - // @todo calling baseIPN like this is a pattern in it's last gasps. Call contribute.completetransaction api. - $baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE); + // @todo calling CRM_Contribute_BAO_Contribution::completeOrder like this is a pattern in it's last gasps. Call contribute.completetransaction api. + CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects); // reset template values before processing next transactions $template->clearTemplateVars(); -- 2.25.1