We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 6d2c0b75 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #331 from Adyen/PW-636

PW-636 Move 3D secure to new checkout endpoint /payments/details
parents 81513233 9ab56f7e
...@@ -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
*/ */
...@@ -1257,7 +1252,7 @@ class Data extends AbstractHelper ...@@ -1257,7 +1252,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])) {
...@@ -1278,4 +1273,14 @@ class Data extends AbstractHelper ...@@ -1278,4 +1273,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