return FALSE;
}
+ /**
+ * Checks to see if invoice_id already exists in db.
+ *
+ * It's arguable if this belongs in the payment subsystem at all but since several processors implement it
+ * it is better to standardise to being here.
+ *
+ * @param int $invoiceId The ID to check.
+ *
+ * @param null $contributionID
+ * If a contribution exists pass in the contribution ID.
+ *
+ * @return bool
+ * True if invoice ID otherwise exists, else false
+ */
+ protected function checkDupe($invoiceId, $contributionID = NULL) {
+ $contribution = new CRM_Contribute_DAO_Contribution();
+ $contribution->invoice_id = $invoiceId;
+ if ($contributionID) {
+ $contribution->whereAdd("id <> $contributionID");
+ }
+ return $contribution->find();
+ }
+
/**
* Get url for users to manage this recurring contribution for this processor.
*
}
// Authorize.Net will not refuse duplicates, so we should check if the user already submitted this transaction
- if ($this->_checkDupe($authorizeNetFields['x_invoice_num'])) {
+ if ($this->checkDupe($authorizeNetFields['x_invoice_num'], CRM_Utils_Array::value('contributionID', $params))) {
return self::error(9004, '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 from Authorize.net. 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.');
}
return $fields;
}
- /**
- * 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();
- }
-
/**
* Generate HMAC_MD5
*
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.');
}
}
}
- /**
- * 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.
* @param string $errorCode
//----------------------------------------------------------------------------------------------------
// 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 from eWAY. 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.');
}
//----------------------------------------------------------------------------------------------------
}
// end function doDirectPayment
- /**
- * 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.
*/
/*
* 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.');
}
return self::errorExit(9014, "Check the code - all transactions should have been headed off before they got here. Something slipped through the net");
}
- /**
- * 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) {
- //copied from Eway but not working and not really sure it should!
- $contribution = new CRM_Contribute_DAO_Contribution();
- $contribution->invoice_id = $invoiceId;
- return $contribution->find();
- }
-
/*
* Produces error message and returns from class
*/
/**********************************************************
* Check to see if we have a duplicate before we send
**********************************************************/
- if ($this->_checkDupe($this->_getParam('order_id'))) {
+ if ($this->checkDupe($params['invoiceID'], CRM_Utils_Array::value('contributionID', $params))) {
return self::error(9004, ts('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 from Authorize.net. 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.'));
}
return TRUE;
}
- /**
- * 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();
- }
-
/**
* Get the value of a field if set.
*
//----------------------------------------------------------------------------------------------------
// 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 from eWAY. 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.');
}
}
// end function doDirectPayment
- /**
- * 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();
- }
-
/**
* **********************************************************************************************
* This function checks the eWAY response status - returning a boolean false if status != 'true'