dev/financial#152 Remove unreachable code
authoreileen <emcnaughton@wikimedia.org>
Sun, 11 Oct 2020 00:36:19 +0000 (13:36 +1300)
committereileen <emcnaughton@wikimedia.org>
Sun, 11 Oct 2020 00:36:19 +0000 (13:36 +1300)
This code cann only be reached if txnType is recurring_payment. Given that we can look
at the earlier switch and see that in that case first must be TRUE or it would have
already returned. Ergo this code is unreachable - and would have been
since the earlier code switched to using the api to handle non-firsts

CRM/Core/Payment/PayPalProIPN.php

index 613186cfae449b9f8b1320167f6666fb009f786c..0a92f88cdcdd1296c82946974cc20c11c5fa993a 100644 (file)
@@ -275,28 +275,6 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN {
       return;
     }
 
-    if (!$first) {
-      //check if this contribution transaction is already processed
-      //if not create a contribution and then get it processed
-      $contribution = new CRM_Contribute_BAO_Contribution();
-      $contribution->trxn_id = $input['trxn_id'];
-      if ($contribution->trxn_id && $contribution->find()) {
-        Civi::log()->debug('PayPalProIPN: Returning since contribution has already been handled.');
-        echo "Success: Contribution has already been handled<p>";
-        return;
-      }
-
-      $contribution->contact_id = $recur->contact_id;
-      $contribution->financial_type_id = $objects['contributionType']->id;
-      $contribution->contribution_page_id = $ids['contributionPage'];
-      $contribution->contribution_recur_id = $ids['contributionRecur'];
-      $contribution->currency = $objects['contribution']->currency;
-      $contribution->payment_instrument_id = $objects['contribution']->payment_instrument_id;
-      $contribution->amount_level = $objects['contribution']->amount_level;
-      $contribution->campaign_id = $objects['contribution']->campaign_id;
-      $objects['contribution'] = &$contribution;
-      $contribution->invoice_id = md5(uniqid(rand(), TRUE));
-    }
     // 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;