Skip to content

Commit

Permalink
Merge pull request #20411 from eileenmcnaughton/ppp2
Browse files Browse the repository at this point in the history
[REF] replace isFirst parameter
  • Loading branch information
eileenmcnaughton authored May 25, 2021
2 parents 8152f2d + f419011 commit c706f46
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ public function retrieve($name, $type, $location = 'POST', $abort = TRUE) {
* @param array $input
* @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, $recur, $contribution, $first) {
public function recur($input, $recur, $contribution) {
// check if first contribution is completed, else complete first contribution
$first = !$this->isContributionCompleted();
if (!isset($input['txnType'])) {
Civi::log()->debug('PayPalProIPN: Could not find txn_type in input request.');
echo 'Failure: Invalid parameters<p>';
Expand Down Expand Up @@ -518,9 +519,7 @@ public function main() {

if ($this->getContributionRecurID()) {
$contributionRecur = $this->getContributionRecurObject();
// check if first contribution is completed, else complete first contribution
$first = !$this->isContributionCompleted();
$this->recur($input, $contributionRecur, $contribution, $first);
$this->recur($input, $contributionRecur, $contribution);
return;
}

Expand Down Expand Up @@ -591,7 +590,6 @@ public function handlePaymentExpress() {
// http://stackoverflow.com/questions/4848227/validate-that-ipn-call-is-from-paypal
// as membership id etc can be derived by the load objects fn
$objects = $ids = $input = [];
$isFirst = FALSE;
$input['invoice'] = self::getValue('i', FALSE);
//Avoid return in case of unit test.
if (empty($input['invoice']) && empty($this->_inputParameters['is_unit_test'])) {
Expand Down Expand Up @@ -619,11 +617,6 @@ public function handlePaymentExpress() {

$this->setContributionID((int) $result['id']);
$ids['contribution'] = $this->getContributionID();
//@todo hardcoding 'pending' for now
$pendingStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
if ($result['contribution_status_id'] == $pendingStatusId) {
$isFirst = TRUE;
}
// arg api won't get this - fix it
$ids['contributionPage'] = CRM_Core_DAO::singleValueQuery("SELECT contribution_page_id FROM civicrm_contribution WHERE invoice_id = %1", [
1 => [
Expand Down Expand Up @@ -655,7 +648,7 @@ public function handlePaymentExpress() {
$contribution->loadRelatedObjects($input, $ids);
$objects = array_merge($objects, $contribution->_relatedObjects);

$this->recur($input, $this->getContributionRecurObject(), $objects['contribution'], $isFirst);
$this->recur($input, $this->getContributionRecurObject(), $objects['contribution']);
}

/**
Expand Down

0 comments on commit c706f46

Please sign in to comment.