Merge pull request #4958 from pratikshad/code-cleanup-batch-19
[civicrm-core.git] / CRM / Core / Payment / FirstData.php
index a0d106d585073761e45644a5e313d671a2befb5b..089838d49e7cea29ad90b0fdf5b83f68a797ad67 100644 (file)
 */
 
 /**
- Note that in order to use FirstData / LinkPoint you need a certificate (.pem) file issued by them
- and a store number. You can configure the path to the certificate and the store number
- through the front end of civiCRM. The path is as seen by the server not the url
- -----------------------------------------------------------------------------------------------
- The basic functionality of this processor is that variables from the $params object are transformed
- into xml using a function provided by the processor. The xml is submitted to the processor's https site
- using curl and the response is translated back into an array using the processor's function.
-
- If an array ($params) is returned to the calling function it is treated as a success and the values from
- the array are merged into the calling functions array.
-
- If an result of class error is returned it is treated as a failure
-
- -----------------------------------------------------------------------------------------------
- **/
Note that in order to use FirstData / LinkPoint you need a certificate (.pem) file issued by them
and a store number. You can configure the path to the certificate and the store number
through the front end of civiCRM. The path is as seen by the server not the url
-----------------------------------------------------------------------------------------------
The basic functionality of this processor is that variables from the $params object are transformed
into xml using a function provided by the processor. The xml is submitted to the processor's https site
using curl and the response is translated back into an array using the processor's function.
+ *
If an array ($params) is returned to the calling function it is treated as a success and the values from
the array are merged into the calling functions array.
+ *
If an result of class error is returned it is treated as a failure
+ *
-----------------------------------------------------------------------------------------------
+ */
 
 /**
  * From Payment processor documentation
@@ -60,11 +60,10 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
    * pattern and cache the instance in this variable
    *
    * @var object
-   * @static
    */
   static private $_singleton = NULL;
 
-  /**********************************************************
+  /**
    * Constructor
    *
    * @param string $mode
@@ -81,36 +80,11 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
   }
 
   /**
-   * Singleton function used to manage this object
-   *
-   * @param string $mode
-   *   The mode of operation: live or test.
-   *
-   * @param object $paymentProcessor
-   *
-   * @return object
-   * @static
-   */
-  public static function &singleton($mode, &$paymentProcessor) {
-    if (!empty($paymentProcessor['id'])) {
-      $cacheKey = $paymentProcessor['id'];
-    }
-    else {
-      //@todo eliminated instances of this in favour of id-specific instances.
-      $cacheKey = $mode . '_' . $paymentProcessor['name'];
-    }
-    if (self::$_singleton[$cacheKey] === NULL) {
-      self::$_singleton[$cacheKey] = new CRM_Core_Payment_FirstData($mode, $paymentProcessor);
-    }
-    return self::$_singleton[$cacheKey];
-  }
-
-  /**********************************************************
    * This function is set up and put here to make the mapping of fields
    * from the params object  as visually clear as possible for easy editing
    *
    *  Comment out irrelevant fields
-   **********************************************************/
+   */
   public function mapProcessorFieldstoParams($params) {
     /*concatenate full customer name first  - code from EWAY gateway
          */
@@ -165,10 +139,10 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
     return $requestFields;
   }
 
-  /**********************************************************
+  /**
    * This function sends request and receives response from
    * the processor
-   **********************************************************/
+   */
   public function doDirectPayment(&$params) {
     if ($params['is_recur'] == TRUE) {
       CRM_Core_Error::fatal(ts('%1 - recurring payments not implemented', array(1 => $paymentProcessor)));
@@ -332,7 +306,8 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
    * @param int $invoiceId
    *   The ID to check.
    *
-   * @return bool                  True if ID exists, else false
+   * @return bool
+   *   True if ID exists, else false
    */
   public function _checkDupe($invoiceId) {
     $contribution = new CRM_Contribute_DAO_Contribution();
@@ -340,9 +315,9 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
     return $contribution->find();
   }
 
-  /**************************************************
+  /**
    * Produces error message and returns from class
-   **************************************************/
+   */
   public function &errorExit($errorCode = NULL, $errorMessage = NULL) {
     $e = CRM_Core_Error::singleton();
 
@@ -355,14 +330,14 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
     return $e;
   }
 
-  /**************************************************
+  /**
    * NOTE: 'doTransferCheckout' not implemented
-   **************************************************/
+   */
   public function doTransferCheckout(&$params, $component) {
     CRM_Core_Error::fatal(ts('This function is not implemented'));
   }
 
-  /********************************************************************************************
+  /**
    * This public function checks to see if we have the right processor config values set
    *
    * NOTE: Called by Events and Contribute to check config params are set prior to trying
@@ -373,10 +348,9 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
    *
    * returns string $errorMsg if any errors found - null if OK
    *
-   ******************************************************************************************
+   *  function checkConfig( $mode )           CiviCRM V1.9 Declaration
+   * CiviCRM V2.0 Declaration
    */
-  //  function checkConfig( $mode )          // CiviCRM V1.9 Declaration
-  // CiviCRM V2.0 Declaration
   public function checkConfig() {
     $errorMsg = array();