From f6c0beee9a32bc47a19dc81f758d6b3fdbbccf90 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 11 Oct 2020 09:32:12 +1300 Subject: [PATCH] dev/financial#152 Clean up & test contributionPageID handling --- CRM/Core/Payment/AuthorizeNetIPN.php | 14 +------------- .../CRM/Core/Payment/AuthorizeNetIPNTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index bcf56e15af..1cadb8f931 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -80,6 +80,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { if (!$contribution->find(TRUE)) { throw new CRM_Core_Exception('Failure: Could not find contribution record for ' . (int) $contribution->id, NULL, ['context' => "Could not find contribution record: {$contribution->id} in IPN request: " . print_r($input, TRUE)]); } + $ids['contributionPage'] = $contribution->contribution_page_id; // make sure contact exists and is valid // use the contact id from the contribution record as the id in the IPN may not be valid anymore. @@ -106,13 +107,6 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $objects['contact'] = &$contact; $objects['contribution'] = &$contribution; - // CRM-19478: handle oddity when p=null is set in place of contribution page ID, - if (!empty($ids['contributionPage']) && !is_numeric($ids['contributionPage'])) { - // We don't need to worry if about removing contribution page id as it will be set later in - // CRM_Contribute_BAO_Contribution::loadRelatedObjects(..) using $objects['contribution']->contribution_page_id - unset($ids['contributionPage']); - } - $this->loadObjects($input, $ids, $objects, TRUE, $paymentProcessorID); if (!empty($ids['paymentProcessor']) && $objects['contributionRecur']->payment_processor_id != $ids['paymentProcessor']) { @@ -321,12 +315,6 @@ INNER JOIN civicrm_contribution co ON co.contribution_recur_id = cr.id throw new CRM_Core_Exception($message); } - // get page id based on contribution id - $ids['contributionPage'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', - $ids['contribution'], - 'contribution_page_id' - ); - if ($input['component'] == 'event') { // FIXME: figure out fields for event } diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index 269e3d519d..12ee0cdc56 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -1,6 +1,7 @@ assertEquals(date('Y-m-d'), substr($updatedContributionRecurAgain['end_date'], 0, 10)); // There should not be any email. $mut->assertMailLogEmpty(); + + $contributions = Contribution::get()->addWhere('contribution_recur_id', '=', $this->_contributionRecurID)->addSelect('contribution_page_id')->execute(); + foreach ($contributions as $contribution) { + $this->assertEquals($this->_contributionPageID, $contribution['contribution_page_id']); + } } /** -- 2.25.1