Skip to content

Commit

Permalink
Merge pull request #17597 from eileenmcnaughton/dopayment
Browse files Browse the repository at this point in the history
dev/financial#131 Remove last places where Core Processors return error object
  • Loading branch information
seamuslee001 authored Jun 14, 2020
2 parents bf9a04e + 39fef48 commit 28f4802
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions CRM/Core/Payment/AuthorizeNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function doDirectPayment(&$params) {

// Authorize.Net will not refuse duplicates, so we should check if the user already submitted this transaction
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.');
throw new PaymentProcessorException('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.', 9004);
}

$response = (string) $this->getGuzzleClient()->post($this->_paymentProcessor['url_site'], [
Expand All @@ -184,11 +184,11 @@ public function doDirectPayment(&$params) {
case self::AUTH_ERROR:
$params['payment_status_id'] = array_search('Failed', $contributionStatus);
$errormsg = $response_fields[2] . ' ' . $response_fields[3];
return self::error($response_fields[1], $errormsg);
throw new PaymentProcessorException($errormsg, $response_fields[1]);

case self::AUTH_DECLINED:
$errormsg = $response_fields[2] . ' ' . $response_fields[3];
return self::error($response_fields[1], $errormsg);
throw new PaymentProcessorException($errormsg, $response_fields[1]);

default:
// Success
Expand Down Expand Up @@ -543,23 +543,6 @@ public function _getParam($field, $xmlSafe = FALSE) {
return $value;
}

/**
* @param null $errorCode
* @param null $errorMessage
*
* @return object
*/
public function &error($errorCode = NULL, $errorMessage = NULL) {
$e = CRM_Core_Error::singleton();
if ($errorCode) {
$e->push($errorCode, 0, [], $errorMessage);
}
else {
$e->push(9001, 0, [], 'Unknown System Error.');
}
return $e;
}

/**
* Set a field to the specified value. Value must be a scalar (int,
* float, string, or boolean)
Expand Down

0 comments on commit 28f4802

Please sign in to comment.