Skip to content

Commit

Permalink
dev/financial#152 Clean up & test contributionPageID handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 10, 2020
1 parent 6ed4a27 commit f6c0bee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 1 addition & 13 deletions CRM/Core/Payment/AuthorizeNetIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function main($component = 'contribute') {
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.
Expand All @@ -106,13 +107,6 @@ public function main($component = 'contribute') {
$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']) {
Expand Down Expand Up @@ -321,12 +315,6 @@ public function getIDs(&$ids, &$input) {
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
}
Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Civi\Payment\Exception\PaymentProcessorException;
use Civi\Api4\Contribution;

/**
* Class CRM_Core_Payment_PayPalProIPNTest
Expand Down Expand Up @@ -135,6 +136,11 @@ public function testIPNPaymentRecurNoReceipt() {
$this->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']);
}
}

/**
Expand Down

0 comments on commit f6c0bee

Please sign in to comment.