Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy check #19042

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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