Navigation Menu

Skip to content

Commit

Permalink
MAGETWO-99307: Authorize.net Transaction Fails but Order goes through
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjosiah committed Apr 22, 2019
1 parent 9312b47 commit dd7cb58
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Expand Up @@ -54,15 +54,15 @@ public function validate(array $validationSubject): ResultInterface
if (isset($transactionResponse['messages']['message']['code'])) {
$errorCodes[] = $transactionResponse['messages']['message']['code'];
$errorMessages[] = $transactionResponse['messages']['message']['text'];
} elseif ($transactionResponse['messages']['message']) {
} elseif (isset($transactionResponse['messages']['message'])) {
foreach ($transactionResponse['messages']['message'] as $message) {
$errorCodes[] = $message['code'];
$errorMessages[] = $message['description'];
}
} elseif (isset($transactionResponse['errors'])) {
foreach ($transactionResponse['errors'] as $message) {
$errorCodes[] = $message['errorCode'];
$errorMessages[] = $message['errorCode'];
$errorMessages[] = $message['errorText'];
}
}

Expand All @@ -85,8 +85,10 @@ private function isResponseCodeAnError(array $transactionResponse): bool
?? $transactionResponse['errors'][0]['errorCode']
?? null;

return in_array($transactionResponse['responseCode'], [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD])
&& $code
return !in_array($transactionResponse['responseCode'], [
self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD
])
|| $code
&& !in_array(
$code,
[
Expand Down
Expand Up @@ -19,9 +19,11 @@ class TransactionResponseValidatorTest extends TestCase
{
private const RESPONSE_CODE_APPROVED = 1;
private const RESPONSE_CODE_HELD = 4;
private const RESPONSE_CODE_DENIED = 2;
private const RESPONSE_REASON_CODE_APPROVED = 1;
private const RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED = 252;
private const RESPONSE_REASON_CODE_PENDING_REVIEW = 253;
private const ERROR_CODE_AVS_MISMATCH = 27;

/**
* @var ResultInterfaceFactory|MockObject
Expand Down Expand Up @@ -86,16 +88,6 @@ public function testValidateScenarios($transactionResponse, $isValid, $errorCode
public function scenarioProvider()
{
return [
// This validator only cares about successful edge cases so test for default behavior
[
[
'responseCode' => 'foo',
],
true,
[],
[]
],

// Test for acceptable reason codes
[
[
Expand Down Expand Up @@ -208,6 +200,29 @@ public function scenarioProvider()
['foo'],
['bar']
],
[
[
'responseCode' => self::RESPONSE_CODE_DENIED,
'errors' => [
[
'errorCode' => self::ERROR_CODE_AVS_MISMATCH,
'errorText' => 'bar'
]
]
],
false,
[self::ERROR_CODE_AVS_MISMATCH],
['bar']
],
// This validator only cares about successful edge cases so test for default behavior
[
[
'responseCode' => 'foo',
],
false,
[],
[]
],
];
}
}

0 comments on commit dd7cb58

Please sign in to comment.