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 9ab56f7e authored by attilak's avatar attilak

Move 3D secure to new checkout endpoint

Add Checkout utility factory into Helper\Data
parent 1cda5566
...@@ -97,14 +97,15 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -97,14 +97,15 @@ class CheckoutResponseValidator extends AbstractValidator
case "RedirectShopper": case "RedirectShopper":
$payment->setAdditionalInformation('3dActive', true); $payment->setAdditionalInformation('3dActive', true);
$issuerUrl = $response['redirect']['url']; if (!empty($paReq = $response['redirect']['data']['PaReq']) &&
$paReq = $response['redirect']['data']['PaReq']; !empty($md = $response['redirect']['data']['MD']) &&
$md = $response['redirect']['data']['MD']; !empty($issuerUrl = $response['redirect']['url']) &&
!empty($paymentData = $response['paymentData'])
if (!empty($paReq) && !empty($md) && !empty($issuerUrl)) { ) {
$payment->setAdditionalInformation('issuerUrl', $issuerUrl); $payment->setAdditionalInformation('issuerUrl', $issuerUrl);
$payment->setAdditionalInformation('paRequest', $paReq); $payment->setAdditionalInformation('paRequest', $paReq);
$payment->setAdditionalInformation('md', $md); $payment->setAdditionalInformation('md', $md);
$payment->setAdditionalInformation('paymentData', $paymentData);
} else { } else {
$isValid = false; $isValid = false;
$errorMsg = __('3D secure is not valid.'); $errorMsg = __('3D secure is not valid.');
......
...@@ -96,11 +96,6 @@ class Data extends AbstractHelper ...@@ -96,11 +96,6 @@ class Data extends AbstractHelper
*/ */
protected $adyenLogger; protected $adyenLogger;
/**
* @var \Adyen\Service\ServiceFactory
*/
protected $adyenServiceFactory;
/** /**
* @var \Magento\Store\Model\StoreManagerInterface * @var \Magento\Store\Model\StoreManagerInterface
*/ */
...@@ -127,7 +122,6 @@ class Data extends AbstractHelper ...@@ -127,7 +122,6 @@ class Data extends AbstractHelper
* @param \Magento\Tax\Model\Calculation $taxCalculation * @param \Magento\Tax\Model\Calculation $taxCalculation
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata * @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Service\ServiceFactory $adyenServiceFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\App\CacheInterface $cache
*/ */
...@@ -145,7 +139,6 @@ class Data extends AbstractHelper ...@@ -145,7 +139,6 @@ class Data extends AbstractHelper
\Magento\Tax\Model\Calculation $taxCalculation, \Magento\Tax\Model\Calculation $taxCalculation,
\Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\App\ProductMetadataInterface $productMetadata,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Service\ServiceFactory $adyenServiceFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\CacheInterface $cache \Magento\Framework\App\CacheInterface $cache
...@@ -163,7 +156,6 @@ class Data extends AbstractHelper ...@@ -163,7 +156,6 @@ class Data extends AbstractHelper
$this->_taxCalculation = $taxCalculation; $this->_taxCalculation = $taxCalculation;
$this->productMetadata = $productMetadata; $this->productMetadata = $productMetadata;
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->adyenServiceFactory = $adyenServiceFactory;
$this->storeManager = $storeManager; $this->storeManager = $storeManager;
$this->cache = $cache; $this->cache = $cache;
} }
...@@ -1242,7 +1234,7 @@ class Data extends AbstractHelper ...@@ -1242,7 +1234,7 @@ class Data extends AbstractHelper
$client = $this->initializeAdyenClient(); $client = $this->initializeAdyenClient();
$service = $this->adyenServiceFactory->createCheckoutUtility($client); $service = $this->createAdyenCheckoutUtilityService($client);
$respone = $service->originKeys($params); $respone = $service->originKeys($params);
if (empty($originKey = $respone['originKeys'][$url])) { if (empty($originKey = $respone['originKeys'][$url])) {
...@@ -1263,4 +1255,14 @@ class Data extends AbstractHelper ...@@ -1263,4 +1255,14 @@ class Data extends AbstractHelper
return self::CHECKOUT_CONTEXT_URL_LIVE; return self::CHECKOUT_CONTEXT_URL_LIVE;
} }
/**
* @param \Adyen\Clien $client
* @return \Adyen\Service\CheckoutUtility
* @throws \Adyen\AdyenException
*/
private function createAdyenCheckoutUtilityService($client)
{
return new \Adyen\Service\CheckoutUtility($client);
}
} }
...@@ -78,16 +78,6 @@ class PaymentRequest extends DataObject ...@@ -78,16 +78,6 @@ class PaymentRequest extends DataObject
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
} }
/**
* @param $storeId
* @return mixed
* @throws \Adyen\AdyenException
*/
private function createClient($storeId) {
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
return $client;
}
/** /**
* @param $payment * @param $payment
* @return mixed * @return mixed
...@@ -97,25 +87,23 @@ class PaymentRequest extends DataObject ...@@ -97,25 +87,23 @@ class PaymentRequest extends DataObject
{ {
$order = $payment->getOrder(); $order = $payment->getOrder();
$storeId = $order->getStoreId(); $storeId = $order->getStoreId();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$shopperIp = $order->getRemoteIp();
$md = $payment->getAdditionalInformation('md'); $md = $payment->getAdditionalInformation('md');
$paResponse = $payment->getAdditionalInformation('paResponse'); $paResponse = $payment->getAdditionalInformation('paResponse');
$paymentData = $payment->getAdditionalInformation('paymentData');
$browserInfo = ['userAgent' => $_SERVER['HTTP_USER_AGENT'], 'acceptHeader' => $_SERVER['HTTP_ACCEPT']];
$request = [ $request = [
"merchantAccount" => $merchantAccount, "paymentData" => $paymentData,
"browserInfo" => $browserInfo, "details" => [
"md" => $md, "MD" => $md,
"paResponse" => $paResponse, "PaRes" => $paResponse
"shopperIP" => $shopperIp ]
]; ];
try { try {
$client = $this->createClient($storeId); $client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = new \Adyen\Service\Payment($client); $service = new \Adyen\Service\Checkout($client);
$result = $service->authorise3D($request); $result = $service->paymentsDetails($request);
} catch(\Adyen\AdyenException $e) { } catch(\Adyen\AdyenException $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed')); throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed'));
} }
......
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