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 87c72deb authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

[PW-2913] Adding redirect data builder to CC authorize requests (#799)

* [PW-2913] Adding redirect data builder to CC authorize requests

* Adding termUrl to redirect form

* Adding termUrl to redirect form

* Update Gateway/Validator/CheckoutResponseValidator.php
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* [PW-2913 ] Adjusting Redirect controller for new 3DS1 flow

* Removing redirect data builder from AdyenPaymentCcVaultAuthorizeRequest
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
parent b541b3f8
...@@ -470,14 +470,15 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -470,14 +470,15 @@ class Redirect extends \Magento\Payment\Block\Form
} }
/** /**
* @return string * @return mixed
*/ */
public function getTermUrl() public function getTermUrl()
{ {
return $this->getUrl( if ($termUrl = $this->getPayment()->getAdditionalInformation('termUrl')) {
'adyen/process/redirect', return $termUrl;
['_secure' => $this->_getRequest()->isSecure()] }
);
throw new AdyenException("No termUrl is provided.");
} }
/** /**
......
This diff is collapsed.
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2020 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
class RedirectDataBuilder implements BuilderInterface
{
/**
* @var \Magento\Framework\App\State
*/
private $appState;
/**
* @var \Adyen\Payment\Helper\Requests
*/
private $adyenRequestsHelper;
/**
* RedirectDataBuilder constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Adyen\Payment\Helper\Requests $adyenRequestsHelper
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Adyen\Payment\Helper\Requests $adyenRequestsHelper
) {
$this->appState = $context->getAppState();
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
/**
* @param array $buildSubject
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function build(array $buildSubject)
{
$request['body'] = $this->adyenRequestsHelper->buildRedirectData([]);
return $request;
}
}
...@@ -148,9 +148,14 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -148,9 +148,14 @@ class CheckoutResponseValidator extends AbstractValidator
} }
// If the redirect data is there then the payment is a card payment with 3d secure // If the redirect data is there then the payment is a card payment with 3d secure
if (isset($response['redirect']['data']['PaReq']) && isset($response['redirect']['data']['MD'])) { if (
isset($response['redirect']['data']['PaReq']) &&
isset($response['redirect']['data']['MD']) &&
isset($response['redirect']['data']['TermUrl'])
) {
$paReq = null; $paReq = null;
$md = null; $md = null;
$termUrl = null;
$payment->setAdditionalInformation('3dActive', true); $payment->setAdditionalInformation('3dActive', true);
...@@ -162,11 +167,16 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -162,11 +167,16 @@ class CheckoutResponseValidator extends AbstractValidator
$md = $response['redirect']['data']['MD']; $md = $response['redirect']['data']['MD'];
} }
if ($paReq && $md && $redirectUrl && $paymentData && $redirectMethod) { if (!empty($response['redirect']['data']['TermUrl'])) {
$termUrl = $response['redirect']['data']['TermUrl'];
}
if ($paReq && $md && $termUrl && $redirectUrl && $paymentData && $redirectMethod) {
$payment->setAdditionalInformation('redirectUrl', $redirectUrl); $payment->setAdditionalInformation('redirectUrl', $redirectUrl);
$payment->setAdditionalInformation('redirectMethod', $redirectMethod); $payment->setAdditionalInformation('redirectMethod', $redirectMethod);
$payment->setAdditionalInformation('paRequest', $paReq); $payment->setAdditionalInformation('paRequest', $paReq);
$payment->setAdditionalInformation('md', $md); $payment->setAdditionalInformation('md', $md);
$payment->setAdditionalInformation('termUrl', $termUrl);
$payment->setAdditionalInformation('paymentData', $paymentData); $payment->setAdditionalInformation('paymentData', $paymentData);
} else { } else {
$isValid = false; $isValid = false;
......
...@@ -341,6 +341,19 @@ class Requests extends AbstractHelper ...@@ -341,6 +341,19 @@ class Requests extends AbstractHelper
return $request; return $request;
} }
/**
* @param array $request
* @return array
*/
public function buildRedirectData($request = [])
{
$request['redirectFromIssuerMethod'] = 'GET';
$request['redirectToIssuerMethod'] = 'POST';
$request['returnUrl'] = $this->adyenHelper->getOrigin() . '/adyen/process/redirect';
return $request;
}
/** /**
* @param $request * @param $request
* @param $areaCode * @param $areaCode
......
...@@ -560,6 +560,7 @@ ...@@ -560,6 +560,7 @@
<item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\CcAuthorizationDataBuilder</item> <item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\CcAuthorizationDataBuilder</item>
<item name="vault" xsi:type="string">Adyen\Payment\Gateway\Request\VaultDataBuilder</item> <item name="vault" xsi:type="string">Adyen\Payment\Gateway\Request\VaultDataBuilder</item>
<item name="threeds2" xsi:type="string">Adyen\Payment\Gateway\Request\ThreeDS2DataBuilder</item> <item name="threeds2" xsi:type="string">Adyen\Payment\Gateway\Request\ThreeDS2DataBuilder</item>
<item name="redirect" xsi:type="string">Adyen\Payment\Gateway\Request\RedirectDataBuilder</item>
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
...@@ -607,6 +608,7 @@ ...@@ -607,6 +608,7 @@
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item> <item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item>
<item name="oneclick" xsi:type="string">Adyen\Payment\Gateway\Request\OneclickAuthorizationDataBuilder</item> <item name="oneclick" xsi:type="string">Adyen\Payment\Gateway\Request\OneclickAuthorizationDataBuilder</item>
<item name="threeds2" xsi:type="string">Adyen\Payment\Gateway\Request\ThreeDS2DataBuilder</item> <item name="threeds2" xsi:type="string">Adyen\Payment\Gateway\Request\ThreeDS2DataBuilder</item>
<item name="redirect" xsi:type="string">Adyen\Payment\Gateway\Request\RedirectDataBuilder</item>
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
......
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