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 625246a1 authored by Alexandros Moraitis's avatar Alexandros Moraitis Committed by GitHub

Merge pull request #518 from Adyen/develop

Release 4.5.0
parents 050b260d 39a88064
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Api;
interface AdyenOriginKeyInterface
{
/**
* @return string
*/
public function getOriginKey();
}
\ No newline at end of file
...@@ -255,7 +255,7 @@ interface NotificationInterface ...@@ -255,7 +255,7 @@ interface NotificationInterface
* @param string $additionalData * @param string $additionalData
* @return $this * @return $this
*/ */
public function setAddtionalData($additionalData); public function setAdditionalData($additionalData);
/** /**
* Gets the Done for the notification. * Gets the Done for the notification.
......
...@@ -52,23 +52,31 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -52,23 +52,31 @@ class Json extends \Magento\Framework\App\Action\Action
*/ */
protected $_adyenLogger; protected $_adyenLogger;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* Json constructor. * Json constructor.
* *
* @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_objectManager = $context->getObjectManager(); $this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory(); $this->_resultFactory = $context->getResultFactory();
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->serializer = $serializer;
// Fix for Magento2.3 adding isAjax to the request params // Fix for Magento2.3 adding isAjax to the request params
if(interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) { if(interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
...@@ -214,7 +222,7 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -214,7 +222,7 @@ class Json extends \Magento\Framework\App\Action\Action
$notification->setLive($notificationMode); $notification->setLive($notificationMode);
if (isset($response['additionalData'])) { if (isset($response['additionalData'])) {
$notification->setAddtionalData(serialize($response['additionalData'])); $notification->setAdditionalData($this->serializer->serialize($response['additionalData']));
} }
if (isset($response['done'])) { if (isset($response['done'])) {
$notification->setDone($response['done']); $notification->setDone($response['done']);
......
...@@ -77,24 +77,35 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -77,24 +77,35 @@ class Redirect extends \Magento\Framework\App\Action\Action
* @var PaymentTokenFactoryInterface * @var PaymentTokenFactoryInterface
*/ */
private $paymentTokenFactory; private $paymentTokenFactory;
/** /**
* @var OrderPaymentExtensionInterfaceFactory * @var OrderPaymentExtensionInterfaceFactory
*/ */
private $paymentExtensionFactory; private $paymentExtensionFactory;
/** /**
* @var OrderPaymentResource * @var OrderPaymentResource
*/ */
private $orderPaymentResource; private $orderPaymentResource;
/** /**
* Redirect constructor. * @var \Magento\Framework\Serialize\SerializerInterface
* */
* @param \Magento\Framework\App\Action\Context $context private $serializer;
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper /**
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest * Redirect constructor.
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository *
*/ * @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
* @param OrderPaymentResource $orderPaymentResource
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
...@@ -103,7 +114,8 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -103,7 +114,8 @@ class Redirect extends \Magento\Framework\App\Action\Action
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
PaymentTokenFactoryInterface $paymentTokenFactory, PaymentTokenFactoryInterface $paymentTokenFactory,
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
OrderPaymentResource $orderPaymentResource OrderPaymentResource $orderPaymentResource,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -113,6 +125,7 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -113,6 +125,7 @@ class Redirect extends \Magento\Framework\App\Action\Action
$this->paymentTokenFactory = $paymentTokenFactory; $this->paymentTokenFactory = $paymentTokenFactory;
$this->paymentExtensionFactory = $paymentExtensionFactory; $this->paymentExtensionFactory = $paymentExtensionFactory;
$this->orderPaymentResource = $orderPaymentResource; $this->orderPaymentResource = $orderPaymentResource;
$this->serializer = $serializer;
if (interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) { if (interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
$request = $this->getRequest(); $request = $this->getRequest();
if ($request instanceof Http && $request->isPost()) { if ($request instanceof Http && $request->isPost()) {
...@@ -198,9 +211,9 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -198,9 +211,9 @@ class Redirect extends \Magento\Framework\App\Action\Action
$extensionAttributes = $this->getExtensionAttributes($order->getPayment()); $extensionAttributes = $this->getExtensionAttributes($order->getPayment());
$extensionAttributes->setVaultPaymentToken($paymentToken); $extensionAttributes->setVaultPaymentToken($paymentToken);
$orderPayment = $order->getPayment()->setExtensionAttributes($extensionAttributes); $orderPayment = $order->getPayment()->setExtensionAttributes($extensionAttributes);
$add = unserialize($orderPayment->getAdditionalData()); $add = $this->serializer->unserialize($orderPayment->getAdditionalData());
$add['force_save'] = true; $add['force_save'] = true;
$orderPayment->setAdditionalData(serialize($add)); $orderPayment->setAdditionalData($this->serializer->serialize($add));
$this->orderPaymentResource->save($orderPayment); $this->orderPaymentResource->save($orderPayment);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->_adyenLogger->error((string)$e->getMessage()); $this->_adyenLogger->error((string)$e->getMessage());
......
...@@ -140,6 +140,13 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -140,6 +140,13 @@ class CheckoutDataBuilder implements BuilderInterface
$request = array_merge($request, $openInvoiceFields); $request = array_merge($request, $openInvoiceFields);
} }
// Ratepay specific Fingerprint
if ($payment->getAdditionalInformation("df_value") && $this->adyenHelper->isPaymentMethodRatepayMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)) {
$request['deviceFingerprint'] = $payment->getAdditionalInformation("df_value");
}
//Boleto data //Boleto data
if ($payment->getAdditionalInformation("social_security_number")) { if ($payment->getAdditionalInformation("social_security_number")) {
$request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number"); $request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
......
...@@ -52,8 +52,8 @@ class CustomerIpDataBuilder implements BuilderInterface ...@@ -52,8 +52,8 @@ class CustomerIpDataBuilder implements BuilderInterface
{ {
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder(); $shopperIp = $paymentDataObject->getPayment()->getOrder()->getXForwardedFor();
return $this->adyenRequestsHelper->buildCustomerIpData([], $order->getRemoteIp()); return $this->adyenRequestsHelper->buildCustomerIpData([], $shopperIp);
} }
} }
...@@ -44,22 +44,30 @@ class InstallmentValidator extends AbstractValidator ...@@ -44,22 +44,30 @@ class InstallmentValidator extends AbstractValidator
*/ */
private $session; private $session;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* InstallmentValidator constructor. * InstallmentValidator constructor.
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory * @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\ObjectManager $objectManager * @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/ */
public function __construct( public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory, \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $session \Magento\Checkout\Model\Session $session,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->session = $session; $this->session = $session;
$this->serializer = $serializer;
parent::__construct($resultFactory); parent::__construct($resultFactory);
} }
...@@ -77,7 +85,7 @@ class InstallmentValidator extends AbstractValidator ...@@ -77,7 +85,7 @@ class InstallmentValidator extends AbstractValidator
$installmentSelected = $payment->getAdditionalInformation('number_of_installments'); $installmentSelected = $payment->getAdditionalInformation('number_of_installments');
$ccType = $payment->getAdditionalInformation('cc_type'); $ccType = $payment->getAdditionalInformation('cc_type');
if ($installmentsAvailable) { if ($installmentsAvailable) {
$installments = unserialize($installmentsAvailable); $installments = $this->serializer->unserialize($installmentsAvailable);
} }
if ($installmentSelected && $installmentsAvailable) { if ($installmentSelected && $installmentsAvailable) {
$isValid = false; $isValid = false;
......
...@@ -131,6 +131,10 @@ class Data extends AbstractHelper ...@@ -131,6 +131,10 @@ class Data extends AbstractHelper
*/ */
private $helperBackend; private $helperBackend;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* Data constructor. * Data constructor.
...@@ -154,6 +158,7 @@ class Data extends AbstractHelper ...@@ -154,6 +158,7 @@ class Data extends AbstractHelper
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Backend\Helper\Data $helperBackend * @param \Magento\Backend\Helper\Data $helperBackend
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Helper\Context $context,
...@@ -175,7 +180,8 @@ class Data extends AbstractHelper ...@@ -175,7 +180,8 @@ class Data extends AbstractHelper
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel, \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Backend\Helper\Data $helperBackend \Magento\Backend\Helper\Data $helperBackend,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
...@@ -197,6 +203,7 @@ class Data extends AbstractHelper ...@@ -197,6 +203,7 @@ class Data extends AbstractHelper
$this->localeResolver = $localeResolver; $this->localeResolver = $localeResolver;
$this->config = $config; $this->config = $config;
$this->helperBackend = $helperBackend; $this->helperBackend = $helperBackend;
$this->serializer = $serializer;
} }
/** /**
...@@ -955,7 +962,7 @@ class Data extends AbstractHelper ...@@ -955,7 +962,7 @@ class Data extends AbstractHelper
$installments = null; $installments = null;
$installmentsValue = $this->getAdyenCcConfigData('installments'); $installmentsValue = $this->getAdyenCcConfigData('installments');
if ($installmentsValue) { if ($installmentsValue) {
$installments = unserialize($installmentsValue); $installments = $this->serializer->unserialize($installmentsValue);
} }
if ($installments) { if ($installments) {
...@@ -1003,6 +1010,19 @@ class Data extends AbstractHelper ...@@ -1003,6 +1010,19 @@ class Data extends AbstractHelper
return false; return false;
} }
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodRatepayMethod($paymentMethod)
{
if (strpos($paymentMethod, 'ratepay') !== false) {
return true;
}
return false;
}
/** /**
* @param $paymentMethod * @param $paymentMethod
* @return bool * @return bool
......
...@@ -67,12 +67,15 @@ class Requests extends AbstractHelper ...@@ -67,12 +67,15 @@ class Requests extends AbstractHelper
} }
/** /**
* @param $request * @param array $request
* @param int $customerId * @param int $customerId
* @param $billingAddress * @param $billingAddress
* @return mixed * @param $storeId
* @param null $payment
* @param null $payload
* @return array
*/ */
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null) public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null, $payload = null)
{ {
if ($customerId > 0) { if ($customerId > 0) {
$request['shopperReference'] = $customerId; $request['shopperReference'] = $customerId;
...@@ -83,6 +86,17 @@ class Requests extends AbstractHelper ...@@ -83,6 +86,17 @@ class Requests extends AbstractHelper
$paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE); $paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
} }
// In case of virtual product and guest checkout there is a workaround to get the guest's email address
if (!empty($payload['additional_data']['guestEmail'])) {
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
!$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $payload['additional_data']['guestEmail'];
} else {
$request['shopperEmail'] = $payload['additional_data']['guestEmail'];
}
}
if (!empty($billingAddress)) { if (!empty($billingAddress)) {
// Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format // Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) && if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
...@@ -423,14 +437,16 @@ class Requests extends AbstractHelper ...@@ -423,14 +437,16 @@ class Requests extends AbstractHelper
*/ */
public function buildVaultData($request = [], $payload) public function buildVaultData($request = [], $payload)
{ {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE]) && if ($this->adyenHelper->isCreditCardVaultEnabled()) {
$payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE] === true if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE]) &&
) { $payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE] === true
// store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail ) {
$request['enableRecurring'] = true; // store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail
} else { $request['enableRecurring'] = true;
// explicity turn this off as merchants have recurring on by default } else {
$request['enableRecurring'] = false; // explicity turn this off as merchants have recurring on by default
$request['enableRecurring'] = false;
}
} }
return $request; return $request;
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\AdyenException;
use Adyen\Payment\Helper\Data as AdyenHelper;
use Magento\Framework\Exception\NoSuchEntityException as MagentoNoSuchEntityException;
class AdyenOriginKey implements \Adyen\Payment\Api\AdyenOriginKeyInterface
{
/**
* @var AdyenHelper
*/
private $helper;
public function __construct(AdyenHelper $helper)
{
$this->helper = $helper;
}
/**
* {@inheritDoc}
* @throws MagentoNoSuchEntityException
* @throws AdyenException
*/
public function getOriginKey()
{
return $this->helper->getOriginKeyForBaseUrl();
}
}
\ No newline at end of file
...@@ -131,10 +131,10 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface ...@@ -131,10 +131,10 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Customer data builder // Customer data builder
$customerId = $quote->getCustomerId(); $customerId = $quote->getCustomerId();
$billingAddress = $quote->getBillingAddress(); $billingAddress = $quote->getBillingAddress();
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId); $request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId, null, $payload);
// Customer Ip data builder // Customer Ip data builder
$shopperIp = $quote->getRemoteIp(); $shopperIp = $quote->getXForwardedFor();
$request = $this->adyenRequestHelper->buildCustomerIpData($request, $shopperIp); $request = $this->adyenRequestHelper->buildCustomerIpData($request, $shopperIp);
// AddressDataBuilder // AddressDataBuilder
......
<?php
namespace Adyen\Payment\Model\Comment;
use Magento\Config\Model\Config\CommentInterface;
use Magento\Framework\Encryption\EncryptorInterface;
class ApiKeyEnding implements CommentInterface
{
/**
* @var EncryptorInterface
*/
private $encryptor;
/**
* ApiKeyEnding constructor.
*
* @param EncryptorInterface $encryptor Magento encryptor, used to decrypt the API key.
*/
public function __construct(EncryptorInterface $encryptor)
{
$this->encryptor = $encryptor;
}
/**
* Method magically called by Magento. This returns the last 4 digits in the merchant's API key.
*
* @param string $elementValue The value of the field with this commented. In this case, an encrypted API key.
* @return string Some HTML markup to be displayed in the admin panel.
*/
public function getCommentText($elementValue)
{
$apiKeyEnding = substr($this->encryptor->decrypt(trim($elementValue)), -4);
if (!$apiKeyEnding) {
return '';
}
return "Key stored ending in <strong>$apiKeyEnding</strong>";
}
}
\ No newline at end of file
...@@ -30,6 +30,11 @@ class Installments extends \Magento\Framework\App\Config\Value ...@@ -30,6 +30,11 @@ class Installments extends \Magento\Framework\App\Config\Value
*/ */
protected $mathRandom; protected $mathRandom;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
...@@ -46,11 +51,13 @@ class Installments extends \Magento\Framework\App\Config\Value ...@@ -46,11 +51,13 @@ class Installments extends \Magento\Framework\App\Config\Value
\Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Math\Random $mathRandom,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [] array $data = []
) { ) {
$this->mathRandom = $mathRandom; $this->mathRandom = $mathRandom;
$this->serializer = $serializer;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
} }
...@@ -62,8 +69,7 @@ class Installments extends \Magento\Framework\App\Config\Value ...@@ -62,8 +69,7 @@ class Installments extends \Magento\Framework\App\Config\Value
public function beforeSave() public function beforeSave()
{ {
$value = $this->getValue(); $value = $this->getValue();
$unserialized = @unserialize($value); if (!is_array($value)) {
if ($unserialized !== false) {
return $this; return $this;
} }
$result = []; $result = [];
...@@ -94,7 +100,7 @@ class Installments extends \Magento\Framework\App\Config\Value ...@@ -94,7 +100,7 @@ class Installments extends \Magento\Framework\App\Config\Value
$finalResult[$key] = $installments; $finalResult[$key] = $installments;
} }
$this->setValue(serialize($finalResult)); $this->setValue($this->serializer->serialize($finalResult));
return $this; return $this;
} }
...@@ -106,7 +112,7 @@ class Installments extends \Magento\Framework\App\Config\Value ...@@ -106,7 +112,7 @@ class Installments extends \Magento\Framework\App\Config\Value
protected function _afterLoad() protected function _afterLoad()
{ {
$value = $this->getValue(); $value = $this->getValue();
$value = unserialize($value); $value = $this->serializer->unserialize($value);
if (is_array($value)) { if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value); $value = $this->encodeArrayFieldValue($value);
$this->setValue($value); $this->setValue($value);
......
...@@ -30,12 +30,18 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -30,12 +30,18 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
*/ */
protected $mathRandom; protected $mathRandom;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Math\Random $mathRandom
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data * @param array $data
...@@ -46,11 +52,13 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -46,11 +52,13 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
\Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Math\Random $mathRandom,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [] array $data = []
) { ) {
$this->mathRandom = $mathRandom; $this->mathRandom = $mathRandom;
$this->serializer = $serializer;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
} }
...@@ -62,9 +70,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -62,9 +70,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
public function beforeSave() public function beforeSave()
{ {
$value = $this->getValue(); $value = $this->getValue();
if (!is_array($value)) {
$unserialized = @unserialize($value);
if ($unserialized !== false) {
return $this; return $this;
} }
$result = []; $result = [];
...@@ -87,7 +93,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -87,7 +93,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
asort($result); asort($result);
$this->setValue(serialize($result)); $this->setValue($this->serializer->serialize($result));
return $this; return $this;
} }
...@@ -100,11 +106,12 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -100,11 +106,12 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
protected function _afterLoad() protected function _afterLoad()
{ {
$value = $this->getValue(); $value = $this->getValue();
$value = unserialize($value); if(!empty($value)) {
$value = $this->serializer->unserialize($value);
if (is_array($value)) { if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value); $value = $this->encodeArrayFieldValue($value);
$this->setValue($value); $this->setValue($value);
}
} }
return $this; return $this;
} }
......
...@@ -219,6 +219,11 @@ class Cron ...@@ -219,6 +219,11 @@ class Cron
*/ */
private $transactionBuilder; private $transactionBuilder;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -263,7 +268,8 @@ class Cron ...@@ -263,7 +268,8 @@ class Cron
SearchCriteriaBuilder $searchCriteriaBuilder, SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepository $orderRepository, OrderRepository $orderRepository,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel, \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder \Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -285,6 +291,7 @@ class Cron ...@@ -285,6 +291,7 @@ class Cron
$this->orderRepository = $orderRepository; $this->orderRepository = $orderRepository;
$this->agreementResourceModel = $agreementResourceModel; $this->agreementResourceModel = $agreementResourceModel;
$this->transactionBuilder = $transactionBuilder; $this->transactionBuilder = $transactionBuilder;
$this->serializer = $serializer;
} }
/** /**
...@@ -501,8 +508,7 @@ class Cron ...@@ -501,8 +508,7 @@ class Cron
$this->_reason = $notification->getPaymentMethod(); $this->_reason = $notification->getPaymentMethod();
$this->_value = $notification->getAmountValue(); $this->_value = $notification->getAmountValue();
$additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
$additionalData = unserialize($notification->getAdditionalData());
// boleto data // boleto data
if ($this->_paymentMethodCode() == "adyen_boleto") { if ($this->_paymentMethodCode() == "adyen_boleto") {
...@@ -672,7 +678,8 @@ class Cron ...@@ -672,7 +678,8 @@ class Cron
{ {
$this->_adyenLogger->addAdyenNotificationCronjob('Updating the Adyen attributes of the order'); $this->_adyenLogger->addAdyenNotificationCronjob('Updating the Adyen attributes of the order');
$additionalData = unserialize($notification->getAdditionalData()); $additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
$_paymentCode = $this->_paymentMethodCode(); $_paymentCode = $this->_paymentMethodCode();
if ($this->_eventCode == Notification::AUTHORISATION if ($this->_eventCode == Notification::AUTHORISATION
......
...@@ -333,7 +333,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not ...@@ -333,7 +333,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not
* @param string $additionalData * @param string $additionalData
* @return $this * @return $this
*/ */
public function setAddtionalData($additionalData) public function setAdditionalData($additionalData)
{ {
return $this->setData(self::ADDITIONAL_DATA, $additionalData); return $this->setData(self::ADDITIONAL_DATA, $additionalData);
} }
......
...@@ -69,6 +69,10 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -69,6 +69,10 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
*/ */
private $storeManager; private $storeManager;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* AdyenCcConfigProvider constructor. * AdyenCcConfigProvider constructor.
...@@ -80,6 +84,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -80,6 +84,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
* @param \Magento\Framework\View\Asset\Source $assetSource * @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Payment\Model\CcConfig $ccConfig * @param \Magento\Payment\Model\CcConfig $ccConfig
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/ */
public function __construct( public function __construct(
\Magento\Payment\Helper\Data $paymentHelper, \Magento\Payment\Helper\Data $paymentHelper,
...@@ -88,7 +93,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -88,7 +93,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\View\Asset\Source $assetSource,
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Payment\Model\CcConfig $ccConfig \Magento\Payment\Model\CcConfig $ccConfig,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
$this->_paymentHelper = $paymentHelper; $this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
...@@ -97,6 +103,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -97,6 +103,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$this->_assetSource = $assetSource; $this->_assetSource = $assetSource;
$this->ccConfig = $ccConfig; $this->ccConfig = $ccConfig;
$this->storeManager = $storeManager; $this->storeManager = $storeManager;
$this->serializer = $serializer;
} }
/** /**
...@@ -156,7 +163,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -156,7 +163,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$installments = $this->_adyenHelper->getAdyenCcConfigData('installments'); $installments = $this->_adyenHelper->getAdyenCcConfigData('installments');
if ($installmentsEnabled && $installments) { if ($installmentsEnabled && $installments) {
$config['payment']['adyenCc']['installments'] = unserialize($installments); $config['payment']['adyenCc']['installments'] = $this->serializer->unserialize($installments);
$config['payment']['adyenCc']['hasInstallments'] = true; $config['payment']['adyenCc']['hasInstallments'] = true;
} else { } else {
$config['payment']['adyenCc']['installments'] = []; $config['payment']['adyenCc']['installments'] = [];
......
...@@ -144,7 +144,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -144,7 +144,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes(); $config['payment'] ['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes();
$config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId(); $config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->session->getQuoteId() . date('c')); $config['payment'] ['adyenHpp']['deviceIdentToken'] = hash("sha256",$this->session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI']; $config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
return $config; return $config;
......
...@@ -53,22 +53,32 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface ...@@ -53,22 +53,32 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface
*/ */
protected $adyenHelper; protected $adyenHelper;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* AdyenHppConfigProvider constructor. * AdyenHppConfigProvider constructor.
* *
* @param PaymentHelper $paymentHelper * @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper, \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper,
\Adyen\Payment\Helper\Data $adyenHelper \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
$this->request = $request; $this->request = $request;
$this->urlBuilder = $urlBuilder; $this->urlBuilder = $urlBuilder;
$this->paymentMethodsHelper = $paymentMethodsHelper; $this->paymentMethodsHelper = $paymentMethodsHelper;
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->serializer = $serializer;
} }
/** /**
...@@ -91,7 +101,9 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface ...@@ -91,7 +101,9 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface
] ]
]; ];
$config['payment']['adyenPos']['connectedTerminals'] = $this->getConnectedTerminals(); if ($this->adyenHelper->getAdyenPosCloudConfigDataFlag("active")) {
$config['payment']['adyenPos']['connectedTerminals'] = $this->getConnectedTerminals();
}
// has installments by default false // has installments by default false
$config['payment']['adyenPos']['hasInstallments'] = false; $config['payment']['adyenPos']['hasInstallments'] = false;
...@@ -101,7 +113,7 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface ...@@ -101,7 +113,7 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface
$installments = $this->adyenHelper->getAdyenPosCloudConfigData('installments'); $installments = $this->adyenHelper->getAdyenPosCloudConfigData('installments');
if ($installmentsEnabled && $installments) { if ($installmentsEnabled && $installments) {
$config['payment']['adyenPos']['installments'] = unserialize($installments); $config['payment']['adyenPos']['installments'] = $this->serializer->unserialize($installments);
$config['payment']['adyenPos']['hasInstallments'] = true; $config['payment']['adyenPos']['hasInstallments'] = true;
} else { } else {
$config['payment']['adyenPos']['installments'] = []; $config['payment']['adyenPos']['installments'] = [];
......
<?php
namespace Adyen\Payment\Test\Comment;
use Adyen\Payment\Model\Comment\ApiKeyEnding;
use Magento\Framework\Encryption\Encryptor;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class ApiKeyEndingTest extends TestCase
{
/**
* @var ApiKeyEnding
*/
private $apiKeyEndingComment;
public function setUp()
{
/** @var MockObject|Encryptor $encryptor */
$encryptor = $this->createMock(Encryptor::class);
$map = [
['4321', '1234'],
['asdfasdfasdf', 'qwerqwerqwer']
];
$encryptor->method('decrypt')
->will($this->returnValueMap($map));
$this->apiKeyEndingComment = new ApiKeyEnding($encryptor);
}
public function testCommentReturnsJustTheEnding()
{
$this->assertEquals('Key stored ending in <strong>1234</strong>', $this->apiKeyEndingComment->getCommentText('4321'));
$this->assertEquals('Key stored ending in <strong>qwer</strong>', $this->apiKeyEndingComment->getCommentText('asdfasdfasdf'));
}
}
...@@ -50,6 +50,15 @@ class DataTest extends \PHPUnit\Framework\TestCase ...@@ -50,6 +50,15 @@ class DataTest extends \PHPUnit\Framework\TestCase
$notificationFactory = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory::class); $notificationFactory = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory::class);
$taxConfig = $this->getSimpleMock(\Magento\Tax\Model\Config::class); $taxConfig = $this->getSimpleMock(\Magento\Tax\Model\Config::class);
$taxCalculation = $this->getSimpleMock(\Magento\Tax\Model\Calculation::class); $taxCalculation = $this->getSimpleMock(\Magento\Tax\Model\Calculation::class);
$productMetadata = $this->getSimpleMock(\Magento\Framework\App\ProductMetadata::class);
$adyenLogger = $this->getSimpleMock(\Adyen\Payment\Logger\AdyenLogger::class);
$storeManager = $this->getSimpleMock(\Magento\Store\Model\StoreManager::class);
$cache = $this->getSimpleMock(\Magento\Framework\App\CacheInterface::class);
$billingAgreementFactory = $this->getSimpleMock(\Adyen\Payment\Model\Billing\AgreementFactory::class);
$agreementResourceModel = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Billing\Agreement::class);
$localeResolver = $this->getSimpleMock(\Magento\Framework\Locale\ResolverInterface::class);
$config = $this->getSimpleMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$helperBackend = $this->getSimpleMock(\Magento\Backend\Helper\Data::class);
$this->dataHelper = new \Adyen\Payment\Helper\Data( $this->dataHelper = new \Adyen\Payment\Helper\Data(
$context, $context,
...@@ -62,7 +71,16 @@ class DataTest extends \PHPUnit\Framework\TestCase ...@@ -62,7 +71,16 @@ class DataTest extends \PHPUnit\Framework\TestCase
$assetSource, $assetSource,
$notificationFactory, $notificationFactory,
$taxConfig, $taxConfig,
$taxCalculation $taxCalculation,
$productMetadata,
$adyenLogger,
$storeManager,
$cache,
$billingAgreementFactory,
$agreementResourceModel,
$localeResolver,
$config,
$helperBackend
); );
} }
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Helper\Data as AdyenHelper;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class AdyenOriginKeyTest extends TestCase
{
/** @var AdyenHelper|MockObject */
private $helper;
protected function setUp()
{
$this->helper = $this->getMockBuilder(AdyenHelper::class)
->disableOriginalConstructor()
->getMock();
}
/** @throws \Exception */
public function testGetOriginKey()
{
$this->helper->method('getOriginKeyForBaseUrl')
->willReturn('something');
$module = new AdyenOriginKey($this->helper);
$this->assertEquals('something', $module->getOriginKey());
}
/** @throws \Exception */
public function testGetOriginKeyDoesNotHandleExceptions()
{
$this->helper->method('getOriginKeyForBaseUrl')
->willThrowException(new \Exception('Some error message', 400));
$module = new AdyenOriginKey($this->helper);
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Some error message');
$this->expectExceptionCode(400);
$module->getOriginKey();
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../../../../vendor/autoload.php';
<!--
~ ######
~ ######
~ ############ ####( ###### #####. ###### ############ ############
~ ############# #####( ###### #####. ###### ############# #############
~ ###### #####( ###### #####. ###### ##### ###### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
~ ###### ###### #####( ###### #####. ###### ##### ##### ######
~ ############# ############# ############# ############# ##### ######
~ ############ ############ ############# ############ ##### ######
~ ######
~ #############
~ ############
~
~ Adyen Payment Module
~
~ Copyright (c) 2019 Adyen B.V.
~ This file is open source and available under the MIT license.
~ See the LICENSE file for more info.
~
~ Author: Adyen <magento@adyen.com>
-->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
bootstrap="./bootstrap.php"
>
<testsuites>
<testsuite name="default">
<directory>.</directory>
</testsuite>
</testsuites>
</phpunit>
...@@ -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": "4.4.0", "version": "4.5.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
"require": { "require": {
"adyen/php-api-library": "~2.1", "adyen/php-api-library": "~2.1",
"magento/framework": ">=101.0.8 <102 || >=102.0.1", "magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*" "magento/module-vault": "101.*",
"php": "~7.0.13|~7.1.0"
},
"require-dev": {
"phpunit/phpunit": "~6.5.0"
}, },
"autoload": { "autoload": {
"files": [ "files": [
...@@ -30,5 +34,11 @@ ...@@ -30,5 +34,11 @@
"psr-4": { "psr-4": {
"Adyen\\Payment\\Tests\\": "tests/" "Adyen\\Payment\\Tests\\": "tests/"
} }
},
"scripts": {
"test": [
"Composer\\Config::disableProcessTimeout",
"vendor/bin/phpunit -c Test/phpunit.xml"
]
} }
} }
...@@ -58,12 +58,14 @@ ...@@ -58,12 +58,14 @@
<tooltip>Copy this from the Test Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip> <tooltip>Copy this from the Test Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_pos_cloud/api_key_test</config_path> <config_path>payment/adyen_pos_cloud/api_key_test</config_path>
<comment model="Adyen\Payment\Model\Comment\ApiKeyEnding" />
</field> </field>
<field id="api_key_live" translate="label" type="obscure" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="api_key_live" translate="label" type="obscure" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>API key for Cloud API LIVE</label> <label>API key for Cloud API LIVE</label>
<tooltip>Copy this from the Live Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip> <tooltip>Copy this from the Live Adyen Customer Area => Settings => Users => System => [web service user]=> Checkout API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_pos_cloud/api_key_live</config_path> <config_path>payment/adyen_pos_cloud/api_key_live</config_path>
<comment model="Adyen\Payment\Model\Comment\ApiKeyEnding" />
</field> </field>
<field id="capture_mode_pos" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="capture_mode_pos" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Capture Delay</label> <label>Capture Delay</label>
......
...@@ -54,12 +54,14 @@ ...@@ -54,12 +54,14 @@
<tooltip>If you don't know your Api-Key, log in to your Test Customer Area. Navigate to Settings > Users > System, and click on your webservice user, normally this will be ws@Company.YourCompanyAccount. Under Checkout token is your API Key.</tooltip> <tooltip>If you don't know your Api-Key, log in to your Test Customer Area. Navigate to Settings > Users > System, and click on your webservice user, normally this will be ws@Company.YourCompanyAccount. Under Checkout token is your API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/api_key_test</config_path> <config_path>payment/adyen_abstract/api_key_test</config_path>
<comment model="Adyen\Payment\Model\Comment\ApiKeyEnding" />
</field> </field>
<field id="api_key_live" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="api_key_live" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<label>API key for Live</label> <label>API key for Live</label>
<tooltip>If you don't know your Api-Key, log in to your Live Customer Area. Navigate to Settings > Users > System, and click on your webservice user, normally this will be ws@Company.YourCompanyAccount. Under Checkout token is your API Key.</tooltip> <tooltip>If you don't know your Api-Key, log in to your Live Customer Area. Navigate to Settings > Users > System, and click on your webservice user, normally this will be ws@Company.YourCompanyAccount. Under Checkout token is your API Key.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/api_key_live</config_path> <config_path>payment/adyen_abstract/api_key_live</config_path>
<comment model="Adyen\Payment\Model\Comment\ApiKeyEnding" />
</field> </field>
<field id="live_endpoint_url_prefix" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="live_endpoint_url_prefix" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Live endpoint prefix</label> <label>Live endpoint prefix</label>
......
...@@ -958,8 +958,45 @@ ...@@ -958,8 +958,45 @@
<type name="Adyen\Payment\Helper\Data"> <type name="Adyen\Payment\Helper\Data">
<arguments> <arguments>
<argument name="dataStorage" xsi:type="object">adyenPaymentConfigDataStorage</argument> <argument name="dataStorage" xsi:type="object">adyenPaymentConfigDataStorage</argument>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments> </arguments>
</type> </type>
<type name="Adyen\Payment\Model\Config\Backend\Installments">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Config\Backend\InstallmentsPosCloud">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Gateway\Validator\InstallmentValidator">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Ui\AdyenCcConfigProvider">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Cron">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Controller\Process\Json">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" <preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface"
type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"/> type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"/>
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" <preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface"
...@@ -972,6 +1009,8 @@ ...@@ -972,6 +1009,8 @@
type="Adyen\Payment\Model\AdyenPaymentProcess"/> type="Adyen\Payment\Model\AdyenPaymentProcess"/>
<preference for="Adyen\Payment\Api\AdyenThreeDS2ProcessInterface" <preference for="Adyen\Payment\Api\AdyenThreeDS2ProcessInterface"
type="Adyen\Payment\Model\AdyenThreeDS2Process"/> type="Adyen\Payment\Model\AdyenThreeDS2Process"/>
<preference for="Adyen\Payment\Api\AdyenOriginKeyInterface"
type="Adyen\Payment\Model\AdyenOriginKey"/>
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface"> <type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/> <plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type> </type>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="4.4.0"> <module name="Adyen_Payment" setup_version="4.5.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -71,4 +71,11 @@ ...@@ -71,4 +71,11 @@
<resource ref="anonymous"/> <resource ref="anonymous"/>
</resources> </resources>
</route> </route>
<route url="/V1/adyen/originKey" method="GET">
<service class="Adyen\Payment\Api\AdyenOriginKeyInterface" method="getOriginKey"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes> </routes>
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
define( define(
[ [
'jquery', 'jquery',
'ko',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
...@@ -34,8 +35,10 @@ define( ...@@ -34,8 +35,10 @@ define(
'Magento_Ui/js/model/messages', 'Magento_Ui/js/model/messages',
'mage/translate', 'mage/translate',
], ],
function ($, quote, Component, placeOrderAction, additionalValidators, urlBuilder, storage, url, Messages, $t) { function ($, ko, quote, Component, placeOrderAction, additionalValidators, urlBuilder, storage, url, Messages, $t) {
'use strict'; 'use strict';
var canMakeApplePayPayments = ko.observable(false);
var applePayVersion = 6;
return Component.extend({ return Component.extend({
self: this, self: this,
defaults: { defaults: {
...@@ -78,11 +81,12 @@ define( ...@@ -78,11 +81,12 @@ define(
var request = { var request = {
countryCode: quote.billingAddress().countryId, countryCode: quote.billingAddress().countryId,
currencyCode: quote.totals().quote_currency_code, currencyCode: quote.totals().quote_currency_code,
supportedNetworks: ['visa', 'masterCard', 'amex', 'discover'], supportedNetworks: ['visa', 'masterCard', 'amex', 'discover', 'maestro', 'vPay', 'jcb', 'elo'],
merchantCapabilities: ['supports3DS'], merchantCapabilities: ['supports3DS'],
total: {label: $t('Grand Total'), amount: quote.totals().base_grand_total} total: {label: $t('Grand Total'), amount: quote.totals().base_grand_total}
}; };
var session = new ApplePaySession(2, request); var session = new ApplePaySession(applePayVersion, request);
session.onvalidatemerchant = function (event) { session.onvalidatemerchant = function (event) {
var promise = self.performValidation(event.validationURL); var promise = self.performValidation(event.validationURL);
promise.then(function (merchantSession) { promise.then(function (merchantSession) {
...@@ -139,7 +143,16 @@ define( ...@@ -139,7 +143,16 @@ define(
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
isApplePayAllowed: function () { isApplePayAllowed: function () {
if (window.ApplePaySession) { var self = this;
// validate if applepay is allowed, it will be picked up by the isApplePayVisible method
var promise = window.ApplePaySession.canMakePaymentsWithActiveCard(self.getMerchantIdentifier());
promise.then(function (canMakePayments) {
if (canMakePayments)
canMakeApplePayPayments(true);
});
if (window.ApplePaySession && window.ApplePaySession.supportsVersion(applePayVersion) ) {
return true; return true;
} }
return false; return false;
...@@ -177,6 +190,12 @@ define( ...@@ -177,6 +190,12 @@ define(
deferred.resolve(true); deferred.resolve(true);
} }
); );
},
isApplePayVisible: function() {
return canMakeApplePayPayments();
},
getMerchantIdentifier: function() {
return window.checkoutConfig.payment.adyen_apple_pay.merchant_identifier;
} }
}); });
} }
......
...@@ -280,6 +280,7 @@ define( ...@@ -280,6 +280,7 @@ define(
var data = { var data = {
'method': this.item.method, 'method': this.item.method,
additional_data: { additional_data: {
'guestEmail': quote.guestEmail,
'cc_type': this.creditCardType(), 'cc_type': this.creditCardType(),
'number': this.creditCardNumber(), 'number': this.creditCardNumber(),
'cvc': this.securityCode(), 'cvc': this.securityCode(),
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
--> -->
<!-- ko if: isApplePayAllowed() --> <!-- ko if: isApplePayAllowed() -->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}"> <div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}, visible: isApplePayVisible()">
<div class="payment-method-title field choice"> <div class="payment-method-title field choice">
<input type="radio" <input type="radio"
name="payment[method]" name="payment[method]"
......
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