[Ref] Minor extraction
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 28 Aug 2021 02:32:38 +0000 (14:32 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 28 Aug 2021 02:32:38 +0000 (14:32 +1200)
Simply extracts getting the subscription id & since the retrieve function throws
defaults to 'abort' the next line is unreachable

CRM/Core/Payment/AuthorizeNetIPN.php

index 30886d1931314d25cdd4466fc0c58584fcfc905a..f6b2a102c0748cb1570a5fcec0cf7895c6df31ef 100644 (file)
@@ -43,11 +43,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN {
     try {
       //we only get invoice num as a key player from payment gateway response.
       //for ARB we get x_subscription_id and x_subscription_paynum
-      $x_subscription_id = $this->retrieve('x_subscription_id', 'String');
-      if (!$x_subscription_id) {
-        // Presence of the id means it is approved.
-        return TRUE;
-      }
+      $x_subscription_id = $this->getRecurProcessorID();
       $ids = $input = [];
 
       $input['component'] = 'contribute';
@@ -329,4 +325,18 @@ INNER JOIN civicrm_contribution co ON co.contribution_recur_id = cr.id
     ]);
   }
 
+  /**
+   * Get the processor_id for the recurring.
+   *
+   * This is the value stored in civicrm_contribution_recur.processor_id,
+   * sometimes called subscription_id.
+   *
+   * @return string
+   *
+   * @throws \CRM_Core_Exception
+   */
+  protected function getRecurProcessorID(): string {
+    return $this->retrieve('x_subscription_id', 'String');
+  }
+
 }