Skip to content

Commit

Permalink
Remove legacy check
Browse files Browse the repository at this point in the history
This check dates right back to when we started extracting IPN code from code blocks in the processor. I don't believe it's meaningful
  • Loading branch information
eileenmcnaughton committed Nov 25, 2020
1 parent d2d89bd commit c2d8f26
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 56 deletions.
13 changes: 9 additions & 4 deletions CRM/Core/Payment/AuthorizeNetIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/

use Civi\Api4\PaymentProcessor;

/**
*
* @package CRM
Expand Down Expand Up @@ -85,9 +87,6 @@ public function main() {

$ids['paymentProcessor'] = $paymentProcessorID;
$contribution->loadRelatedObjects($input, $ids);
if (empty($contribution->_relatedObjects['paymentProcessor'])) {
throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);
}

// check if first contribution is completed, else complete first contribution
$first = TRUE;
Expand Down Expand Up @@ -339,12 +338,18 @@ protected function getContributionRecurObject(string $processorID, int $contactI
*
* @return int
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
protected function getPaymentProcessorID(): int {
// Attempt to get payment processor ID from URL
if (!empty($this->_inputParameters['processor_id'])) {
if (!empty($this->_inputParameters['processor_id']) &&
'AuthNet' === PaymentProcessor::get(FALSE)
->addSelect('payment_processor_type_id:name')
->addWhere('id', '=', $this->_inputParameters['processor_id'])
->execute()->first()['payment_processor_type_id:name']
) {
return (int) $this->_inputParameters['processor_id'];
}
// This is an unreliable method as there could be more than one instance.
Expand Down
3 changes: 0 additions & 3 deletions CRM/Core/Payment/BaseIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ public function loadObjects($input, &$ids, &$objects, $required, $paymentProcess
$contribution = &$objects['contribution'];
$ids['paymentProcessor'] = $paymentProcessorID;
$success = $contribution->loadRelatedObjects($input, $ids);
if ($required && empty($contribution->_relatedObjects['paymentProcessor'])) {
throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);
}
$objects = array_merge($objects, $contribution->_relatedObjects);
return $success;
}
Expand Down
3 changes: 0 additions & 3 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,6 @@ public function main() {
if (!$contribution->loadRelatedObjects($input, $ids)) {
return;
}
if (empty($contribution->_relatedObjects['paymentProcessor'])) {
throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);
}

$input['payment_processor_id'] = $paymentProcessorID;

Expand Down
47 changes: 1 addition & 46 deletions tests/phpunit/CRM/Core/Payment/BaseIPNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,32 +315,8 @@ public function testLoadPledgeObjects() {
public function testLoadPledgeObjectsInvalidPledgeID() {
$this->_setUpPledgeObjects();
$this->ids['pledge_payment'][0] = 0;
try {
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
}
catch (CRM_Core_Exception $e) {
$this->assertEquals('Could not find payment processor for contribution record: 1', $e->getMessage());
}
$this->assertArrayNotHasKey('pledge_payment', $this->objects);

$this->ids['pledge_payment'][0] = NULL;
try {
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
}
catch (CRM_Core_Exception $e) {
$this->assertEquals('Could not find payment processor for contribution record: 1', $e->getMessage());
}
$this->assertArrayNotHasKey('pledge_payment', $this->objects);

$this->ids['pledge_payment'][0] = '';

try {
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
$this->assertArrayHasKey('error_message', $result);
}
catch (CRM_Core_Exception $e) {
$this->assertEquals('Could not find payment processor for contribution record: 1', $e->getMessage());
}
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
$this->assertArrayNotHasKey('pledge_payment', $this->objects);

$this->ids['pledge_payment'][0] = 999;
Expand Down Expand Up @@ -368,12 +344,6 @@ public function testSendMailPledge() {
*/
public function testRequiredWithoutProcessorID() {
$this->_setUpPledgeObjects();
try {
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
}
catch (CRM_Core_Exception $e) {
$this->assertEquals('Could not find payment processor for contribution record: 1', $e->getMessage());
}
// error is only returned if $required set to True
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL);
$this->assertEquals(TRUE, $result);
Expand All @@ -390,21 +360,6 @@ public function testPaymentProcessorLoadsAsParam() {
$this->assertTrue($this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL));
}

/**
* Test that an error is returned if required set & contribution page exists
*/
public function testRequiredWithContributionPageError() {
$this->_setUpContributionObjects();
try {
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL);
}
catch (CRM_Core_Exception $e) {
$this->assertEquals('Could not find payment processor for contribution record: 1', $e->getMessage());
}
// error is only returned if $required set to True
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL);
}

public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
$this->_setUpParticipantObjects('Pending from incomplete transaction');
$additionalParticipantId = $this->participantCreate([
Expand Down

0 comments on commit c2d8f26

Please sign in to comment.