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