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 84ecbcf8 authored by Rik ter Beek's avatar Rik ter Beek

Fixes #63 reactivate quote and show error message when 3D secure failed

parent cd6ecf87
...@@ -94,10 +94,13 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -94,10 +94,13 @@ class Validate3d extends \Magento\Framework\App\Action\Action
try { try {
$result = $order->getPayment()->getMethodInstance()->authorise3d($order->getPayment()); $result = $order->getPayment()->getMethodInstance()->authorise3d($order->getPayment());
} catch (Exception $e) { } catch (\Exception $e) {
$this->_adyenLogger->addAdyenResult("Process 3D secure payment was refused");
$result = 'Refused'; $result = 'Refused';
} }
$this->_adyenLogger->addAdyenResult("Process 3D secure payment result is: " . $result);
// check if authorise3d was successful // check if authorise3d was successful
if ($result == 'Authorised') { if ($result == 'Authorised') {
$order->addStatusHistoryComment(__('3D-secure validation was successful'))->save(); $order->addStatusHistoryComment(__('3D-secure validation was successful'))->save();
...@@ -105,6 +108,15 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -105,6 +108,15 @@ class Validate3d extends \Magento\Framework\App\Action\Action
} else { } else {
$order->addStatusHistoryComment(__('3D-secure validation was unsuccessful.'))->save(); $order->addStatusHistoryComment(__('3D-secure validation was unsuccessful.'))->save();
$this->_adyenHelper->cancelOrder($order); $this->_adyenHelper->cancelOrder($order);
$this->messageManager->addErrorMessage("3D-secure validation was unsuccessful");
// reactivate the quote
$session = $this->_getCheckout();
// restore the quote
$session->restoreQuote();
$this->_redirect('checkout/cart');
} }
} }
} else { } else {
......
...@@ -359,7 +359,7 @@ class PaymentRequest extends DataObject ...@@ -359,7 +359,7 @@ class PaymentRequest extends DataObject
try { try {
$service = new \Adyen\Service\Payment($this->_client); $service = new \Adyen\Service\Payment($this->_client);
$result = $service->authorise3D($request); $result = $service->authorise3D($request);
} catch(Exception $e) { } catch(\Adyen\AdyenException $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed')); throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed'));
} }
......
...@@ -387,7 +387,11 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -387,7 +387,11 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/ */
public function authorise3d($payment) public function authorise3d($payment)
{ {
$response = $this->_paymentRequest->authorise3d($payment); try {
$response = $this->_paymentRequest->authorise3d($payment);
} catch(\Exception $e) {
throw $e;
}
$responseCode = $response['resultCode']; $responseCode = $response['resultCode'];
return $responseCode; return $responseCode;
} }
......
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