Skip to content
Snippets Groups Projects
Commit 01a5d8d4 authored by eileen's avatar eileen
Browse files

Simplify parameters passed to completeOrder

Now that completeOrder has had most interaction with objects var cleaned up
we know only 2 objects are actually used
- contribution - which we can fetch in-function
- paymentProcessor - which we were actually only guessing

This alters it to only load & pass contribution. The value of passing in
processor seems lost in time. This code can only be reached for pay_later contributions - see

CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution
and specifically
https://github.com/civicrm/civicrm-core/blob/318c63045e82d30ed7fe8cdacb91a6d31fc5331b/CRM/Contribute/BAO/Contribution.php#L2033

and only when submitted via an online event (same function) so by definition there IS NO PAYMENT PROCESSOR that applies.

Given that we can just do the minimum to load the contribution and pass that in.
parent fd364ea9
Branches
Tags
No related merge requests found
......@@ -312,43 +312,15 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
*
*/
public static function updateContributionStatus($params) {
// get minimum required values.
$componentId = $params['component_id'] ?? NULL;
$contributionId = $params['contribution_id'] ?? NULL;
$input = $ids = $objects = [];
//get the required ids.
$ids['contribution'] = $contributionId;
$ids['participant'] = $params['component_id'];
if (!$ids['contact'] = CRM_Utils_Array::value('contact_id', $params)) {
$ids['contact'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution',
$contributionId,
'contact_id'
);
}
if (!$ids['event'] = CRM_Utils_Array::value('event_id', $params)) {
$ids['event'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant',
$componentId,
'event_id'
);
}
$input['component'] = 'event';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$input = ['component' => 'event'];
// reset template values.
$template = CRM_Core_Smarty::singleton();
$template->clearTemplateVars();
if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) {
throw new CRM_Core_Exception('validation error');
}
$contribution = &$objects['contribution'];
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['contribution_id'];
$contribution->fetch();
$contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [
'labelColumn' => 'name',
......@@ -387,10 +359,10 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
// @todo use the api - ie civicrm_api3('Contribution', 'completetransaction', $input);
// as this method is not preferred / supported.
CRM_Contribute_BAO_Contribution::completeOrder($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
'related_contact' => NULL,
'participant' => $params['component_id'],
'contributionRecur' => NULL,
], $objects);
], ['contribution' => $contribution]);
// reset template values before processing next transactions
$template->clearTemplateVars();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment