Add new paymentprocessor supportsX methods to replace remaining isSupported methods
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Mon, 3 Sep 2018 09:13:01 +0000 (10:13 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Thu, 13 Sep 2018 10:47:10 +0000 (11:47 +0100)
CRM/Contribute/Form/UpdateBilling.php
CRM/Contribute/Form/UpdateSubscription.php
CRM/Core/Payment.php
CRM/Member/Page/Tab.php

index 166050f676569eba4e5c098f674bd34f4377360f..da6604388bf00fad19eb5e2ab25220c113a38921 100644 (file)
@@ -95,7 +95,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form {
       $this->_selfService = TRUE;
     }
 
-    if (!$this->_paymentProcessor['object']->isSupported('updateSubscriptionBillingInfo')) {
+    if (!$this->_paymentProcessor['object']->supports('updateSubscriptionBillingInfo')) {
       CRM_Core_Error::fatal(ts("%1 processor doesn't support updating subscription billing details.",
         array(1 => $this->_paymentProcessor['object']->_processorName)
       ));
index 5f09e5c0fd4c9c3568f1dc30465c6c94122c44ff..6f8a080bda851a079b2e417606efa90ea84a9d40 100644 (file)
@@ -257,7 +257,7 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form {
 
     $params['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
     $updateSubscription = TRUE;
-    if ($this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
+    if ($this->_paymentProcessorObj->supports('changeSubscriptionAmount')) {
       $updateSubscription = $this->_paymentProcessorObj->changeSubscriptionAmount($message, $params);
     }
     if (is_a($updateSubscription, 'CRM_Core_Error')) {
index 13f506bcd118e2627c14e1fe5cb51e63362b139b..be6ee8c5e75decd41084bc7d5bdabd7f55d1fd19 100644 (file)
@@ -375,6 +375,18 @@ abstract class CRM_Core_Payment {
     return FALSE;
   }
 
+  /**
+   * Does this processor support updating billing info for recurring contributions through code.
+   *
+   * If the processor returns true then it must be possible to update billing info from within CiviCRM
+   * that will be updated at the payment processor.
+   *
+   * @return bool
+   */
+  protected function supportsUpdateSubscriptionBillingInfo() {
+    return method_exists(CRM_Utils_System::getClassName($this), 'updateSubscriptionBillingInfo');
+  }
+
   /**
    * Can recurring contributions be set against pledges.
    *
@@ -590,7 +602,7 @@ abstract class CRM_Core_Payment {
    * @return array
    */
   public function getEditableRecurringScheduleFields() {
-    if (method_exists($this, 'changeSubscriptionAmount')) {
+    if ($this->supports('changeSubscriptionAmount')) {
       return array('amount');
     }
   }
@@ -1453,7 +1465,7 @@ abstract class CRM_Core_Payment {
 
       case 'billing':
         //in notify mode don't return the update billing url
-        if (!$this->isSupported('updateSubscriptionBillingInfo')) {
+        if (!$this->supports('updateSubscriptionBillingInfo')) {
           return NULL;
         }
         $url = 'civicrm/contribute/updatebilling';
@@ -1504,7 +1516,7 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
     }
 
     // Else login URL
-    if ($this->isSupported('accountLoginURL')) {
+    if ($this->supports('accountLoginURL')) {
       return $this->accountLoginURL();
     }
 
@@ -1550,6 +1562,18 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
     return FALSE;
   }
 
+  /**
+   * Does this processor support changing the amount for recurring contributions through code.
+   *
+   * If the processor returns true then it must be possible to update the amount from within CiviCRM
+   * that will be updated at the payment processor.
+   *
+   * @return bool
+   */
+  protected function supportsChangeSubscriptionAmount() {
+    return method_exists(CRM_Utils_System::getClassName($this), 'changeSubscriptionAmount');
+  }
+
   /**
    * Checks if payment processor supports recurring contributions
    *
@@ -1562,6 +1586,17 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
     return FALSE;
   }
 
+  /**
+   * Checks if payment processor supports an account login URL
+   * TODO: This is checked by self::subscriptionURL but is only used if no entityID is found.
+   * TODO: It is implemented by AuthorizeNET, any others?
+   *
+   * @return bool
+   */
+  protected function supportsAccountLoginURL() {
+    return method_exists(CRM_Utils_System::getClassName($this), 'accountLoginURL');
+  }
+
   /**
    * Should a receipt be sent out for a pending payment.
    *
index a461dab701c2ae5c740d49ddcec2704a0f202079..ec5d77447d7689ccf6439549ede3e2d31cb8557a 100644 (file)
@@ -108,9 +108,7 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
         $paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity(
           $membership[$dao->id]['membership_id'], 'membership', 'obj');
         if (!empty($paymentObject)) {
-          // @todo - get this working with syntax style $paymentObject->supports(array
-          //('updateSubscriptionBillingInfo'));
-          $isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
+          $isUpdateBilling = $paymentObject->supports('updateSubscriptionBillingInfo');
         }
 
         // @todo - get this working with syntax style $paymentObject->supports(array