Merge pull request #4958 from pratikshad/code-cleanup-batch-19
[civicrm-core.git] / CRM / Core / Payment / FirstData.php
index ff83bbe9f4234390677eb6ed32bc8ab26bf74f90..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
-
- -----------------------------------------------------------------------------------------------
- **/
-
-/*From Payment processor documentation
-For testing purposes, you can use any of the card numbers listed below. The test card numbers
-will not result in any charges to the card. Use these card numbers with any expiration date in the
-future.
-     Visa Level 2 - 4275330012345675 (replies with a referral message)
-     JCB - 3566007770003510
-     Discover - 6011000993010978
-     MasterCard - 5424180279791765
-     Visa - 4005550000000019 or 4111111111111111
-     MasterCard Level 2 - 5404980000008386
-     Diners - 36555565010005
-     Amex - 372700997251009
-*
-***************************
-*Lines starting with CRM_Core_Error::debug_log_message output messages to files/upload/civicrm.log - you may with to comment them out once it is working satisfactorily
-
-*For live testing uncomment the result field below and set the value to the response you wish to get from the payment processor
-***************************/
+ * 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
+ * For testing purposes, you can use any of the card numbers listed below. The test card numbers
+ * will not result in any charges to the card. Use these card numbers with any expiration date in the
+ * future.
+ *      Visa Level 2 - 4275330012345675 (replies with a referral message)
+ *      JCB - 3566007770003510
+ *      Discover - 6011000993010978
+ *      MasterCard - 5424180279791765
+ *      Visa - 4005550000000019 or 4111111111111111
+ *      MasterCard Level 2 - 5404980000008386
+ *      Diners - 36555565010005
+ *      Amex - 372700997251009
+ *
+ * **************************
+ * Lines starting with CRM_Core_Error::debug_log_message output messages to files/upload/civicrm.log - you may with to comment them out once it is working satisfactorily
+ *
+ * For live testing uncomment the result field below and set the value to the response you wish to get from the payment processor
+ * **************************
+ */
 class CRM_Core_Payment_FirstData extends CRM_Core_Payment {
   # (not used, implicit in the API, might need to convert?)
   const CHARSET = 'UFT-8';
@@ -58,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
@@ -79,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
          */
@@ -163,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)));
@@ -330,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();
@@ -338,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();
 
@@ -353,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
@@ -371,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();