Merge branch 'onlyjob-master'
[civicrm-core.git] / CRM / Core / Payment / Elavon.php
index 493bfec62c5b5a60049b4f4475695e9464fdf0ae..bcbe845b7d158c060c079dd24e18b4bd8bf0dcf7 100644 (file)
@@ -37,7 +37,7 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment {
   static private $_singleton = NULL;
 
   /**
-   * Constructor
+   * Constructor.
    *
    * @param string $mode
    *   The mode of operation: live or test.
@@ -145,7 +145,7 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment {
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $requestFields);
 
     // Check to see if we have a duplicate before we send
-    if ($this->_checkDupe($params['invoiceID'])) {
+    if ($this->checkDupe($params['invoiceID'], CRM_Utils_Array::value('contributionID', $params))) {
       return self::errorExit(9003, 'It appears that this transaction is a duplicate.  Have you already submitted the form once?  If so there may have been a connection problem.  Check your email for a receipt.  If you do not receive a receipt within 2 hours you can try your transaction again.  If you continue to have problems please contact the site administrator.');
     }
 
@@ -260,22 +260,7 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment {
   }
 
   /**
-   * Checks to see if invoice_id already exists in db
-   *
-   * @param int $invoiceId
-   *   The ID to check.
-   *
-   * @return bool
-   *   True if ID exists, else false
-   */
-  public function _checkDupe($invoiceId) {
-    $contribution = new CRM_Contribute_DAO_Contribution();
-    $contribution->invoice_id = $invoiceId;
-    return $contribution->find();
-  }
-
-  /**
-   * Produces error message and returns from class
+   * Produces error message and returns from class.
    * @param string $errorCode
    * @param string $errorMessage
    * @return CRM_Core_Error
@@ -299,7 +284,7 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment {
   }
 
   /**
-   * This public function checks to see if we have the right processor config values set
+   * 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
    *  register any credit card details