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

[REF] Clean up interaction with contribution recur object

It we look in getIDS and through that to getContributionObject we can see that an exception
is thrown if there is no valid recurring contribution object (A.net only does IPNs for recurring).

This removes a bunch of condition ifs around it's presence and also uses the object more consistently
parent 9a66ac8d
Branches
Tags
No related merge requests found
......@@ -75,14 +75,10 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
$ids['contact'] = $contribution->contact_id;
}
if (!empty($ids['contributionRecur'])) {
$contributionRecur = new CRM_Contribute_BAO_ContributionRecur();
$contributionRecur->id = $ids['contributionRecur'];
if (!$contributionRecur->find(TRUE)) {
CRM_Core_Error::debug_log_message("Could not find contribution recur record: {$ids['ContributionRecur']} in IPN request: " . print_r($input, TRUE));
echo "Failure: Could not find contribution recur record: {$ids['ContributionRecur']}<p>";
return FALSE;
}
$contributionRecur = new CRM_Contribute_BAO_ContributionRecur();
$contributionRecur->id = $ids['contributionRecur'];
if (!$contributionRecur->find(TRUE)) {
throw new CRM_Core_Exception("Could not find contribution recur record: {$ids['ContributionRecur']} in IPN request: " . print_r($input, TRUE));
}
$objects['contact'] = &$contact;
......@@ -90,11 +86,11 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
$this->loadObjects($input, $ids, $objects, TRUE, $paymentProcessorID);
if (!empty($ids['paymentProcessor']) && $objects['contributionRecur']->payment_processor_id != $ids['paymentProcessor']) {
if (!empty($ids['paymentProcessor']) && $contributionRecur->payment_processor_id != $ids['paymentProcessor']) {
Civi::log()->warning('Payment Processor does not match the recurring processor id.', ['civi.tag' => 'deprecated']);
}
if ($component == 'contribute' && $ids['contributionRecur']) {
if ($component == 'contribute') {
// check if first contribution is completed, else complete first contribution
$first = TRUE;
if ($objects['contribution']->contribution_status_id == 1) {
......@@ -119,7 +115,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
return $this->recur($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
'contributionRecur' => $contributionRecur->id,
'contact' => $ids['contact'] ?? NULL,
'contributionPage' => $ids['contributionPage'] ?? NULL,
], $objects['contributionRecur'], $objects['contribution'], $first);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment