Skip to content

Commit

Permalink
[REF] Switch to using getContributionRecurID function, remove now unu…
Browse files Browse the repository at this point in the history
…sed param

This is a follow up to civicrm#20294
- getContributionRecurID now always has the id so we don't need to pass it around
in the ids array
  • Loading branch information
eileenmcnaughton committed May 17, 2021
1 parent 27b1d20 commit 2d222eb
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function recur($input, $ids, $recur, $contribution, $first) {
$input['contribution_status_id'] = $contributionStatuses['Completed'];
$input['invoice_id'] = md5(uniqid(rand(), TRUE));
$input['original_contribution_id'] = $ids['contribution'];
$input['contribution_recur_id'] = $ids['contributionRecur'];
$input['contribution_recur_id'] = $this->getContributionRecurID();

civicrm_api3('Contribution', 'repeattransaction', $input);
return;
Expand Down Expand Up @@ -307,15 +307,11 @@ public function recur($input, $ids, $recur, $contribution, $first) {
// CRM-13737 - am not aware of any reason why payment_date would not be set - this if is a belt & braces
$contribution->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now;

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

/**
* @param array $input
* @param array $ids
* @param \CRM_Contribute_BAO_Contribution $contribution
* @param bool $recur
* @param bool $first
Expand All @@ -326,7 +322,7 @@ public function recur($input, $ids, $recur, $contribution, $first) {
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function single($input, $ids, $contribution, $recur = FALSE, $first = FALSE) {
public function single($input, $contribution, $recur = FALSE, $first = FALSE) {

// make sure the invoice is valid and matches what we have in the contribution record
if ((!$recur) || ($recur && $first)) {
Expand Down Expand Up @@ -385,7 +381,7 @@ public function single($input, $ids, $contribution, $recur = FALSE, $first = FAL
return;
}

CRM_Contribute_BAO_Contribution::completeOrder($input, $ids['contributionRecur'] ?? NULL, $contribution->id ?? NULL);
CRM_Contribute_BAO_Contribution::completeOrder($input, $this->getContributionRecurID(), $contribution->id ?? NULL);
}

/**
Expand Down Expand Up @@ -454,7 +450,7 @@ public function main() {
$ids['onbehalf_dupe_alert'] = self::retrieve('onBehalfDupeAlert', 'Integer', 'GET', FALSE);
}

if (!$ids['membership'] && $ids['contributionRecur']) {
if (!$ids['membership'] && $this->getContributionRecurID()) {
$sql = "
SELECT m.id
FROM civicrm_membership m
Expand All @@ -463,7 +459,7 @@ public function main() {
LIMIT 1";
$sqlParams = [
1 => [$ids['contribution'], 'Integer'],
2 => [$ids['contributionRecur'], 'Integer'],
2 => [$this->getContributionRecurID(), 'Integer'],
];
if ($membershipId = CRM_Core_DAO::singleValueQuery($sql, $sqlParams)) {
$ids['membership'] = $membershipId;
Expand Down Expand Up @@ -519,10 +515,7 @@ public function main() {
return;
}

$this->single($input, [
'participant' => $ids['participant'] ?? NULL,
'contributionRecur' => $ids['contributionRecur'] ?? NULL,
], $contribution, FALSE, FALSE);
$this->single($input, $contribution, FALSE, FALSE);
}
catch (CRM_Core_Exception $e) {
Civi::log()->debug($e->getMessage() . ' input {input}', ['input' => $input]);
Expand Down

0 comments on commit 2d222eb

Please sign in to comment.