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

Release 6.5.0 (#807)

* Remove X-forwarded-for header and IP whitelisting/ HMAC is in different configuration (#784)

* Seperate the config ip check and hmac check

* Remove x-forwared-for

* Add explode to ipAddress array to fetch the first one

* Add config cache tag to origin keys cache (#781)

Changing the config (merchantAccount, sandbox mode, HMAC, etc) and
clearing the config cache will also clear the originKeys cache.

Fixes #777

* [PW-2567] Guest checkout tokenisation (#788)

* Add check to guest user

* Create the uuid with orderId

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

* remove the guest_checkout_tokenize from config.xml
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* avoid setting order state to NULL (#778)

This may happen when setting a status that is not default for a state.
Fixes Adyen/adyen-magento2#384
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* Fix swish payment methods when running it with the swish app (#793)

* For some payment methods like swish with resultCode pending we store this into the property adyenPaymentData instead of paymentData. Check if adyenPaymentData exists if so add this as paymentData in request. This will solve issues for Swish payment method. We need to refactor a lot of code to make everywhere to use consistency in the naming this will be a separate story to be picked up.

* Update Controller/Process/Result.php

* Update Controller/Process/Result.php

* Update Controller/Process/Result.php
Co-authored-by: default avatarAlessio Zampatti <alessio.zampatti@adyen.com>
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
Co-authored-by: default avatarAlessio Zampatti <alessio.zampatti@adyen.com>

* [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>

* Fixing tokenization typo (#803)

* Fetch country id from order address instead of country (#792)

OrderAddressInterface does not contain getCountry method
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* add setting for payment origin (for pwa integrations) (#786)

* add setting for payment origin (for pwa integrations)

* Improve payment origin field tooltip
Co-authored-by: default avatarÁngel Campos <acampos1916@gmail.com>

* Add missing parameter to getOrigin

Missing parameter $storeId in Helper/Data getOrigin to add external payment origin
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* Add @param to getOrigin docs

* Fix typo in field comment
Co-authored-by: default avatarAlessio Zampatti <gigendh@gmail.com>

* Add $storeId parameter to getOrigin call
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
Co-authored-by: default avatarÁngel Campos <acampos1916@gmail.com>
Co-authored-by: default avatarAlessio Zampatti <gigendh@gmail.com>

* use adyen helper to create adyen checkout service (#789)

This is just so we can use a plugin on `createAdyenCheckoutService` class, which we currently cannot do because of `new`.
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>

* 6.5.0 version bump

* Adding storeId param to getOrigin() calls (#806)
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
Co-authored-by: default avatarAlexandros Moraitis <alexandros.moraitis@adyen.com>
Co-authored-by: default avatarRichard Bayet <2353374+rbayet@users.noreply.github.com>
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
Co-authored-by: default avatarErmanno Baschiera <ebaschiera@gmail.com>
Co-authored-by: default avatarRik ter Beek <rikterbeek@users.noreply.github.com>
Co-authored-by: default avatarAlessio Zampatti <alessio.zampatti@adyen.com>
Co-authored-by: default avatarJeroen <jeroen@reachdigital.nl>
Co-authored-by: default avatarPablo Giralt <pablogiralt@gmail.com>
Co-authored-by: default avatarAlessio Zampatti <gigendh@gmail.com>
Co-authored-by: default avatarDaniel Sloof <goapsychadelic@gmail.com>
parent 3202b52c
...@@ -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.");
} }
/** /**
......
...@@ -205,7 +205,7 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -205,7 +205,7 @@ class Json extends \Magento\Framework\App\Action\Action
*/ */
protected function _processNotification($response, $notificationMode) protected function _processNotification($response, $notificationMode)
{ {
if ($this->configHelper->getNotificationsIpHmacCheck()) { if ($this->configHelper->getNotificationsIpCheck()) {
//Validate if the notification comes from a verified IP //Validate if the notification comes from a verified IP
if (!$this->isIpValid()) { if (!$this->isIpValid()) {
$this->_adyenLogger->addAdyenNotification( $this->_adyenLogger->addAdyenNotification(
...@@ -213,17 +213,21 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -213,17 +213,21 @@ class Json extends \Magento\Framework\App\Action\Action
); );
return false; return false;
} }
if ($this->configHelper->getNotificationsHmacCheck()) {
if ($this->hmacSignature->isHmacSupportedEventCode($response)) { if ($this->hmacSignature->isHmacSupportedEventCode($response)) {
//Validate the Hmac calculation //Validate the Hmac calculation
if (!$this->hmacSignature->isValidNotificationHMAC($this->configHelper->getNotificationsHmacKey(), if (!$this->hmacSignature->isValidNotificationHMAC(
$response)) { $this->configHelper->getNotificationsHmacKey(),
$this->_adyenLogger->addAdyenNotification('HMAC key validation failed ' . print_r($response, 1)); $response
)) {
$this->_adyenLogger->addAdyenNotification(
'HMAC key validation failed ' . print_r($response, 1)
);
return false; return false;
} }
} }
} }
}
// validate the notification // validate the notification
if ($this->authorised($response)) { if ($this->authorised($response)) {
// log the notification // log the notification
...@@ -347,18 +351,10 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -347,18 +351,10 @@ class Json extends \Magento\Framework\App\Action\Action
protected function isIpValid() protected function isIpValid()
{ {
$ipAddress = []; $ipAddress = [];
//Getting remote and possibly forwarded IP addresses //Getting remote and possibly forwarded IP addresses
if (!empty($_SERVER['REMOTE_ADDR'])) { if (!empty($_SERVER['REMOTE_ADDR'])) {
array_push($ipAddress, $_SERVER['REMOTE_ADDR']); $ipAddress = explode(',', $_SERVER['REMOTE_ADDR']);
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
array_push($ipAddress, $_SERVER['HTTP_X_FORWARDED_FOR']);
} }
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
array_push($ipAddress, $_SERVER['HTTP_CLIENT_IP']);
}
return $this->ipAddressHelper->isIpAddressValid($ipAddress); return $this->ipAddressHelper->isIpAddressValid($ipAddress);
} }
......
...@@ -155,14 +155,16 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -155,14 +155,16 @@ class Redirect extends \Magento\Framework\App\Action\Action
if ($active && $success != true) { if ($active && $success != true) {
$this->_adyenLogger->addAdyenResult("3D secure is active"); $this->_adyenLogger->addAdyenResult("3D secure is active");
// check if it is already processed // check if the GET request contains the required 3DS params
if ($this->getRequest()->isPost()) { if ($this->getRequest()->getParam('PaRes') && $this->getRequest()->getParam('MD')) {
$this->_adyenLogger->addAdyenResult("Process 3D secure payment"); $this->_adyenLogger->addAdyenResult("Process 3D secure payment");
$requestMD = $this->getRequest()->getPost('MD'); $requestMD = $this->getRequest()->getParam('MD');
$requestPaRes = $this->getRequest()->getPost('PaRes'); $requestPaRes = $this->getRequest()->getParam('PaRes');
$md = $order->getPayment()->getAdditionalInformation('md');
//Reset the payment's additional info to the new MD and PaRes
$order->getPayment()->setAdditionalInformation('md', $requestMD);
$order->getPayment()->setAdditionalInformation('paRequest', $requestPaRes);
if ($requestMD == $md) {
$order->getPayment()->setAdditionalInformation('paResponse', $requestPaRes); $order->getPayment()->setAdditionalInformation('paResponse', $requestPaRes);
try { try {
...@@ -245,7 +247,6 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -245,7 +247,6 @@ class Redirect extends \Magento\Framework\App\Action\Action
$this->_redirect($this->_adyenHelper->getAdyenAbstractConfigData('return_path')); $this->_redirect($this->_adyenHelper->getAdyenAbstractConfigData('return_path'));
} }
}
} else { } else {
$this->_adyenLogger->addAdyenResult("Customer was redirected to bank for 3D-secure validation."); $this->_adyenLogger->addAdyenResult("Customer was redirected to bank for 3D-secure validation.");
$order->addStatusHistoryComment( $order->addStatusHistoryComment(
......
...@@ -390,11 +390,29 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -390,11 +390,29 @@ class Result extends \Magento\Framework\App\Action\Action
$request = []; $request = [];
if (!empty($this->_session->getLastRealOrder()) && if (!empty($this->_session->getLastRealOrder()) &&
!empty($this->_session->getLastRealOrder()->getPayment()) && !empty($this->_session->getLastRealOrder()->getPayment())
!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("paymentData"))
) { ) {
if (!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation('paymentData'))) {
$request['paymentData'] = $this->_session->getLastRealOrder()->getPayment()->
getAdditionalInformation('paymentData');
// remove paymentData from db
$this->_session->getLastRealOrder()->getPayment()->unsAdditionalInformation('paymentData');
$this->_session->getLastRealOrder()->getPayment()->save();
}
// for pending payment that redirect we store this under adyenPaymentData
// TODO: refactor the code in the plugin that all paymentData is stored in paymentData and not in adyenPaymentData
if (!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation('adyenPaymentData'))) {
$request['paymentData'] = $this->_session->getLastRealOrder()->getPayment()-> $request['paymentData'] = $this->_session->getLastRealOrder()->getPayment()->
getAdditionalInformation("paymentData"); getAdditionalInformation("adyenPaymentData");
// remove paymentData from db
$this->_session->getLastRealOrder()->getPayment()->unsAdditionalInformation('adyenPaymentData');
$this->_session->getLastRealOrder()->getPayment()->save();
}
} else {
$this->_adyenLogger->addError("Can't load the order id from the session");
} }
$request["details"] = $response; $request["details"] = $response;
......
...@@ -157,8 +157,8 @@ class PayByMailCommand implements CommandInterface ...@@ -157,8 +157,8 @@ class PayByMailCommand implements CommandInterface
// if directory lookup is enabled use the billingadress as countrycode // if directory lookup is enabled use the billingadress as countrycode
if ($countryCode == false) { if ($countryCode == false) {
if (is_object($order->getBillingAddress()) && $order->getBillingAddress()->getCountry() != "") { if (is_object($order->getBillingAddress()) && $order->getBillingAddress()->getCountryId() != "") {
$countryCode = $order->getBillingAddress()->getCountry(); $countryCode = $order->getBillingAddress()->getCountryId();
} else { } else {
$countryCode = ""; $countryCode = "";
} }
......
...@@ -68,8 +68,7 @@ class TransactionPayment implements ClientInterface ...@@ -68,8 +68,7 @@ class TransactionPayment implements ClientInterface
} }
$client = $this->adyenHelper->initializeAdyenClient(); $client = $this->adyenHelper->initializeAdyenClient();
$service = $this->adyenHelper->createAdyenCheckoutService($client);
$service = new \Adyen\Service\Checkout($client);
$requestOptions = []; $requestOptions = [];
......
...@@ -63,11 +63,13 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -63,11 +63,13 @@ class RecurringDataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$storeId = $payment->getOrder()->getStoreId(); $storeId = $payment->getOrder()->getStoreId();
$areaCode = $this->appState->getAreaCode(); $areaCode = $this->appState->getAreaCode();
$customerId = $payment->getOrder()->getCustomerId();
$additionalInformation = $payment->getAdditionalInformation(); $additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildRecurringData( $request['body'] = $this->adyenRequestsHelper->buildRecurringData(
$areaCode, $areaCode,
$storeId, $storeId,
$additionalInformation, $additionalInformation,
$customerId,
[] []
); );
return $request; return $request;
......
<?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)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$storeId = $payment->getOrder()->getStoreId();
$request['body'] = $this->adyenRequestsHelper->buildRedirectData($storeId, []);
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;
......
...@@ -31,7 +31,8 @@ class Config ...@@ -31,7 +31,8 @@ class Config
const XML_PAYMENT_PREFIX = "payment"; const XML_PAYMENT_PREFIX = "payment";
const XML_ADYEN_ABSTRACT_PREFIX = "adyen_abstract"; const XML_ADYEN_ABSTRACT_PREFIX = "adyen_abstract";
const XML_NOTIFICATIONS_CAN_CANCEL_FIELD = "notifications_can_cancel"; const XML_NOTIFICATIONS_CAN_CANCEL_FIELD = "notifications_can_cancel";
const XML_NOTIFICATIONS_IP_HMAC_CHECK = "notifications_ip_hmac_check"; const XML_NOTIFICATIONS_HMAC_CHECK = "notifications_hmac_check";
const XML_NOTIFICATIONS_IP_CHECK = "notifications_ip_check";
const XML_NOTIFICATIONS_HMAC_KEY_LIVE = "notification_hmac_key_live"; const XML_NOTIFICATIONS_HMAC_KEY_LIVE = "notification_hmac_key_live";
const XML_NOTIFICATIONS_HMAC_KEY_TEST = "notification_hmac_key_test"; const XML_NOTIFICATIONS_HMAC_KEY_TEST = "notification_hmac_key_test";
...@@ -84,15 +85,31 @@ class Config ...@@ -84,15 +85,31 @@ class Config
} }
/** /**
* Retrieve flag for notifications_ip_hmac_check * Retrieve flag for notifications_hmac_check
* *
* @param int $storeId * @param int $storeId
* @return bool * @return bool
*/ */
public function getNotificationsIpHmacCheck($storeId = null) public function getNotificationsHmacCheck($storeId = null)
{ {
return (bool)$this->getConfigData( return (bool)$this->getConfigData(
self::XML_NOTIFICATIONS_IP_HMAC_CHECK, self::XML_NOTIFICATIONS_HMAC_CHECK,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* Retrieve flag for notifications_ip_check
*
* @param int $storeId
* @return bool
*/
public function getNotificationsIpCheck($storeId = null)
{
return (bool)$this->getConfigData(
self::XML_NOTIFICATIONS_IP_CHECK,
self::XML_ADYEN_ABSTRACT_PREFIX, self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId, $storeId,
true true
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
namespace Adyen\Payment\Helper; namespace Adyen\Payment\Helper;
use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Cache\Type\Config as ConfigCache;
use Adyen\Payment\Model\ApplicationInfo; use Adyen\Payment\Model\ApplicationInfo;
/** /**
...@@ -1040,6 +1041,11 @@ class Data extends AbstractHelper ...@@ -1040,6 +1041,11 @@ class Data extends AbstractHelper
return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId); return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId);
} }
public function isGuestTokenizationEnabled($storeId)
{
return $this->getAdyenOneclickConfigDataFlag('guest_checkout_tokenization', $storeId);
}
/** /**
* @param $paymentMethod * @param $paymentMethod
* @return bool * @return bool
...@@ -1535,10 +1541,14 @@ class Data extends AbstractHelper ...@@ -1535,10 +1541,14 @@ class Data extends AbstractHelper
} }
/** /**
* @param null|int|string $storeId
* @return string * @return string
*/ */
public function getOrigin() public function getOrigin($storeId)
{ {
if ( $paymentOriginUrl = $this->getAdyenAbstractConfigData("payment_origin_url", $storeId) ) {
return $paymentOriginUrl;
}
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get(\Magento\Framework\App\State::class); $state = $objectManager->get(\Magento\Framework\App\State::class);
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB); $baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
...@@ -1561,13 +1571,13 @@ class Data extends AbstractHelper ...@@ -1561,13 +1571,13 @@ class Data extends AbstractHelper
*/ */
public function getOriginKeyForBaseUrl() public function getOriginKeyForBaseUrl()
{ {
$origin = $this->getOrigin();
$storeId = $this->storeManager->getStore()->getId(); $storeId = $this->storeManager->getStore()->getId();
$origin = $this->getOrigin($storeId);
$cacheKey = 'Adyen_origin_key_for_' . $origin . '_' . $storeId; $cacheKey = 'Adyen_origin_key_for_' . $origin . '_' . $storeId;
if (!$originKey = $this->cache->load($cacheKey)) { if (!$originKey = $this->cache->load($cacheKey)) {
if ($originKey = $this->getOriginKeyForOrigin($origin, $storeId)) { if ($originKey = $this->getOriginKeyForOrigin($origin, $storeId)) {
$this->cache->save($originKey, $cacheKey, [], 60 * 60 * 24); $this->cache->save($originKey, $cacheKey, [ConfigCache::CACHE_TAG], 60 * 60 * 24);
} }
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
namespace Adyen\Payment\Helper; namespace Adyen\Payment\Helper;
use Adyen\Payment\Observer\AdyenOneclickDataAssignObserver; use Adyen\Payment\Observer\AdyenOneclickDataAssignObserver;
use Adyen\Util\Uuid;
use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Vault\Model\Ui\VaultConfigProvider; use Magento\Vault\Model\Ui\VaultConfigProvider;
...@@ -37,12 +38,12 @@ class Requests extends AbstractHelper ...@@ -37,12 +38,12 @@ class Requests extends AbstractHelper
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
private $adyenHelper; private $adyenHelper;
/** /**
* Requests constructor. * Requests constructor.
* *
* @param Data $adyenHelper * @param Data $adyenHelper
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper
) { ) {
...@@ -86,6 +87,11 @@ class Requests extends AbstractHelper ...@@ -86,6 +87,11 @@ class Requests extends AbstractHelper
if ($customerId > 0) { if ($customerId > 0) {
$request['shopperReference'] = $customerId; $request['shopperReference'] = $customerId;
} }
elseif ($this->adyenHelper->isGuestTokenizationEnabled($storeId)){
$uuid = Uuid::generateV4();
$guestCustomerId = $payment->getOrder()->getIncrementId() . $uuid;
$request['shopperReference'] = $guestCustomerId;
}
$paymentMethod = ''; $paymentMethod = '';
if ($payment) { if ($payment) {
...@@ -313,7 +319,7 @@ class Requests extends AbstractHelper ...@@ -313,7 +319,7 @@ class Requests extends AbstractHelper
{ {
if ($this->adyenHelper->isCreditCardThreeDS2Enabled($storeId)) { if ($this->adyenHelper->isCreditCardThreeDS2Enabled($storeId)) {
$request['additionalData']['allow3DS2'] = true; $request['additionalData']['allow3DS2'] = true;
$request['origin'] = $this->adyenHelper->getOrigin(); $request['origin'] = $this->adyenHelper->getOrigin($storeId);
$request['channel'] = 'web'; $request['channel'] = 'web';
$request['browserInfo']['screenWidth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_WIDTH]; $request['browserInfo']['screenWidth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_WIDTH];
$request['browserInfo']['screenHeight'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_HEIGHT]; $request['browserInfo']['screenHeight'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_HEIGHT];
...@@ -328,21 +334,39 @@ class Requests extends AbstractHelper ...@@ -328,21 +334,39 @@ class Requests extends AbstractHelper
} }
} else { } else {
$request['additionalData']['allow3DS2'] = false; $request['additionalData']['allow3DS2'] = false;
$request['origin'] = $this->adyenHelper->getOrigin(); $request['origin'] = $this->adyenHelper->getOrigin($storeId);
$request['channel'] = 'web'; $request['channel'] = 'web';
} }
return $request; return $request;
} }
/**
* @param array $request
* @return array
*/
public function buildRedirectData($storeId, $request = [])
{
$request['redirectFromIssuerMethod'] = 'GET';
$request['redirectToIssuerMethod'] = 'POST';
$request['returnUrl'] = $this->adyenHelper->getOrigin($storeId) . '/adyen/process/redirect';
return $request;
}
/** /**
* @param $request * @param $request
* @param $areaCode * @param $areaCode
* @param $storeId * @param $storeId
* @param $payment * @param $payment
*/ */
public function buildRecurringData($areaCode, int $storeId, $additionalData, $request = []) public function buildRecurringData($areaCode, int $storeId, $additionalData, $customerId, $request = [])
{ {
$isGuestUser = true;
if ($customerId > 0) {
$isGuestUser = false;
}
// If the vault feature is on this logic is handled in the VaultDataBuilder // If the vault feature is on this logic is handled in the VaultDataBuilder
if (!$this->adyenHelper->isCreditCardVaultEnabled()) { if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
if ($areaCode !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { if ($areaCode !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
...@@ -351,8 +375,7 @@ class Requests extends AbstractHelper ...@@ -351,8 +375,7 @@ class Requests extends AbstractHelper
$enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId); $enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId);
$enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId); $enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId);
if ($enableOneclick && !$isGuestUser) {
if ($enableOneclick) {
$request['enableOneClick'] = true; $request['enableOneClick'] = true;
} else { } else {
$request['enableOneClick'] = false; $request['enableOneClick'] = false;
...@@ -365,7 +388,7 @@ class Requests extends AbstractHelper ...@@ -365,7 +388,7 @@ class Requests extends AbstractHelper
} }
// value can be 0,1 or true // value can be 0,1 or true
if (!empty($additionalData[AdyenCcDataAssignObserver::STORE_CC])) { if (!empty($additionalData[AdyenCcDataAssignObserver::STORE_CC]) || ($isGuestUser && $this->adyenHelper->isGuestTokenizationEnabled($storeId))) {
$request['paymentMethod']['storeDetails'] = true; $request['paymentMethod']['storeDetails'] = true;
} }
} }
......
...@@ -1945,7 +1945,6 @@ class Cron ...@@ -1945,7 +1945,6 @@ class Cron
{ {
$statusObject = $this->_orderStatusCollection->create() $statusObject = $this->_orderStatusCollection->create()
->addFieldToFilter('main_table.status', $status) ->addFieldToFilter('main_table.status', $status)
->addFieldToFilter('state_table.is_default', true)
->joinStates() ->joinStates()
->getFirstItem(); ->getFirstItem();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "6.4.0", "version": "6.5.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
<include path="Adyen_Payment::system/adyen_boleto.xml"/> <include path="Adyen_Payment::system/adyen_boleto.xml"/>
<include path="Adyen_Payment::system/adyen_apple_pay.xml"/> <include path="Adyen_Payment::system/adyen_apple_pay.xml"/>
<include path="Adyen_Payment::system/adyen_google_pay.xml"/> <include path="Adyen_Payment::system/adyen_google_pay.xml"/>
<include path="Adyen_Payment::system/adyen_pwa.xml"/>
</group> </group>
</section> </section>
</system> </system>
......
...@@ -58,5 +58,10 @@ ...@@ -58,5 +58,10 @@
<config_path>payment/adyen_oneclick/share_billing_agreement</config_path> <config_path>payment/adyen_oneclick/share_billing_agreement</config_path>
</field> </field>
</group> </group>
<field id="guest_checkout_tokenization" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable guest checkout tokenization</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_oneclick/guest_checkout_tokenization</config_path>
</field>
</group> </group>
</include> </include>
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_pwa" translate="label" type="text" sortOrder="95" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Advanced: PWA]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<comment>
<![CDATA[
<p>
These settings are specific for PWA integrations
</p>
]]>
</comment>
<field id="payments_origin_url" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment Origin URL</label>
<tooltip>Only relevant if you process payments from an external URL different to that of Magento</tooltip>
<config_path>payment/adyen_abstract/payment_origin_url</config_path>
</field>
</group>
</include>
...@@ -33,19 +33,30 @@ ...@@ -33,19 +33,30 @@
</p> </p>
]]> ]]>
</comment> </comment>
<field id="notifications_ip_hmac_check" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="notifications_hmac_check" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Check notification's IP address and HMAC signature</label> <label>Check notification's HMAC signature</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/notifications_ip_hmac_check</config_path> <config_path>payment/adyen_abstract/notifications_hmac_check</config_path>
<comment> <comment>
<![CDATA[ <![CDATA[
If enabled notifications will be accepted only when the IP address matches Adyen's servers and the HMAC If enabled notifications will be accepted only when the HMAC
signature is verified. To learn more about these settings refer to signature is verified. To learn more about these settings refer to
<a target="_blank" href="https://docs.adyen.com/plugins/magento-2/set-up-the-plugin-in-magento">Adyen documentation</a>. <a target="_blank" href="https://docs.adyen.com/plugins/magento-2/set-up-the-plugin-in-magento">Adyen documentation</a>.
]]> ]]>
</comment> </comment>
</field> </field>
<field id="notification_hmac_key_test" translate="label" type="obscure" sortOrder="20" showInDefault="1" <field id="notifications_ip_check" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Check notification's IP address</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/notifications_ip_check</config_path>
<comment>
<![CDATA[
If enabled notifications will be accepted only when the IP address matches Adyen's servers. To learn more about these settings refer to
<a target="_blank" href="https://docs.adyen.com/plugins/magento-2/set-up-the-plugin-in-magento">Adyen documentation</a>.
]]>
</comment>
</field>
<field id="notification_hmac_key_test" translate="label" type="obscure" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1"> showInWebsite="1" showInStore="1">
<label>HMAC key test</label> <label>HMAC key test</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
...@@ -57,7 +68,7 @@ ...@@ -57,7 +68,7 @@
]]> ]]>
</tooltip> </tooltip>
</field> </field>
<field id="notification_hmac_key_live" translate="label" type="obscure" sortOrder="30" showInDefault="1" <field id="notification_hmac_key_live" translate="label" type="obscure" sortOrder="40" showInDefault="1"
showInWebsite="1" showInStore="1"> showInWebsite="1" showInStore="1">
<label>HMAC key live</label> <label>HMAC key live</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
......
...@@ -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>
...@@ -1050,7 +1052,8 @@ ...@@ -1050,7 +1052,8 @@
<item name="payment/adyen_abstract/debug" xsi:type="string">1</item> <item name="payment/adyen_abstract/debug" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/full_path_location_pem_file_test" xsi:type="string">1</item> <item name="payment/adyen_apple_pay/full_path_location_pem_file_test" xsi:type="string">1</item>
<item name="payment/adyen_apple_pay/full_path_location_pem_file_live" xsi:type="string">1</item> <item name="payment/adyen_apple_pay/full_path_location_pem_file_live" xsi:type="string">1</item>
<item name="payment/adyen_abstract/notifications_ip_hmac_check" xsi:type="string">1</item> <item name="payment/adyen_abstract/notifications_ip_check" xsi:type="string">1</item>
<item name="payment/adyen_abstract/notifications_hmac_check" xsi:type="string">1</item>
</argument> </argument>
<argument name="sensitive" xsi:type="array"> <argument name="sensitive" xsi:type="array">
<item name="payment/adyen_abstract/merchant_account" xsi:type="string">1</item> <item name="payment/adyen_abstract/merchant_account" xsi:type="string">1</item>
......
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