We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 16ce9c74 authored by attilak's avatar attilak

Add error message into response in Transactions

Log these errors in the validators
parent 55617992
......@@ -82,6 +82,7 @@ class TransactionAuthorization implements ClientInterface
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
return $response;
}
}
......@@ -60,7 +60,7 @@ class TransactionCancel implements ClientInterface
try {
$response = $service->cancel($request);
} catch (\Adyen\AdyenException $e) {
$response = null;
$response['error'] = $e->getMessage();
}
return $response;
}
......
......@@ -60,10 +60,9 @@ class TransactionCapture implements ClientInterface
try {
$response = $service->capture($request);
} catch (\Adyen\AdyenException $e) {
$this->_adyenLogger->error($e); // add this for now not in the lib yet
$response = null;
$response['error'] = $e->getMessage();
}
return $response;
}
}
......@@ -63,7 +63,7 @@ class TransactionRefund implements ClientInterface
try {
$responses[] = $service->refund($request);
} catch (\Adyen\AdyenException $e) {
$responses[] = null;
$responses[] = array('error' => $e->getMessage());
}
}
return $responses;
......
......@@ -61,9 +61,14 @@ class CancelResponseValidator extends AbstractValidator
// The available response codes that the API can return in case of successfull cancellation
$expectedResponses = ['[cancelOrRefund-received]', '[cancel-received]'];
if (!in_array($response['response'], $expectedResponses)) {
if (empty($response['response']) || !in_array($response['response'], $expectedResponses)) {
$errorMsg = __('Error with cancellation');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
......
......@@ -58,9 +58,14 @@ class CaptureResponseValidator extends AbstractValidator
$isValid = true;
$errorMessages = [];
if ($response['response'] != '[capture-received]') {
if (empty($response['response']) || $response['response'] != '[capture-received]') {
$errorMsg = __('Error with capture');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
......
......@@ -67,7 +67,7 @@ class CheckoutResponseValidator extends AbstractValidator
$isValid = true;
$errorMessages = [];
// validate result
if (isset($response['resultCode'])) {
if (!empty($response['resultCode'])) {
switch ($response['resultCode']) {
case "IdentifyShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
......@@ -193,6 +193,11 @@ class CheckoutResponseValidator extends AbstractValidator
}
} else {
$errorMsg = __('Error with payment method please select different payment method.');
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
}
......
......@@ -68,7 +68,7 @@ class GeneralResponseValidator extends AbstractValidator
$errorMessages = [];
// validate result
if ($response && isset($response['resultCode'])) {
if (!empty($response['resultCode'])) {
switch ($response['resultCode']) {
case "Authorised":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
......@@ -139,9 +139,14 @@ class GeneralResponseValidator extends AbstractValidator
}
} else {
$errorMsg = __('Error with payment method please select different payment method.');
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
}
return $this->createResult($isValid, $errorMessages);
}
}
......@@ -59,9 +59,14 @@ class RefundResponseValidator extends AbstractValidator
$errorMessages = [];
foreach ($responses as $response) {
if ($response['response'] != '[refund-received]') {
if (empty($response['response']) || $response['response'] != '[refund-received]') {
$errorMsg = __('Error with refund');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment