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 now-unused ids parameter from signature #20299

Merged
merged 2 commits into from
May 14, 2021
Merged
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
43 changes: 29 additions & 14 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,19 @@ public function recur($input, $recur, $contribution, $first) {
return;
}

$this->single($input, [
'participant' => NULL,
'contributionRecur' => $recur->id,
], $contribution, TRUE);
$this->single($input, $contribution, TRUE);
}

/**
* @param array $input
* @param array $ids
* @param \CRM_Contribute_BAO_Contribution $contribution
* @param bool $recur
*
* @return void
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function single($input, $ids, $contribution, $recur = FALSE) {
public function single($input, $contribution, $recur = FALSE) {

// make sure the invoice is valid and matches what we have in the contribution record
if ($contribution->invoice_id != $input['invoice']) {
Expand Down Expand Up @@ -240,8 +236,8 @@ public function main() {
$component = $this->retrieve('module', 'String');
$input['component'] = $component;

$ids['contact'] = $this->retrieve('contactID', 'Integer', TRUE);
$contributionID = $ids['contribution'] = $this->retrieve('contributionID', 'Integer', TRUE);
$ids['contact'] = $this->getContactID();
$contributionID = $ids['contribution'] = $this->getContributionID();
$membershipID = $this->retrieve('membershipID', 'Integer', FALSE);

$this->getInput($input);
Expand Down Expand Up @@ -295,7 +291,7 @@ public function main() {
}
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $ids['contribution'];
$contribution->id = $this->getContributionID();
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)]);
}
Expand All @@ -305,7 +301,7 @@ public function main() {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contribution->contact_id;
$contact->find(TRUE);
if ($contact->id != $ids['contact']) {
if ($contact->id != $this->getContactID()) {
// If the ids do not match then it is possible the contact id in the IPN has been merged into another contact which is why we use the contact_id from the contribution
CRM_Core_Error::debug_log_message("Contact ID in IPN {$ids['contact']} not found but contact_id found in contribution {$contribution->contact_id} used instead");
echo "WARNING: Could not find contact record: {$ids['contact']}<p>";
Expand Down Expand Up @@ -374,10 +370,7 @@ public function main() {
Civi::log()->debug('Returning since contribution status is not handled');
return;
}
$this->single($input, [
'participant' => $ids['participant'] ?? NULL,
'contributionRecur' => $this->getContributionRecurID(),
], $contribution);
$this->single($input, $contribution);
}
catch (CRM_Core_Exception $e) {
Civi::log()->debug($e->getMessage() . ' input {input}', ['input' => $input]);
Expand Down Expand Up @@ -520,4 +513,26 @@ protected function getContributionRecurID(): ?int {
return $id ? (int) $id : NULL;
}

/**
* Get Contribution ID.
*
* @return int
*
* @throws \CRM_Core_Exception
*/
protected function getContributionID(): int {
return (int) $this->retrieve('contributionID', 'Integer', TRUE);
}

/**
* Get contact id from parameters.
*
* @return int
*
* @throws \CRM_Core_Exception
*/
protected function getContactID(): int {
return (int) $this->retrieve('contactID', 'Integer', TRUE);
}

}