Skip to content

Commit

Permalink
Merge pull request #19041 from eileenmcnaughton/ppp
Browse files Browse the repository at this point in the history
[REF] Stop passing objects to recur in paypal pro - pass specific objects
  • Loading branch information
eileenmcnaughton authored Nov 24, 2020
2 parents 69cb6ca + 62dda08 commit 7264109
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,22 @@ public function retrieve($name, $type, $location = 'POST', $abort = TRUE) {
*
* @param array $input
* @param array $ids
* @param array $objects
* @param \CRM_Contribute_BAO_ContributionRecur $recur
* @param \CRM_Contribute_BAO_Contribution $contribution
* @param bool $first
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function recur($input, $ids, $objects, $first) {
public function recur($input, $ids, $recur, $contribution, $first) {
if (!isset($input['txnType'])) {
Civi::log()->debug('PayPalProIPN: Could not find txn_type in input request.');
echo 'Failure: Invalid parameters<p>';
return;
}

$recur = &$objects['contributionRecur'];

// make sure the invoice ids match
// make sure the invoice is valid and matches what we have in
// the contribution record
Expand Down Expand Up @@ -276,13 +277,13 @@ public function recur($input, $ids, $objects, $first) {
}

// CRM-13737 - am not aware of any reason why payment_date would not be set - this if is a belt & braces
$objects['contribution']->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now;
$contribution->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now;

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

/**
Expand Down Expand Up @@ -460,7 +461,7 @@ public function main() {
if ($objects['contribution']->contribution_status_id == $completedStatusId) {
$first = FALSE;
}
$this->recur($input, $ids, $objects, $first);
$this->recur($input, $ids, $objects['contributionRecur'], $objects['contribution'], $first);
return;
}

Expand Down Expand Up @@ -621,7 +622,7 @@ public function handlePaymentExpress() {
if (!$this->loadObjects($input, $ids, $objects, TRUE, $paymentProcessorID)) {
throw new CRM_Core_Exception('Data did not validate');
}
$this->recur($input, $ids, $objects, $isFirst);
$this->recur($input, $ids, $objects['contributionRecur'], $objects['contribution'], $isFirst);
}

/**
Expand Down

0 comments on commit 7264109

Please sign in to comment.