[REF] Minor auth.net ipn simplification
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 28 Jun 2021 02:03:56 +0000 (14:03 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 5 Jul 2021 22:34:43 +0000 (10:34 +1200)
This removes some property setting on the contribution
which is then discarded & moves a bit of validation to be
with the other validation

CRM/Core/Payment/AuthorizeNetIPN.php

index a2416e61d3195fb5e94f0495b9acec3e8343510d..cbc63cec2bc32c6025a3a40b4b7045f821111469 100644 (file)
@@ -74,6 +74,10 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
       if (!$contributionRecur->find(TRUE)) {
         throw new CRM_Core_Exception("Could not find contribution recur record: {$ids['ContributionRecur']} in IPN request: " . print_r($input, TRUE));
       }
+      // do a subscription check
+      if ($contributionRecur->processor_id != $input['subscription_id']) {
+        throw new CRM_Core_Exception('Unrecognized subscription.');
+      }
 
       // check if first contribution is completed, else complete first contribution
       $first = TRUE;
@@ -113,19 +117,10 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
    */
   public function recur($input, $recur, $contribution, $first) {
 
-    // do a subscription check
-    if ($recur->processor_id != $input['subscription_id']) {
-      throw new CRM_Core_Exception('Unrecognized subscription.');
-    }
-
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
 
     $now = date('YmdHis');
 
-    $contribution->invoice_id = md5(uniqid(rand(), TRUE));
-    $contribution->total_amount = $input['amount'];
-    $contribution->trxn_id = $input['trxn_id'];
-
     $isFirstOrLastRecurringPayment = FALSE;
     if ($input['response_code'] == 1) {
       // Approved