diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index 19b4bcec9c7f..f365683550fd 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -167,25 +167,29 @@ public function doDirectPayment(&$params) { curl_close($submit); $response_fields = $this->explode_csv($response); + + // fetch available contribution statuses + $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); + // check gateway MD5 response if (!$this->checkMD5($response_fields[37], $response_fields[6], $response_fields[9])) { + $params['payment_status_id'] = array_search('Failed', $contributionStatus); return self::error(9003, 'MD5 Verification failed'); } // check for application errors // TODO: // AVS, CVV2, CAVV, and other verification results - $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); switch ($response_fields[0]) { - case self::AUTH_REVIEW : + case self::AUTH_REVIEW: $params['payment_status_id'] = array_search('Pending', $contributionStatus); break; - case self::AUTH_ERROR : + case self::AUTH_ERROR: $params['payment_status_id'] = array_search('Failed', $contributionStatus); break; - case self::AUTH_DECLINED : + case self::AUTH_DECLINED: $errormsg = $response_fields[2] . ' ' . $response_fields[3]; return self::error($response_fields[1], $errormsg);