From 39fef483752476b12a14cfc4472588344c330d86 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 13 Jun 2020 14:28:47 +1200 Subject: [PATCH] dev/financial#131 Remove last places where Core Processors return error object --- CRM/Core/Payment/AuthorizeNet.php | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index 452db8125974..3b51574df153 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -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'], [ @@ -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 @@ -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)