Merge pull request #5580 from eileenmcnaughton/CRM-16247
[civicrm-core.git] / CRM / Core / Payment.php
index 60a6e3550934774222d075c3d6e269400f5ea86f..2b665249af241e9c7c5d3ecfbc5b87835724720b 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -206,6 +206,27 @@ abstract class CRM_Core_Payment {
     }
   }
 
+  /**
+   * Getter for the payment processor.
+   *
+   * The payment processor array is based on the civicrm_payment_processor table entry.
+   *
+   * @return array
+   *   Payment processor array.
+   */
+  public function getPaymentProcessor() {
+    return $this->_paymentProcessor;
+  }
+
+  /**
+   * Setter for the payment processor.
+   *
+   * @param array $processor
+   */
+  public function setPaymentProcessor($processor) {
+    $this->_paymentProcessor = $processor;
+  }
+
   /**
    * Setter for the payment form that wants to use the processor.
    *
@@ -229,7 +250,9 @@ abstract class CRM_Core_Payment {
 
   /**
    * Getter for accessing member vars.
+   *
    * @todo believe this is unused
+   *
    * @param string $name
    *
    * @return null
@@ -318,6 +341,7 @@ abstract class CRM_Core_Payment {
           'size' => 20,
           'maxlength' => 20,
           'autocomplete' => 'off',
+          'class' => 'creditcard',
         ),
         'is_required' => TRUE,
       ),
@@ -452,8 +476,10 @@ abstract class CRM_Core_Payment {
   abstract protected function doDirectPayment(&$params);
 
   /**
-   * Process payment - this function wraps around both doTransferPayment and doDirectPayment
-   * it ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms more agnostic
+   * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
+   *
+   * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
+   * more agnostic.
    *
    * @param array $params
    *
@@ -486,8 +512,12 @@ abstract class CRM_Core_Payment {
   abstract protected function checkConfig();
 
   /**
+   * Redirect for paypal.
+   *
+   * @todo move to paypal class or remove
+   *
    * @param $paymentProcessor
-   * @todo move to paypal class or remover
+   *
    * @return bool
    */
   public static function paypalRedirect(&$paymentProcessor) {
@@ -507,6 +537,10 @@ abstract class CRM_Core_Payment {
   }
 
   /**
+   * Handle incoming payment notification.
+   *
+   * IPNs, also called silent posts are notifications of payment outcomes or activity on an external site.
+   *
    * @todo move to0 \Civi\Payment\System factory method
    * Page callback for civicrm/payment/ipn
    */
@@ -556,7 +590,10 @@ abstract class CRM_Core_Payment {
     else {
       // This is called when processor_name is passed - passing processor_id instead is recommended.
       $sql .= " WHERE ppt.name = %2 AND pp.is_test = %1";
-      $args[1] = array((CRM_Utils_Array::value('mode', $params) == 'test') ? 1 : 0, 'Integer');
+      $args[1] = array(
+        (CRM_Utils_Array::value('mode', $params) == 'test') ? 1 : 0,
+        'Integer',
+      );
       $args[2] = array($params['processor_name'], 'String');
       $notFound = "No active instances of the '{$params['processor_name']}' payment processor were found.";
     }
@@ -589,7 +626,7 @@ abstract class CRM_Core_Payment {
         }
       }
 
-      $processorInstance = $processorInstance = Civi\Payment\System::singleton()->getById($dao->processor_id);
+      $processorInstance = Civi\Payment\System::singleton()->getById($dao->processor_id);
 
       // Should never be empty - we already established this processor_id exists and is active.
       if (empty($processorInstance)) {