Update Copywrite year to be 2019
[civicrm-core.git] / CRM / Core / Payment.php
index 25de4a781f4ef1fe1ce52ad47ac079ac41eb7361..952be8a5f34966850c4bd892c77743ce57e26dcc 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -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');
     }
   }
@@ -722,6 +734,7 @@ abstract class CRM_Core_Payment {
             'rule_parameters' => TRUE,
           ),
         ),
+        'extra' => ['class' => 'crm-form-select'],
       ),
       'credit_card_type' => array(
         'htmlType' => 'select',
@@ -1381,6 +1394,9 @@ abstract class CRM_Core_Payment {
       $extension_instance_found = TRUE;
     }
 
+    // Call IPN postIPNProcess hook to allow for custom processing of IPN data.
+    $IPNParams = array_merge($_GET, $_REQUEST);
+    CRM_Utils_Hook::postIPNProcess($IPNParams);
     if (!$extension_instance_found) {
       $message = "No extension instances of the '%1' payment processor were found.<br />" .
         "%2 method is unsupported in legacy payment processors.";
@@ -1454,7 +1470,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';
@@ -1505,7 +1521,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();
     }
 
@@ -1551,6 +1567,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
    *
@@ -1563,6 +1591,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.
    *