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 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
case "RedirectShopper":
$payment->setAdditionalInformation('3dActive', true);
$issuerUrl = $response['redirect']['url'];
$paReq = $response['redirect']['data']['PaReq'];
$md = $response['redirect']['data']['MD'];
if (!empty($paReq) && !empty($md) && !empty($issuerUrl)) {
if (!empty($paReq = $response['redirect']['data']['PaReq']) &&
!empty($md = $response['redirect']['data']['MD']) &&
!empty($issuerUrl = $response['redirect']['url']) &&
!empty($paymentData = $response['paymentData'])
) {
$payment->setAdditionalInformation('issuerUrl', $issuerUrl);
$payment->setAdditionalInformation('paRequest', $paReq);
$payment->setAdditionalInformation('md', $md);
$payment->setAdditionalInformation('paymentData', $paymentData);
} else {
$isValid = false;
$errorMsg = __('3D secure is not valid.');
......
......@@ -96,11 +96,6 @@ class Data extends AbstractHelper
*/
protected $adyenLogger;
/**
* @var \Adyen\Service\ServiceFactory
*/
protected $adyenServiceFactory;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
......@@ -1257,7 +1252,7 @@ class Data extends AbstractHelper
$client = $this->initializeAdyenClient();
$service = $this->adyenServiceFactory->createCheckoutUtility($client);
$service = $this->createAdyenCheckoutUtilityService($client);
$respone = $service->originKeys($params);
if (empty($originKey = $respone['originKeys'][$url])) {
......@@ -1278,4 +1273,14 @@ class Data extends AbstractHelper
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
$this->_appState = $context->getAppState();
}
/**
* @param $storeId
* @return mixed
* @throws \Adyen\AdyenException
*/
private function createClient($storeId) {
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
return $client;
}
/**
* @param $payment
* @return mixed
......@@ -97,25 +87,23 @@ class PaymentRequest extends DataObject
{
$order = $payment->getOrder();
$storeId = $order->getStoreId();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$shopperIp = $order->getRemoteIp();
$md = $payment->getAdditionalInformation('md');
$paResponse = $payment->getAdditionalInformation('paResponse');
$paymentData = $payment->getAdditionalInformation('paymentData');
$browserInfo = ['userAgent' => $_SERVER['HTTP_USER_AGENT'], 'acceptHeader' => $_SERVER['HTTP_ACCEPT']];
$request = [
"merchantAccount" => $merchantAccount,
"browserInfo" => $browserInfo,
"md" => $md,
"paResponse" => $paResponse,
"shopperIP" => $shopperIp
"paymentData" => $paymentData,
"details" => [
"MD" => $md,
"PaRes" => $paResponse
]
];
try {
$client = $this->createClient($storeId);
$service = new \Adyen\Service\Payment($client);
$result = $service->authorise3D($request);
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = new \Adyen\Service\Checkout($client);
$result = $service->paymentsDetails($request);
} catch(\Adyen\AdyenException $e) {
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